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

Side by Side Diff: content/child/socket_stream_dispatcher.cc

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « content/child/socket_stream_dispatcher.h ('k') | content/child/web_database_observer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/socket_stream_dispatcher.h" 5 #include "content/child/socket_stream_dispatcher.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/id_map.h" 10 #include "base/id_map.h"
(...skipping 12 matching lines...) Expand all
23 #include "webkit/child/websocketstreamhandle_delegate.h" 23 #include "webkit/child/websocketstreamhandle_delegate.h"
24 24
25 namespace content { 25 namespace content {
26 26
27 // IPCWebSocketStreamHandleBridge is owned by each SocketStreamHandle. 27 // IPCWebSocketStreamHandleBridge is owned by each SocketStreamHandle.
28 // It communicates with the main browser process via SocketStreamDispatcher. 28 // It communicates with the main browser process via SocketStreamDispatcher.
29 class IPCWebSocketStreamHandleBridge 29 class IPCWebSocketStreamHandleBridge
30 : public webkit_glue::WebSocketStreamHandleBridge { 30 : public webkit_glue::WebSocketStreamHandleBridge {
31 public: 31 public:
32 IPCWebSocketStreamHandleBridge( 32 IPCWebSocketStreamHandleBridge(
33 WebKit::WebSocketStreamHandle* handle, 33 blink::WebSocketStreamHandle* handle,
34 webkit_glue::WebSocketStreamHandleDelegate* delegate) 34 webkit_glue::WebSocketStreamHandleDelegate* delegate)
35 : socket_id_(kNoSocketId), 35 : socket_id_(kNoSocketId),
36 handle_(handle), 36 handle_(handle),
37 delegate_(delegate) {} 37 delegate_(delegate) {}
38 38
39 // Returns the handle having given id or NULL if there is no such handle. 39 // Returns the handle having given id or NULL if there is no such handle.
40 static IPCWebSocketStreamHandleBridge* FromSocketId(int id); 40 static IPCWebSocketStreamHandleBridge* FromSocketId(int id);
41 41
42 // webkit_glue::WebSocketStreamHandleBridge methods. 42 // webkit_glue::WebSocketStreamHandleBridge methods.
43 virtual void Connect(const GURL& url) OVERRIDE; 43 virtual void Connect(const GURL& url) OVERRIDE;
44 virtual bool Send(const std::vector<char>& data) OVERRIDE; 44 virtual bool Send(const std::vector<char>& data) OVERRIDE;
45 virtual void Close() OVERRIDE; 45 virtual void Close() OVERRIDE;
46 46
47 // Called by SocketStreamDispatcher. 47 // Called by SocketStreamDispatcher.
48 void OnConnected(int max_amount_send_allowed); 48 void OnConnected(int max_amount_send_allowed);
49 void OnSentData(int amount_sent); 49 void OnSentData(int amount_sent);
50 void OnReceivedData(const std::vector<char>& data); 50 void OnReceivedData(const std::vector<char>& data);
51 void OnClosed(); 51 void OnClosed();
52 void OnFailed(int error_code, const char* error_msg); 52 void OnFailed(int error_code, const char* error_msg);
53 53
54 private: 54 private:
55 virtual ~IPCWebSocketStreamHandleBridge(); 55 virtual ~IPCWebSocketStreamHandleBridge();
56 56
57 // The ID for this bridge and corresponding SocketStream instance in the 57 // The ID for this bridge and corresponding SocketStream instance in the
58 // browser process. 58 // browser process.
59 int socket_id_; 59 int socket_id_;
60 60
61 WebKit::WebSocketStreamHandle* handle_; 61 blink::WebSocketStreamHandle* handle_;
62 webkit_glue::WebSocketStreamHandleDelegate* delegate_; 62 webkit_glue::WebSocketStreamHandleDelegate* delegate_;
63 63
64 // Map from ID to bridge instance. 64 // Map from ID to bridge instance.
65 static base::LazyInstance<IDMap<IPCWebSocketStreamHandleBridge> >::Leaky 65 static base::LazyInstance<IDMap<IPCWebSocketStreamHandleBridge> >::Leaky
66 all_bridges; 66 all_bridges;
67 }; 67 };
68 68
69 // static 69 // static
70 base::LazyInstance<IDMap<IPCWebSocketStreamHandleBridge> >::Leaky 70 base::LazyInstance<IDMap<IPCWebSocketStreamHandleBridge> >::Leaky
71 IPCWebSocketStreamHandleBridge::all_bridges = LAZY_INSTANCE_INITIALIZER; 71 IPCWebSocketStreamHandleBridge::all_bridges = LAZY_INSTANCE_INITIALIZER;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if (delegate_) 170 if (delegate_)
171 delegate_->DidFail(handle_, error_code, ASCIIToUTF16(error_msg)); 171 delegate_->DidFail(handle_, error_code, ASCIIToUTF16(error_msg));
172 } 172 }
173 173
174 SocketStreamDispatcher::SocketStreamDispatcher() { 174 SocketStreamDispatcher::SocketStreamDispatcher() {
175 } 175 }
176 176
177 /* static */ 177 /* static */
178 webkit_glue::WebSocketStreamHandleBridge* 178 webkit_glue::WebSocketStreamHandleBridge*
179 SocketStreamDispatcher::CreateBridge( 179 SocketStreamDispatcher::CreateBridge(
180 WebKit::WebSocketStreamHandle* handle, 180 blink::WebSocketStreamHandle* handle,
181 webkit_glue::WebSocketStreamHandleDelegate* delegate) { 181 webkit_glue::WebSocketStreamHandleDelegate* delegate) {
182 return new IPCWebSocketStreamHandleBridge(handle, delegate); 182 return new IPCWebSocketStreamHandleBridge(handle, delegate);
183 } 183 }
184 184
185 bool SocketStreamDispatcher::OnMessageReceived(const IPC::Message& msg) { 185 bool SocketStreamDispatcher::OnMessageReceived(const IPC::Message& msg) {
186 bool handled = true; 186 bool handled = true;
187 IPC_BEGIN_MESSAGE_MAP(SocketStreamDispatcher, msg) 187 IPC_BEGIN_MESSAGE_MAP(SocketStreamDispatcher, msg)
188 IPC_MESSAGE_HANDLER(SocketStreamMsg_Connected, OnConnected) 188 IPC_MESSAGE_HANDLER(SocketStreamMsg_Connected, OnConnected)
189 IPC_MESSAGE_HANDLER(SocketStreamMsg_SentData, OnSentData) 189 IPC_MESSAGE_HANDLER(SocketStreamMsg_SentData, OnSentData)
190 IPC_MESSAGE_HANDLER(SocketStreamMsg_ReceivedData, OnReceivedData) 190 IPC_MESSAGE_HANDLER(SocketStreamMsg_ReceivedData, OnReceivedData)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 void SocketStreamDispatcher::OnFailed(int socket_id, int error_code) { 247 void SocketStreamDispatcher::OnFailed(int socket_id, int error_code) {
248 IPCWebSocketStreamHandleBridge* bridge = 248 IPCWebSocketStreamHandleBridge* bridge =
249 IPCWebSocketStreamHandleBridge::FromSocketId(socket_id); 249 IPCWebSocketStreamHandleBridge::FromSocketId(socket_id);
250 if (bridge) 250 if (bridge)
251 bridge->OnFailed(error_code, net::ErrorToString(error_code)); 251 bridge->OnFailed(error_code, net::ErrorToString(error_code));
252 else 252 else
253 DLOG(ERROR) << "No bridge for socket_id=" << socket_id; 253 DLOG(ERROR) << "No bridge for socket_id=" << socket_id;
254 } 254 }
255 255
256 } // namespace content 256 } // namespace content
OLDNEW
« no previous file with comments | « content/child/socket_stream_dispatcher.h ('k') | content/child/web_database_observer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698