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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « content/child/websocket_dispatcher.h ('k') | content/common/websocket_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 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 #include "content/child/websocket_dispatcher.h"
6
7 #include <map>
8
9 #include "base/logging.h"
10 #include "content/child/websocket_bridge.h"
11 #include "content/common/websocket_messages.h"
12 #include "ipc/ipc_message.h"
13 #include "url/gurl.h"
14
15 namespace content {
16
17 WebSocketDispatcher::WebSocketDispatcher() : channel_id_max_(0) {}
18
19 WebSocketDispatcher::~WebSocketDispatcher() {}
20
21 int WebSocketDispatcher::AddBridge(WebSocketBridge* bridge) {
22 ++channel_id_max_;
23 bridges_.insert(std::make_pair(channel_id_max_, bridge));
24 return channel_id_max_;
25 }
26
27 void WebSocketDispatcher::RemoveBridge(int channel_id) {
28 std::map<int, WebSocketBridge*>::iterator i = bridges_.find(channel_id);
Tom Sepez 2013/09/20 16:39:30 nit: pickier reviewers would insist that a longer
yhirano 2013/09/23 20:38:05 Done.
29 if (i == bridges_.end()) {
30 DVLOG(1) << "Remove a non-existent bridge(" << channel_id << ")";
31 return;
32 }
33 bridges_.erase(i);
34 }
35
36 bool WebSocketDispatcher::OnMessageReceived(const IPC::Message& msg) {
37 switch (msg.type()) {
38 case WebSocketMsg_AddChannelResponse::ID:
39 case WebSocketMsg_SendFrame::ID:
40 case WebSocketMsg_FlowControl::ID:
41 case WebSocketMsg_DropChannel::ID:
42 break;
43 default:
44 return false;
45 }
46
47 WebSocketBridge* bridge = GetBridge(msg.routing_id(), msg.type());
48 if (!bridge)
49 return true;
50 return bridge->OnMessageReceived(msg);
51 }
52
53 WebSocketBridge* WebSocketDispatcher::GetBridge(int channel_id, uint32 type) {
54 std::map<int, WebSocketBridge*>::iterator i = bridges_.find(channel_id);
55 if (i == bridges_.end()) {
56 DVLOG(1) << "No bridge for channel_id=" << channel_id
57 << ", type=" << type;
58 return NULL;
59 }
60 return i->second;
61 }
62
63 } // namespace content
OLDNEW
« 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