summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryhirano@chromium.org <yhirano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-24 09:37:31 +0000
committeryhirano@chromium.org <yhirano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-24 09:37:31 +0000
commitd7d8229037bb3a02e4d2162afccd3821fde23327 (patch)
treef105795bec4780bde8780a43154de19191db020c
parentb76ee6f64a25f1a20994fac0e653ac42f8e42ac0 (diff)
downloadchromium_src-d7d8229037bb3a02e4d2162afccd3821fde23327.zip
chromium_src-d7d8229037bb3a02e4d2162afccd3821fde23327.tar.gz
chromium_src-d7d8229037bb3a02e4d2162afccd3821fde23327.tar.bz2
Introduce webkit_glue bridges for the new WebSocket Implementation.
We are implementing the new WebSocket implementation. This CL introduces WebSocketDispatcher, an IPC message dispatcher. WebSocketBridge and other bridge classes are also introduces. Currently this CL doesn't change any behavior because nobody uses the classes yet. BUG=275459 Review URL: https://chromiumcodereview.appspot.com/22815034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224955 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/child/child_thread.cc4
-rw-r--r--content/child/child_thread.h7
-rw-r--r--content/child/webkitplatformsupport_impl.cc7
-rw-r--r--content/child/webkitplatformsupport_impl.h3
-rw-r--r--content/child/websocket_bridge.cc215
-rw-r--r--content/child/websocket_bridge.h64
-rw-r--r--content/child/websocket_dispatcher.cc64
-rw-r--r--content/child/websocket_dispatcher.h48
-rw-r--r--content/common/websocket_messages.h39
-rw-r--r--content/content_child.gypi4
-rw-r--r--content/test/test_webkit_platform_support.cc2
-rw-r--r--content/test/test_webkit_platform_support.h2
-rw-r--r--webkit/child/webkitplatformsupport_impl.h2
-rw-r--r--webkit/child/websocketstreamhandle_impl.cc2
-rw-r--r--webkit/glue/webkit_glue_unittest.cc2
15 files changed, 436 insertions, 29 deletions
diff --git a/content/child/child_thread.cc b/content/child/child_thread.cc
index c24528b..14ba2cc 100644
--- a/content/child/child_thread.cc
+++ b/content/child/child_thread.cc
@@ -25,6 +25,7 @@
#include "content/child/resource_dispatcher.h"
#include "content/child/socket_stream_dispatcher.h"
#include "content/child/thread_safe_sender.h"
+#include "content/child/websocket_dispatcher.h"
#include "content/common/child_process_messages.h"
#include "content/public/common/content_switches.h"
#include "ipc/ipc_logging.h"
@@ -146,6 +147,7 @@ void ChildThread::Init() {
resource_dispatcher_.reset(new ResourceDispatcher(this));
socket_stream_dispatcher_.reset(new SocketStreamDispatcher());
+ websocket_dispatcher_.reset(new WebSocketDispatcher);
file_system_dispatcher_.reset(new FileSystemDispatcher());
histogram_message_filter_ = new ChildHistogramMessageFilter();
@@ -321,6 +323,8 @@ bool ChildThread::OnMessageReceived(const IPC::Message& msg) {
return true;
if (socket_stream_dispatcher_->OnMessageReceived(msg))
return true;
+ if (websocket_dispatcher_->OnMessageReceived(msg))
+ return true;
if (file_system_dispatcher_->OnMessageReceived(msg))
return true;
diff --git a/content/child/child_thread.h b/content/child/child_thread.h
index b2095ab..94918feb 100644
--- a/content/child/child_thread.h
+++ b/content/child/child_thread.h
@@ -42,6 +42,7 @@ class QuotaMessageFilter;
class ResourceDispatcher;
class SocketStreamDispatcher;
class ThreadSafeSender;
+class WebSocketDispatcher;
// The main thread of a child process derives from this class.
class CONTENT_EXPORT ChildThread : public IPC::Listener, public IPC::Sender {
@@ -91,6 +92,10 @@ class CONTENT_EXPORT ChildThread : public IPC::Listener, public IPC::Sender {
return socket_stream_dispatcher_.get();
}
+ WebSocketDispatcher* websocket_dispatcher() const {
+ return websocket_dispatcher_.get();
+ }
+
FileSystemDispatcher* file_system_dispatcher() const {
return file_system_dispatcher_.get();
}
@@ -180,6 +185,8 @@ class CONTENT_EXPORT ChildThread : public IPC::Listener, public IPC::Sender {
// Handles SocketStream for this process.
scoped_ptr<SocketStreamDispatcher> socket_stream_dispatcher_;
+ scoped_ptr<WebSocketDispatcher> websocket_dispatcher_;
+
// The OnChannelError() callback was invoked - the channel is dead, don't
// attempt to communicate.
bool on_channel_error_called_;
diff --git a/content/child/webkitplatformsupport_impl.cc b/content/child/webkitplatformsupport_impl.cc
index 191b2f8..9d60e25 100644
--- a/content/child/webkitplatformsupport_impl.cc
+++ b/content/child/webkitplatformsupport_impl.cc
@@ -6,6 +6,7 @@
#include "content/child/child_thread.h"
#include "content/child/socket_stream_dispatcher.h"
#include "content/child/webkitplatformsupport_impl.h"
+#include "content/child/websocket_bridge.h"
#include "content/public/common/content_client.h"
namespace content {
@@ -33,7 +34,7 @@ WebKitPlatformSupportImpl::CreateResourceLoader(
}
webkit_glue::WebSocketStreamHandleBridge*
-WebKitPlatformSupportImpl::CreateWebSocketBridge(
+WebKitPlatformSupportImpl::CreateWebSocketStreamBridge(
WebKit::WebSocketStreamHandle* handle,
webkit_glue::WebSocketStreamHandleDelegate* delegate) {
SocketStreamDispatcher* dispatcher =
@@ -41,4 +42,8 @@ WebKitPlatformSupportImpl::CreateWebSocketBridge(
return dispatcher->CreateBridge(handle, delegate);
}
+WebKit::WebSocketHandle* WebKitPlatformSupportImpl::createWebSocketHandle() {
+ return new WebSocketBridge;
+}
+
} // namespace content
diff --git a/content/child/webkitplatformsupport_impl.h b/content/child/webkitplatformsupport_impl.h
index f74fcd9..3a484d1 100644
--- a/content/child/webkitplatformsupport_impl.h
+++ b/content/child/webkitplatformsupport_impl.h
@@ -29,9 +29,10 @@ class CONTENT_EXPORT WebKitPlatformSupportImpl
virtual webkit_glue::ResourceLoaderBridge* CreateResourceLoader(
const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info)
OVERRIDE;
- virtual webkit_glue::WebSocketStreamHandleBridge* CreateWebSocketBridge(
+ virtual webkit_glue::WebSocketStreamHandleBridge* CreateWebSocketStreamBridge(
WebKit::WebSocketStreamHandle* handle,
webkit_glue::WebSocketStreamHandleDelegate* delegate) OVERRIDE;
+ virtual WebKit::WebSocketHandle* createWebSocketHandle() OVERRIDE;
};
} // namespace content
diff --git a/content/child/websocket_bridge.cc b/content/child/websocket_bridge.cc
new file mode 100644
index 0000000..e1810dd6
--- /dev/null
+++ b/content/child/websocket_bridge.cc
@@ -0,0 +1,215 @@
+// 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/child/websocket_bridge.h"
+
+#include <stdint.h>
+#include <string>
+#include <vector>
+
+#include "base/logging.h"
+#include "base/strings/string_util.h"
+#include "content/child/child_thread.h"
+#include "content/child/websocket_dispatcher.h"
+#include "content/common/websocket.h"
+#include "content/common/websocket_messages.h"
+#include "ipc/ipc_message.h"
+#include "ipc/ipc_message_macros.h"
+#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/WebString.h"
+#include "third_party/WebKit/public/platform/WebURL.h"
+#include "third_party/WebKit/public/platform/WebVector.h"
+
+using WebKit::WebSocketHandle;
+using WebKit::WebSocketHandleClient;
+using WebKit::WebString;
+using WebKit::WebURL;
+using WebKit::WebVector;
+
+namespace content {
+
+WebSocketBridge::WebSocketBridge()
+ : channel_id_(kInvalidChannelId), client_(NULL) {}
+
+WebSocketBridge::~WebSocketBridge() {
+ Disconnect();
+}
+
+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_SendFrame, DidReceiveData)
+ IPC_MESSAGE_HANDLER(WebSocketMsg_FlowControl, DidReceiveFlowControl)
+ IPC_MESSAGE_HANDLER(WebSocketMsg_DropChannel, DidClose)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void WebSocketBridge::DidConnect(bool fail,
+ const std::string& selected_protocol,
+ const std::string& extensions) {
+ WebSocketHandleClient* client = client_;
+ DVLOG(1) << "WebSocketBridge::DidConnect("
+ << fail << ", "
+ << selected_protocol << ", "
+ << extensions << ")";
+ if (fail)
+ Disconnect();
+ if (!client)
+ return;
+
+ WebString protocol_to_pass = WebString::fromUTF8(selected_protocol);
+ WebString extensions_to_pass = WebString::fromUTF8(extensions);
+ client->didConnect(this, fail, protocol_to_pass, extensions_to_pass);
+ // |this| can be deleted here.
+}
+
+void WebSocketBridge::DidReceiveData(bool fin,
+ WebSocketMessageType type,
+ const std::vector<char>& data) {
+ DVLOG(1) << "WebSocketBridge::DidReceiveData("
+ << fin << ", "
+ << type << ", "
+ << "(data size = " << data.size() << "))";
+ if (!client_)
+ return;
+
+ WebSocketHandle::MessageType type_to_pass =
+ WebSocketHandle::MessageTypeContinuation;
+ switch (type) {
+ case WEB_SOCKET_MESSAGE_TYPE_CONTINUATION:
+ type_to_pass = WebSocketHandle::MessageTypeContinuation;
+ break;
+ case WEB_SOCKET_MESSAGE_TYPE_TEXT:
+ type_to_pass = WebSocketHandle::MessageTypeText;
+ break;
+ case WEB_SOCKET_MESSAGE_TYPE_BINARY:
+ type_to_pass = WebSocketHandle::MessageTypeBinary;
+ break;
+ }
+ const char* data_to_pass = data.empty() ? NULL : &data[0];
+ client_->didReceiveData(this, fin, type_to_pass, data_to_pass, data.size());
+ // |this| can be deleted here.
+}
+
+void WebSocketBridge::DidReceiveFlowControl(int64_t quota) {
+ DVLOG(1) << "WebSocketBridge::DidReceiveFlowControl(" << quota << ")";
+ if (!client_)
+ return;
+
+ client_->didReceiveFlowControl(this, quota);
+ // |this| can be deleted here.
+}
+
+void WebSocketBridge::DidClose(unsigned short code,
+ const std::string& reason) {
+ DVLOG(1) << "WebSocketBridge::DidClose("
+ << code << ", "
+ << reason << ")";
+ WebSocketHandleClient* client = client_;
+ Disconnect();
+ if (!client)
+ return;
+
+ WebString reason_to_pass = WebString::fromUTF8(reason);
+ client->didClose(this, code, reason_to_pass);
+ // |this| can be deleted here.
+}
+
+void WebSocketBridge::connect(
+ const WebURL& url,
+ const WebVector<WebString>& protocols,
+ const WebString& origin,
+ WebSocketHandleClient* client) {
+ DCHECK_EQ(kInvalidChannelId, channel_id_);
+ WebSocketDispatcher* dispatcher =
+ ChildThread::current()->websocket_dispatcher();
+ channel_id_ = dispatcher->AddBridge(this);
+ client_ = client;
+
+ std::vector<std::string> protocols_to_pass;
+ for (size_t i = 0; i < protocols.size(); ++i)
+ protocols_to_pass.push_back(protocols[i].utf8());
+ GURL origin_to_pass(origin.utf8());
+
+ DVLOG(1) << "Bridge#" << channel_id_ << " Connect("
+ << url << ", (" << JoinString(protocols_to_pass, ", ") << "), "
+ << origin_to_pass << ")";
+
+ ChildThread::current()->Send(
+ new WebSocketHostMsg_AddChannelRequest(channel_id_,
+ url,
+ protocols_to_pass,
+ origin_to_pass));
+}
+
+void WebSocketBridge::send(bool fin,
+ WebSocketHandle::MessageType type,
+ const char* data,
+ size_t size) {
+ if (channel_id_ == kInvalidChannelId)
+ return;
+
+ WebSocketMessageType type_to_pass = WEB_SOCKET_MESSAGE_TYPE_CONTINUATION;
+ switch (type) {
+ case WebSocketHandle::MessageTypeContinuation:
+ type_to_pass = WEB_SOCKET_MESSAGE_TYPE_CONTINUATION;
+ break;
+ case WebSocketHandle::MessageTypeText:
+ type_to_pass = WEB_SOCKET_MESSAGE_TYPE_TEXT;
+ break;
+ case WebSocketHandle::MessageTypeBinary:
+ type_to_pass = WEB_SOCKET_MESSAGE_TYPE_BINARY;
+ break;
+ }
+
+ DVLOG(1) << "Bridge #" << channel_id_ << " Send("
+ << fin << ", " << type_to_pass << ", "
+ << "(data size = " << size << "))";
+
+ ChildThread::current()->Send(
+ new WebSocketMsg_SendFrame(channel_id_,
+ fin,
+ type_to_pass,
+ std::vector<char>(data, data + size)));
+}
+
+void WebSocketBridge::flowControl(int64_t quota) {
+ if (channel_id_ == kInvalidChannelId)
+ return;
+
+ DVLOG(1) << "Bridge #" << channel_id_ << " FlowControl(" << quota << ")";
+
+ ChildThread::current()->Send(
+ new WebSocketMsg_FlowControl(channel_id_, quota));
+}
+
+void WebSocketBridge::close(unsigned short code,
+ const WebString& reason) {
+ if (channel_id_ == kInvalidChannelId)
+ return;
+
+ std::string reason_to_pass = reason.utf8();
+ DVLOG(1) << "Bridge #" << channel_id_ << " Close("
+ << code << ", " << reason_to_pass << ")";
+ ChildThread::current()->Send(
+ new WebSocketMsg_DropChannel(channel_id_, code, reason_to_pass));
+}
+
+void WebSocketBridge::Disconnect() {
+ if (channel_id_ == kInvalidChannelId)
+ return;
+ WebSocketDispatcher* dispatcher =
+ ChildThread::current()->websocket_dispatcher();
+ dispatcher->RemoveBridge(channel_id_);
+
+ channel_id_ = kInvalidChannelId;
+ client_ = NULL;
+}
+
+} // namespace content
diff --git a/content/child/websocket_bridge.h b/content/child/websocket_bridge.h
new file mode 100644
index 0000000..4834c40
--- /dev/null
+++ b/content/child/websocket_bridge.h
@@ -0,0 +1,64 @@
+// 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.
+
+#ifndef CONTENT_CHILD_WEBSOCKET_BRIDGE_H_
+#define CONTENT_CHILD_WEBSOCKET_BRIDGE_H_
+
+#include <stdint.h>
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "content/common/websocket.h"
+#include "ipc/ipc_message.h"
+#include "third_party/WebKit/public/platform/WebSocketHandle.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"
+
+namespace content {
+
+class WebSocketBridge : public WebKit::WebSocketHandle {
+ public:
+ WebSocketBridge();
+
+ // Handles an IPC message from the browser process.
+ bool OnMessageReceived(const IPC::Message& message);
+
+ // WebSocketHandle functions.
+ virtual void connect(const WebKit::WebURL& url,
+ const WebKit::WebVector<WebKit::WebString>& protocols,
+ const WebKit::WebString& origin,
+ WebKit::WebSocketHandleClient* client) OVERRIDE;
+ virtual void send(bool fin,
+ WebSocketHandle::MessageType type,
+ const char* data,
+ size_t size) OVERRIDE;
+ virtual void flowControl(int64_t quota) OVERRIDE;
+ virtual void close(unsigned short code,
+ const WebKit::WebString& reason) OVERRIDE;
+
+ virtual void Disconnect();
+
+ private:
+ virtual ~WebSocketBridge();
+
+ void DidConnect(bool fail,
+ const std::string& selected_protocol,
+ const std::string& extensions);
+ void DidReceiveData(bool fin,
+ WebSocketMessageType type,
+ const std::vector<char>& data);
+ void DidReceiveFlowControl(int64_t quota);
+ void DidClose(unsigned short code, const std::string& reason);
+
+ int channel_id_;
+ WebKit::WebSocketHandleClient* client_;
+
+ static const int kInvalidChannelId = -1;
+};
+
+} // namespace content
+
+#endif // CONTENT_CHILD_WEBSOCKET_BRIDGE_H_
diff --git a/content/child/websocket_dispatcher.cc b/content/child/websocket_dispatcher.cc
new file mode 100644
index 0000000..72c3558
--- /dev/null
+++ b/content/child/websocket_dispatcher.cc
@@ -0,0 +1,64 @@
+// 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/child/websocket_dispatcher.h"
+
+#include <stdint.h>
+#include <map>
+
+#include "base/logging.h"
+#include "content/child/websocket_bridge.h"
+#include "content/common/websocket_messages.h"
+#include "ipc/ipc_message.h"
+#include "url/gurl.h"
+
+namespace content {
+
+WebSocketDispatcher::WebSocketDispatcher() : channel_id_max_(0) {}
+
+WebSocketDispatcher::~WebSocketDispatcher() {}
+
+int WebSocketDispatcher::AddBridge(WebSocketBridge* bridge) {
+ ++channel_id_max_;
+ bridges_.insert(std::make_pair(channel_id_max_, bridge));
+ return channel_id_max_;
+}
+
+void WebSocketDispatcher::RemoveBridge(int channel_id) {
+ std::map<int, WebSocketBridge*>::iterator iter = bridges_.find(channel_id);
+ if (iter == bridges_.end()) {
+ DVLOG(1) << "Remove a non-existent bridge(" << channel_id << ")";
+ return;
+ }
+ bridges_.erase(iter);
+}
+
+bool WebSocketDispatcher::OnMessageReceived(const IPC::Message& msg) {
+ switch (msg.type()) {
+ case WebSocketMsg_AddChannelResponse::ID:
+ case WebSocketMsg_SendFrame::ID:
+ case WebSocketMsg_FlowControl::ID:
+ case WebSocketMsg_DropChannel::ID:
+ break;
+ default:
+ return false;
+ }
+
+ WebSocketBridge* bridge = GetBridge(msg.routing_id(), msg.type());
+ if (!bridge)
+ return true;
+ return bridge->OnMessageReceived(msg);
+}
+
+WebSocketBridge* WebSocketDispatcher::GetBridge(int channel_id, uint32 type) {
+ std::map<int, WebSocketBridge*>::iterator iter = bridges_.find(channel_id);
+ if (iter == bridges_.end()) {
+ DVLOG(1) << "No bridge for channel_id=" << channel_id
+ << ", type=" << type;
+ return NULL;
+ }
+ return iter->second;
+}
+
+} // namespace content
diff --git a/content/child/websocket_dispatcher.h b/content/child/websocket_dispatcher.h
new file mode 100644
index 0000000..5356c3b
--- /dev/null
+++ b/content/child/websocket_dispatcher.h
@@ -0,0 +1,48 @@
+// 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.
+
+#ifndef CONTENT_CHILD_WEBSOCKET_DISPATCHER_H_
+#define CONTENT_CHILD_WEBSOCKET_DISPATCHER_H_
+
+#include <stdint.h>
+#include <map>
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ipc/ipc_listener.h"
+
+namespace content {
+
+class WebSocketBridge;
+
+// Dispatches WebSocket related messages sent to a child process from the
+// main browser process. There is one instance per child process. Messages
+// are dispatched on the main child thread. The ChildThread class
+// creates an instance of WebSocketDispatcher and delegates calls to it.
+class WebSocketDispatcher : public IPC::Listener {
+ public:
+ WebSocketDispatcher();
+ virtual ~WebSocketDispatcher();
+
+ // Returns a unique channel id
+ int AddBridge(WebSocketBridge* bridge);
+ void RemoveBridge(int channel_id);
+
+ // IPC::Listener implementation.
+ virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
+
+ private:
+ WebSocketBridge* GetBridge(int channel_id, uint32 type);
+
+ std::map<int, WebSocketBridge*> bridges_;
+ int channel_id_max_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebSocketDispatcher);
+};
+
+} // namespace content
+
+#endif // CONTENT_CHILD_WEBSOCKET_DISPATCHER_H_
diff --git a/content/common/websocket_messages.h b/content/common/websocket_messages.h
index a3dd68c..5a9304f 100644
--- a/content/common/websocket_messages.h
+++ b/content/common/websocket_messages.h
@@ -38,11 +38,10 @@
// The browser process will not send |channel_id| as-is to the remote server; it
// will try to use a short id on the wire. This saves the renderer from
// having to try to choose the ids cleverly.
-IPC_MESSAGE_CONTROL4(WebSocketHostMsg_AddChannelRequest,
- int /* channel_id */,
- GURL /* socket_url */,
- std::vector<std::string> /* requested_protocols */,
- GURL /* origin */)
+IPC_MESSAGE_ROUTED3(WebSocketHostMsg_AddChannelRequest,
+ GURL /* socket_url */,
+ std::vector<std::string> /* requested_protocols */,
+ GURL /* origin */)
// Web Socket messages sent from the browser to the renderer.
@@ -55,11 +54,10 @@ IPC_MESSAGE_CONTROL4(WebSocketHostMsg_AddChannelRequest,
// re-use. |selected_protocol| is the sub-protocol the server selected,
// or empty if no sub-protocol was selected. |extensions| is the list of
// extensions negotiated for the connection.
-IPC_MESSAGE_CONTROL4(WebSocketMsg_AddChannelResponse,
- int /* channel_id */,
- bool /* fail */,
- std::string /* selected_protocol */,
- std::string /* extensions */)
+IPC_MESSAGE_ROUTED3(WebSocketMsg_AddChannelResponse,
+ bool /* fail */,
+ std::string /* selected_protocol */,
+ std::string /* extensions */)
// WebSocket messages that can be sent in either direction.
@@ -75,11 +73,10 @@ IPC_ENUM_TRAITS(content::WebSocketMessageType)
// first message. If |type| is WEB_SOCKET_MESSAGE_TYPE_TEXT, then the
// concatenation of the |data| from every frame in the message must be valid
// UTF-8. If |fin| is not set, |data| must be non-empty.
-IPC_MESSAGE_CONTROL4(WebSocketMsg_SendFrame,
- int /* channel_id */,
- bool /* fin */,
- content::WebSocketMessageType /* type */,
- std::vector<char> /* data */)
+IPC_MESSAGE_ROUTED3(WebSocketMsg_SendFrame,
+ bool /* fin */,
+ content::WebSocketMessageType /* type */,
+ std::vector<char> /* data */)
// Add |quota| tokens of send quota for channel |channel_id|. |quota| must be a
// positive integer. Both the browser and the renderer set send quota for the
@@ -87,9 +84,8 @@ IPC_MESSAGE_CONTROL4(WebSocketMsg_SendFrame,
// messages. Both sides start a new channel with a quota of 0, and must wait for
// a FlowControl message before calling SendFrame. The total available quota on
// one side must never exceed 0x7FFFFFFFFFFFFFFF tokens.
-IPC_MESSAGE_CONTROL2(WebSocketMsg_FlowControl,
- int /* channel_id */,
- int64 /* quota */)
+IPC_MESSAGE_ROUTED1(WebSocketMsg_FlowControl,
+ int64 /* quota */)
// Drop the channel.
// When sent by the renderer, this will cause a DropChannel message to be sent
@@ -104,7 +100,6 @@ IPC_MESSAGE_CONTROL2(WebSocketMsg_FlowControl,
// UTF-8 encoded string which may be useful for debugging but is not necessarily
// human-readable, as supplied by the server in the Close or DropChannel
// message.
-IPC_MESSAGE_CONTROL3(WebSocketMsg_DropChannel,
- int /* channel_id */,
- unsigned short /* code */,
- std::string /* reason */)
+IPC_MESSAGE_ROUTED2(WebSocketMsg_DropChannel,
+ unsigned short /* code */,
+ std::string /* reason */)
diff --git a/content/content_child.gypi b/content/content_child.gypi
index 6ae4731..14c1a31 100644
--- a/content/content_child.gypi
+++ b/content/content_child.gypi
@@ -137,6 +137,10 @@
'child/webkitplatformsupport_impl.h',
'child/webmessageportchannel_impl.cc',
'child/webmessageportchannel_impl.h',
+ 'child/websocket_bridge.cc',
+ 'child/websocket_bridge.h',
+ 'child/websocket_dispatcher.cc',
+ 'child/websocket_dispatcher.h',
'public/child/image_decoder_utils.h',
'public/child/resource_dispatcher_delegate.h',
],
diff --git a/content/test/test_webkit_platform_support.cc b/content/test/test_webkit_platform_support.cc
index 9ad1e2e..5bc6b71 100644
--- a/content/test/test_webkit_platform_support.cc
+++ b/content/test/test_webkit_platform_support.cc
@@ -235,7 +235,7 @@ TestWebKitPlatformSupport::CreateResourceLoader(
}
webkit_glue::WebSocketStreamHandleBridge*
-TestWebKitPlatformSupport::CreateWebSocketBridge(
+TestWebKitPlatformSupport::CreateWebSocketStreamBridge(
WebKit::WebSocketStreamHandle* handle,
webkit_glue::WebSocketStreamHandleDelegate* delegate) {
NOTREACHED();
diff --git a/content/test/test_webkit_platform_support.h b/content/test/test_webkit_platform_support.h
index 7c02705..055dd3f 100644
--- a/content/test/test_webkit_platform_support.h
+++ b/content/test/test_webkit_platform_support.h
@@ -67,7 +67,7 @@ class TestWebKitPlatformSupport :
virtual webkit_glue::ResourceLoaderBridge* CreateResourceLoader(
const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info)
OVERRIDE;
- virtual webkit_glue::WebSocketStreamHandleBridge* CreateWebSocketBridge(
+ virtual webkit_glue::WebSocketStreamHandleBridge* CreateWebSocketStreamBridge(
WebKit::WebSocketStreamHandle* handle,
webkit_glue::WebSocketStreamHandleDelegate* delegate) OVERRIDE;
diff --git a/webkit/child/webkitplatformsupport_impl.h b/webkit/child/webkitplatformsupport_impl.h
index b9ed7e8..1c6579c2 100644
--- a/webkit/child/webkitplatformsupport_impl.h
+++ b/webkit/child/webkitplatformsupport_impl.h
@@ -122,7 +122,7 @@ class WEBKIT_CHILD_EXPORT WebKitPlatformSupportImpl :
virtual ResourceLoaderBridge* CreateResourceLoader(
const ResourceLoaderBridge::RequestInfo& request_info) = 0;
// Creates a WebSocketStreamHandleBridge.
- virtual WebSocketStreamHandleBridge* CreateWebSocketBridge(
+ virtual WebSocketStreamHandleBridge* CreateWebSocketStreamBridge(
WebKit::WebSocketStreamHandle* handle,
WebSocketStreamHandleDelegate* delegate) = 0;
diff --git a/webkit/child/websocketstreamhandle_impl.cc b/webkit/child/websocketstreamhandle_impl.cc
index fe46b8f..3359fc0 100644
--- a/webkit/child/websocketstreamhandle_impl.cc
+++ b/webkit/child/websocketstreamhandle_impl.cc
@@ -86,7 +86,7 @@ void WebSocketStreamHandleImpl::Context::Connect(
WebKitPlatformSupportImpl* platform) {
VLOG(1) << "Connect url=" << url;
DCHECK(!bridge_.get());
- bridge_ = platform->CreateWebSocketBridge(handle_, this);
+ bridge_ = platform->CreateWebSocketStreamBridge(handle_, this);
AddRef(); // Will be released by DidClose().
bridge_->Connect(url);
}
diff --git a/webkit/glue/webkit_glue_unittest.cc b/webkit/glue/webkit_glue_unittest.cc
index 678d916..936c9c5 100644
--- a/webkit/glue/webkit_glue_unittest.cc
+++ b/webkit/glue/webkit_glue_unittest.cc
@@ -34,7 +34,7 @@ class TestWebKitPlatformSupport
return NULL;
}
- virtual webkit_glue::WebSocketStreamHandleBridge* CreateWebSocketBridge(
+ virtual webkit_glue::WebSocketStreamHandleBridge* CreateWebSocketStreamBridge(
WebKit::WebSocketStreamHandle*,
webkit_glue::WebSocketStreamHandleDelegate*) OVERRIDE {
return NULL;