Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1633)

Unified Diff: content/child/websocket_dispatcher.cc

Issue 22815034: Introduce webkit_glue bridges for the new WebSocket Implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/websocket_dispatcher.h ('k') | content/common/websocket_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/websocket_dispatcher.cc
diff --git a/content/child/websocket_dispatcher.cc b/content/child/websocket_dispatcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..332b519206b83cdd770ad0d345a4c48c95693e82
--- /dev/null
+++ b/content/child/websocket_dispatcher.cc
@@ -0,0 +1,64 @@
+// Copyright (c) 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
« no previous file with comments | « content/child/websocket_dispatcher.h ('k') | content/common/websocket_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698