1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_COMMON_WEBSOCKET_H_ 6 #define CONTENT_COMMON_WEBSOCKET_H_ 7 8 #include <string> 9 #include <utility> 10 #include <vector> 11 12 #include "base/strings/string_split.h" 13 #include "base/time/time.h" 14 #include "url/gurl.h" 15 16 namespace content { 17 18 // WebSocket data message types sent between the browser and renderer processes. 19 enum WebSocketMessageType { 20 WEB_SOCKET_MESSAGE_TYPE_CONTINUATION = 0x0, 21 WEB_SOCKET_MESSAGE_TYPE_TEXT = 0x1, 22 WEB_SOCKET_MESSAGE_TYPE_BINARY = 0x2, 23 WEB_SOCKET_MESSAGE_TYPE_LAST = WEB_SOCKET_MESSAGE_TYPE_BINARY 24 }; 25 26 // Opening handshake request information which will be shown in the inspector. 27 // All string data should be encoded to ASCII in the browser process. 28 struct WebSocketHandshakeRequest { 29 WebSocketHandshakeRequest(); 30 ~WebSocketHandshakeRequest(); 31 32 // The request URL 33 GURL url; 34 // Additional HTTP request headers 35 base::StringPairs headers; 36 // HTTP request headers raw string 37 std::string headers_text; 38 // The time that this request is sent 39 base::Time request_time; 40 }; 41 42 // Opening handshake response information which will be shown in the inspector. 43 // All string data should be encoded to ASCII in the browser process. 44 struct WebSocketHandshakeResponse { 45 WebSocketHandshakeResponse(); 46 ~WebSocketHandshakeResponse(); 47 48 // The request URL 49 GURL url; 50 // HTTP status code 51 int status_code; 52 // HTTP status text 53 std::string status_text; 54 // Additional HTTP response headers 55 std::vector<std::pair<std::string, std::string> > headers; 56 // HTTP response headers raw string 57 std::string headers_text; 58 // The time that this response arrives 59 base::Time response_time; 60 }; 61 62 } // namespace content 63 64 #endif // CONTENT_COMMON_WEBSOCKET_H_ 65