diff options
author | yhirano@chromium.org <yhirano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-27 02:12:56 +0000 |
---|---|---|
committer | yhirano@chromium.org <yhirano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-27 02:12:56 +0000 |
commit | 3572daea423c006950ba12340d7961a7a1768875 (patch) | |
tree | 7ed4ce81452f5f72fd607a717e9077ca19df023b /content/common | |
parent | 60531d54b668c625ea5e2e7d4285ae8ac7388691 (diff) | |
download | chromium_src-3572daea423c006950ba12340d7961a7a1768875.zip chromium_src-3572daea423c006950ba12340d7961a7a1768875.tar.gz chromium_src-3572daea423c006950ba12340d7961a7a1768875.tar.bz2 |
Notify WebSocket handshake information to the renderer, chromium side
Notify WebSocket opening handshake request / response to the renderer process
to show them in the inspector.
Moved WebSocketHandshake{Request, Response} from modules/websockets
to platform/network to use them in platform/exported .
Blink side CL is: https://codereview.chromium.org/77273002/
BUG=310405
R=ricea, tsepez, jam
Review URL: https://codereview.chromium.org/77513002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common')
-rw-r--r-- | content/common/OWNERS | 6 | ||||
-rw-r--r-- | content/common/websocket.cc | 18 | ||||
-rw-r--r-- | content/common/websocket.h | 39 | ||||
-rw-r--r-- | content/common/websocket_messages.h | 27 |
4 files changed, 87 insertions, 3 deletions
diff --git a/content/common/OWNERS b/content/common/OWNERS index 148fe7a..5601dee 100644 --- a/content/common/OWNERS +++ b/content/common/OWNERS @@ -38,6 +38,6 @@ per-file accessibility_node_data.*=dmazzoni@chromium.org per-file accessibility_node_data.*=dtseng@chromium.org # WebSocket -per-file websocket.h=ricea@chromium.org -per-file websocket.h=tyoshino@chromium.org -per-file websocket.h=yhirano@chromium.org +per-file websocket.*=ricea@chromium.org +per-file websocket.*=tyoshino@chromium.org +per-file websocket.*=yhirano@chromium.org diff --git a/content/common/websocket.cc b/content/common/websocket.cc new file mode 100644 index 0000000..b1d57611 --- /dev/null +++ b/content/common/websocket.cc @@ -0,0 +1,18 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/common/websocket.h" + +namespace content { + +WebSocketHandshakeRequest::WebSocketHandshakeRequest() {} + +WebSocketHandshakeRequest::~WebSocketHandshakeRequest() {} + +WebSocketHandshakeResponse::WebSocketHandshakeResponse() + : status_code(0) {} + +WebSocketHandshakeResponse::~WebSocketHandshakeResponse() {} + +} // namespace content diff --git a/content/common/websocket.h b/content/common/websocket.h index 3bc8a99..98d75fa 100644 --- a/content/common/websocket.h +++ b/content/common/websocket.h @@ -5,6 +5,13 @@ #ifndef CONTENT_COMMON_WEBSOCKET_H_ #define CONTENT_COMMON_WEBSOCKET_H_ +#include <string> +#include <utility> +#include <vector> + +#include "base/time/time.h" +#include "url/gurl.h" + namespace content { // WebSocket data message types sent between the browser and renderer processes. @@ -14,6 +21,38 @@ enum WebSocketMessageType { WEB_SOCKET_MESSAGE_TYPE_BINARY = 0x2 }; +// Opening handshake request information which will be shown in the inspector. +// All string data should be encoded to ASCII in the browser process. +struct WebSocketHandshakeRequest { + WebSocketHandshakeRequest(); + ~WebSocketHandshakeRequest(); + + // The request URL + GURL url; + // Additional HTTP request headers + std::vector<std::pair<std::string, std::string> > headers; + // The time that this request is sent + base::Time request_time; +}; + +// Opening handshake response information which will be shown in the inspector. +// All string data should be encoded to ASCII in the browser process. +struct WebSocketHandshakeResponse { + WebSocketHandshakeResponse(); + ~WebSocketHandshakeResponse(); + + // The request URL + GURL url; + // HTTP status code + int status_code; + // HTTP status text + std::string status_text; + // Additional HTTP response headers + std::vector<std::pair<std::string, std::string> > headers; + // The time that this response arrives + base::Time response_time; +}; + } // namespace content #endif // CONTENT_COMMON_WEBSOCKET_H_ diff --git a/content/common/websocket_messages.h b/content/common/websocket_messages.h index 233aacf..dadece4 100644 --- a/content/common/websocket_messages.h +++ b/content/common/websocket_messages.h @@ -26,6 +26,20 @@ #define IPC_MESSAGE_EXPORT CONTENT_EXPORT #define IPC_MESSAGE_START WebSocketMsgStart +IPC_STRUCT_TRAITS_BEGIN(content::WebSocketHandshakeRequest) + IPC_STRUCT_TRAITS_MEMBER(url) + IPC_STRUCT_TRAITS_MEMBER(headers) + IPC_STRUCT_TRAITS_MEMBER(request_time) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(content::WebSocketHandshakeResponse) + IPC_STRUCT_TRAITS_MEMBER(url) + IPC_STRUCT_TRAITS_MEMBER(status_code) + IPC_STRUCT_TRAITS_MEMBER(status_text) + IPC_STRUCT_TRAITS_MEMBER(headers) + IPC_STRUCT_TRAITS_MEMBER(response_time) +IPC_STRUCT_TRAITS_END() + // WebSocket messages sent from the renderer to the browser. // Open new virtual WebSocket connection to |socket_url|. |channel_id| is an @@ -59,6 +73,19 @@ IPC_MESSAGE_ROUTED3(WebSocketMsg_AddChannelResponse, std::string /* selected_protocol */, std::string /* extensions */) +// Notify the renderer that the browser has started an opening handshake. +// This message is for showing the request in the inspector and +// can be omitted if the inspector is not active. +IPC_MESSAGE_ROUTED1(WebSocketMsg_NotifyStartOpeningHandshake, + content::WebSocketHandshakeRequest /* request */) + +// Notify the renderer that the browser has finished an opening handshake. +// This message precedes AddChannelResponse. +// This message is for showing the response in the inspector and +// can be omitted if the inspector is not active. +IPC_MESSAGE_ROUTED1(WebSocketMsg_NotifyFinishOpeningHandshake, + content::WebSocketHandshakeResponse /* response */) + // Notify the renderer that the browser is required to fail the connection // (see RFC6455 7.1.7 for details). // When the renderer process receives this messages it does the following: |