summaryrefslogtreecommitdiffstats
path: root/content/child
diff options
context:
space:
mode:
authoryhirano@chromium.org <yhirano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-27 02:12:56 +0000
committeryhirano@chromium.org <yhirano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-27 02:12:56 +0000
commit3572daea423c006950ba12340d7961a7a1768875 (patch)
tree7ed4ce81452f5f72fd607a717e9077ca19df023b /content/child
parent60531d54b668c625ea5e2e7d4285ae8ac7388691 (diff)
downloadchromium_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/child')
-rw-r--r--content/child/websocket_bridge.cc38
-rw-r--r--content/child/websocket_bridge.h2
-rw-r--r--content/child/websocket_dispatcher.cc2
3 files changed, 42 insertions, 0 deletions
diff --git a/content/child/websocket_bridge.cc b/content/child/websocket_bridge.cc
index 5f0e37d..c8e74ef 100644
--- a/content/child/websocket_bridge.cc
+++ b/content/child/websocket_bridge.cc
@@ -6,6 +6,7 @@
#include <stdint.h>
#include <string>
+#include <utility>
#include <vector>
#include "base/logging.h"
@@ -19,6 +20,8 @@
#include "url/gurl.h"
#include "third_party/WebKit/public/platform/WebSocketHandle.h"
#include "third_party/WebKit/public/platform/WebSocketHandleClient.h"
+#include "third_party/WebKit/public/platform/WebSocketHandshakeRequestInfo.h"
+#include "third_party/WebKit/public/platform/WebSocketHandshakeResponseInfo.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/platform/WebVector.h"
@@ -57,6 +60,10 @@ bool WebSocketBridge::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(WebSocketBridge, msg)
IPC_MESSAGE_HANDLER(WebSocketMsg_AddChannelResponse, DidConnect)
+ IPC_MESSAGE_HANDLER(WebSocketMsg_NotifyStartOpeningHandshake,
+ DidStartOpeningHandshake)
+ IPC_MESSAGE_HANDLER(WebSocketMsg_NotifyFinishOpeningHandshake,
+ DidFinishOpeningHandshake)
IPC_MESSAGE_HANDLER(WebSocketMsg_NotifyFailure, DidFail)
IPC_MESSAGE_HANDLER(WebSocketMsg_SendFrame, DidReceiveData)
IPC_MESSAGE_HANDLER(WebSocketMsg_FlowControl, DidReceiveFlowControl)
@@ -85,6 +92,37 @@ void WebSocketBridge::DidConnect(bool fail,
// |this| can be deleted here.
}
+void WebSocketBridge::DidStartOpeningHandshake(
+ const WebSocketHandshakeRequest& request) {
+ DVLOG(1) << "WebSocketBridge::DidStartOpeningHandshake("
+ << request.url << ")";
+ // All strings are already encoded to ASCII in the browser.
+ blink::WebSocketHandshakeRequestInfo request_to_pass;
+ request_to_pass.setURL(WebURL(request.url));
+ for (size_t i = 0; i < request.headers.size(); ++i) {
+ const std::pair<std::string, std::string>& header = request.headers[i];
+ request_to_pass.addHeaderField(WebString::fromLatin1(header.first),
+ WebString::fromLatin1(header.second));
+ }
+ client_->didStartOpeningHandshake(this, request_to_pass);
+}
+
+void WebSocketBridge::DidFinishOpeningHandshake(
+ const WebSocketHandshakeResponse& response) {
+ DVLOG(1) << "WebSocketBridge::DidFinishOpeningHandshake("
+ << response.url << ")";
+ // All strings are already encoded to ASCII in the browser.
+ blink::WebSocketHandshakeResponseInfo response_to_pass;
+ response_to_pass.setStatusCode(response.status_code);
+ response_to_pass.setStatusText(WebString::fromLatin1(response.status_text));
+ for (size_t i = 0; i < response.headers.size(); ++i) {
+ const std::pair<std::string, std::string>& header = response.headers[i];
+ response_to_pass.addHeaderField(WebString::fromLatin1(header.first),
+ WebString::fromLatin1(header.second));
+ }
+ client_->didFinishOpeningHandshake(this, response_to_pass);
+}
+
void WebSocketBridge::DidFail(const std::string& message) {
DVLOG(1) << "WebSocketBridge::DidFail(" << message << ")";
WebSocketHandleClient* client = client_;
diff --git a/content/child/websocket_bridge.h b/content/child/websocket_bridge.h
index 1ad8368..830939b 100644
--- a/content/child/websocket_bridge.h
+++ b/content/child/websocket_bridge.h
@@ -47,6 +47,8 @@ class WebSocketBridge : public blink::WebSocketHandle {
void DidConnect(bool fail,
const std::string& selected_protocol,
const std::string& extensions);
+ void DidStartOpeningHandshake(const WebSocketHandshakeRequest& request);
+ void DidFinishOpeningHandshake(const WebSocketHandshakeResponse& response);
void DidFail(const std::string& message);
void DidReceiveData(bool fin,
WebSocketMessageType type,
diff --git a/content/child/websocket_dispatcher.cc b/content/child/websocket_dispatcher.cc
index 3ff5fe7..6c32dd4 100644
--- a/content/child/websocket_dispatcher.cc
+++ b/content/child/websocket_dispatcher.cc
@@ -37,6 +37,8 @@ void WebSocketDispatcher::RemoveBridge(int channel_id) {
bool WebSocketDispatcher::OnMessageReceived(const IPC::Message& msg) {
switch (msg.type()) {
case WebSocketMsg_AddChannelResponse::ID:
+ case WebSocketMsg_NotifyStartOpeningHandshake::ID:
+ case WebSocketMsg_NotifyFinishOpeningHandshake::ID:
case WebSocketMsg_NotifyFailure::ID:
case WebSocketMsg_SendFrame::ID:
case WebSocketMsg_FlowControl::ID: