OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "webkit/tools/test_shell/simple_socket_stream_bridge.h" | 7 #include "webkit/tools/test_shell/simple_socket_stream_bridge.h" |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
12 #include "net/socket_stream/socket_stream_job.h" | 12 #include "net/socket_stream/socket_stream_job.h" |
13 #include "net/websockets/websocket_job.h" | 13 #include "net/websockets/websocket_job.h" |
14 #include "net/url_request/url_request_context.h" | 14 #include "net/url_request/url_request_context.h" |
15 #include "third_party/WebKit/WebKit/chromium/public/WebSocketStreamHandle.h" | 15 #include "third_party/WebKit/WebKit/chromium/public/WebSocketStreamHandle.h" |
16 #include "webkit/glue/websocketstreamhandle_bridge.h" | 16 #include "webkit/glue/websocketstreamhandle_bridge.h" |
17 #include "webkit/glue/websocketstreamhandle_delegate.h" | 17 #include "webkit/glue/websocketstreamhandle_delegate.h" |
18 | 18 |
19 using webkit_glue::WebSocketStreamHandleBridge; | 19 using webkit_glue::WebSocketStreamHandleBridge; |
20 | 20 |
21 static const int kNoSocketId = 0; | 21 static const int kNoSocketId = 0; |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 MessageLoop* g_io_thread; | 25 MessageLoop* g_io_thread; |
26 scoped_refptr<URLRequestContext> g_request_context; | 26 scoped_refptr<net::URLRequestContext> g_request_context; |
27 | 27 |
28 class WebSocketStreamHandleBridgeImpl | 28 class WebSocketStreamHandleBridgeImpl |
29 : public WebSocketStreamHandleBridge, | 29 : public WebSocketStreamHandleBridge, |
30 public net::SocketStream::Delegate { | 30 public net::SocketStream::Delegate { |
31 public: | 31 public: |
32 WebSocketStreamHandleBridgeImpl( | 32 WebSocketStreamHandleBridgeImpl( |
33 WebKit::WebSocketStreamHandle* handle, | 33 WebKit::WebSocketStreamHandle* handle, |
34 webkit_glue::WebSocketStreamHandleDelegate* delegate); | 34 webkit_glue::WebSocketStreamHandleDelegate* delegate); |
35 | 35 |
36 // WebSocketStreamHandleBridge methods. | 36 // WebSocketStreamHandleBridge methods. |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 delegate_ = NULL; | 212 delegate_ = NULL; |
213 if (delegate) | 213 if (delegate) |
214 delegate->DidClose(handle_); | 214 delegate->DidClose(handle_); |
215 Release(); | 215 Release(); |
216 } | 216 } |
217 | 217 |
218 } // namespace | 218 } // namespace |
219 | 219 |
220 /* static */ | 220 /* static */ |
221 void SimpleSocketStreamBridge::InitializeOnIOThread( | 221 void SimpleSocketStreamBridge::InitializeOnIOThread( |
222 URLRequestContext* request_context) { | 222 net::URLRequestContext* request_context) { |
223 g_io_thread = MessageLoop::current(); | 223 g_io_thread = MessageLoop::current(); |
224 g_request_context = request_context; | 224 g_request_context = request_context; |
225 } | 225 } |
226 | 226 |
227 void SimpleSocketStreamBridge::Cleanup() { | 227 void SimpleSocketStreamBridge::Cleanup() { |
228 g_io_thread = NULL; | 228 g_io_thread = NULL; |
229 g_request_context = NULL; | 229 g_request_context = NULL; |
230 } | 230 } |
231 | 231 |
232 namespace webkit_glue { | 232 namespace webkit_glue { |
233 | 233 |
234 /* static */ | 234 /* static */ |
235 WebSocketStreamHandleBridge* WebSocketStreamHandleBridge::Create( | 235 WebSocketStreamHandleBridge* WebSocketStreamHandleBridge::Create( |
236 WebKit::WebSocketStreamHandle* handle, | 236 WebKit::WebSocketStreamHandle* handle, |
237 WebSocketStreamHandleDelegate* delegate) { | 237 WebSocketStreamHandleDelegate* delegate) { |
238 return new WebSocketStreamHandleBridgeImpl(handle, delegate); | 238 return new WebSocketStreamHandleBridgeImpl(handle, delegate); |
239 } | 239 } |
240 | 240 |
241 } // namespace webkit_glue | 241 } // namespace webkit_glue |
OLD | NEW |