| OLD | NEW |
| 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 // An implementation of WebSocketStreamHandle. | 5 // An implementation of WebSocketStreamHandle. |
| 6 | 6 |
| 7 #include "webkit/child/websocketstreamhandle_impl.h" | 7 #include "webkit/child/websocketstreamhandle_impl.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "third_party/WebKit/public/platform/WebData.h" | 16 #include "third_party/WebKit/public/platform/WebData.h" |
| 17 #include "third_party/WebKit/public/platform/WebSocketStreamError.h" | 17 #include "third_party/WebKit/public/platform/WebSocketStreamError.h" |
| 18 #include "third_party/WebKit/public/platform/WebSocketStreamHandleClient.h" | 18 #include "third_party/WebKit/public/platform/WebSocketStreamHandleClient.h" |
| 19 #include "third_party/WebKit/public/platform/WebURL.h" | 19 #include "third_party/WebKit/public/platform/WebURL.h" |
| 20 #include "webkit/child/webkitplatformsupport_impl.h" | 20 #include "webkit/child/webkitplatformsupport_impl.h" |
| 21 #include "webkit/child/websocketstreamhandle_bridge.h" |
| 21 #include "webkit/child/websocketstreamhandle_delegate.h" | 22 #include "webkit/child/websocketstreamhandle_delegate.h" |
| 22 #include "webkit/glue/websocketstreamhandle_bridge.h" | |
| 23 | 23 |
| 24 using WebKit::WebData; | 24 using WebKit::WebData; |
| 25 using WebKit::WebSocketStreamError; | 25 using WebKit::WebSocketStreamError; |
| 26 using WebKit::WebSocketStreamHandle; | 26 using WebKit::WebSocketStreamHandle; |
| 27 using WebKit::WebSocketStreamHandleClient; | 27 using WebKit::WebSocketStreamHandleClient; |
| 28 using WebKit::WebURL; | 28 using WebKit::WebURL; |
| 29 | 29 |
| 30 namespace webkit_glue { | 30 namespace webkit_glue { |
| 31 | 31 |
| 32 // WebSocketStreamHandleImpl::Context ----------------------------------------- | 32 // WebSocketStreamHandleImpl::Context ----------------------------------------- |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 WebSocketStreamHandleClient* client_; | 71 WebSocketStreamHandleClient* client_; |
| 72 // |bridge_| is alive from Connect to DidClose, so Context must be alive | 72 // |bridge_| is alive from Connect to DidClose, so Context must be alive |
| 73 // in the time period. | 73 // in the time period. |
| 74 scoped_refptr<WebSocketStreamHandleBridge> bridge_; | 74 scoped_refptr<WebSocketStreamHandleBridge> bridge_; |
| 75 | 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(Context); | 76 DISALLOW_COPY_AND_ASSIGN(Context); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 WebSocketStreamHandleImpl::Context::Context(WebSocketStreamHandleImpl* handle) | 79 WebSocketStreamHandleImpl::Context::Context(WebSocketStreamHandleImpl* handle) |
| 80 : handle_(handle), | 80 : handle_(handle), |
| 81 client_(NULL), | 81 client_(NULL) { |
| 82 bridge_(NULL) { | |
| 83 } | 82 } |
| 84 | 83 |
| 85 void WebSocketStreamHandleImpl::Context::Connect( | 84 void WebSocketStreamHandleImpl::Context::Connect( |
| 86 const WebURL& url, | 85 const WebURL& url, |
| 87 WebKitPlatformSupportImpl* platform) { | 86 WebKitPlatformSupportImpl* platform) { |
| 88 VLOG(1) << "Connect url=" << url; | 87 VLOG(1) << "Connect url=" << url; |
| 89 DCHECK(!bridge_.get()); | 88 DCHECK(!bridge_.get()); |
| 90 bridge_ = platform->CreateWebSocketBridge(handle_, this); | 89 bridge_ = platform->CreateWebSocketBridge(handle_, this); |
| 91 AddRef(); // Will be released by DidClose(). | 90 AddRef(); // Will be released by DidClose(). |
| 92 bridge_->Connect(url); | 91 bridge_->Connect(url); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 186 |
| 188 bool WebSocketStreamHandleImpl::send(const WebData& data) { | 187 bool WebSocketStreamHandleImpl::send(const WebData& data) { |
| 189 return context_->Send(data); | 188 return context_->Send(data); |
| 190 } | 189 } |
| 191 | 190 |
| 192 void WebSocketStreamHandleImpl::close() { | 191 void WebSocketStreamHandleImpl::close() { |
| 193 context_->Close(); | 192 context_->Close(); |
| 194 } | 193 } |
| 195 | 194 |
| 196 } // namespace webkit_glue | 195 } // namespace webkit_glue |
| OLD | NEW |