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

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, 2 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 <stdint.h>
8 #include <map>
9
10 #include "base/logging.h"
11 #include "content/child/websocket_bridge.h"
12 #include "content/common/websocket_messages.h"
13 #include "ipc/ipc_message.h"
14 #include "url/gurl.h"
15
16 namespace content {
17
18 WebSocketDispatcher::WebSocketDispatcher() : channel_id_max_(0) {}
19
20 WebSocketDispatcher::~WebSocketDispatcher() {}
21
22 int WebSocketDispatcher::AddBridge(WebSocketBridge* bridge) {
23 ++channel_id_max_;
24 bridges_.insert(std::make_pair(channel_id_max_, bridge));
25 return channel_id_max_;
26 }
27
28 void WebSocketDispatcher::RemoveBridge(int channel_id) {
29 std::map<int, WebSocketBridge*>::iterator iter = bridges_.find(channel_id);
30 if (iter == bridges_.end()) {
31 DVLOG(1) << "Remove a non-existent bridge(" << channel_id << ")";
32 return;
33 }
34 bridges_.erase(iter);
35 }
36
37 bool WebSocketDispatcher::OnMessageReceived(const IPC::Message& msg) {
38 switch (msg.type()) {
39 case WebSocketMsg_AddChannelResponse::ID:
40 case WebSocketMsg_SendFrame::ID:
41 case WebSocketMsg_FlowControl::ID:
42 case WebSocketMsg_DropChannel::ID:
43 break;
44 default:
45 return false;
46 }
47
48 WebSocketBridge* bridge = GetBridge(msg.routing_id(), msg.type());
49 if (!bridge)
50 return true;
51 return bridge->OnMessageReceived(msg);
52 }
53
54 WebSocketBridge* WebSocketDispatcher::GetBridge(int channel_id, uint32 type) {
55 std::map<int, WebSocketBridge*>::iterator iter = bridges_.find(channel_id);
56 if (iter == bridges_.end()) {
57 DVLOG(1) << "No bridge for channel_id=" << channel_id
58 << ", type=" << type;
59 return NULL;
60 }
61 return iter->second;
62 }
63
64 } // 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