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/glue/websocketstreamhandle_impl.h" | 7 #include "webkit/glue/websocketstreamhandle_impl.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 client_->didFail( | 158 client_->didFail( |
159 handle_, | 159 handle_, |
160 WebSocketStreamError(error_code, error_msg)); | 160 WebSocketStreamError(error_code, error_msg)); |
161 } | 161 } |
162 } | 162 } |
163 | 163 |
164 // WebSocketStreamHandleImpl ------------------------------------------------ | 164 // WebSocketStreamHandleImpl ------------------------------------------------ |
165 | 165 |
166 WebSocketStreamHandleImpl::WebSocketStreamHandleImpl( | 166 WebSocketStreamHandleImpl::WebSocketStreamHandleImpl( |
167 WebKitPlatformSupportImpl* platform) | 167 WebKitPlatformSupportImpl* platform) |
168 : ALLOW_THIS_IN_INITIALIZER_LIST(context_(new Context(this))), | 168 : context_(new Context(this)), |
169 platform_(platform) { | 169 platform_(platform) { |
170 } | 170 } |
171 | 171 |
172 WebSocketStreamHandleImpl::~WebSocketStreamHandleImpl() { | 172 WebSocketStreamHandleImpl::~WebSocketStreamHandleImpl() { |
173 // We won't receive any events from |context_|. | 173 // We won't receive any events from |context_|. |
174 // |context_| is ref counted, and will be released when it received | 174 // |context_| is ref counted, and will be released when it received |
175 // DidClose. | 175 // DidClose. |
176 context_->Detach(); | 176 context_->Detach(); |
177 } | 177 } |
178 | 178 |
179 void WebSocketStreamHandleImpl::connect( | 179 void WebSocketStreamHandleImpl::connect( |
180 const WebURL& url, WebSocketStreamHandleClient* client) { | 180 const WebURL& url, WebSocketStreamHandleClient* client) { |
181 VLOG(1) << "connect url=" << url; | 181 VLOG(1) << "connect url=" << url; |
182 DCHECK(!context_->client()); | 182 DCHECK(!context_->client()); |
183 context_->set_client(client); | 183 context_->set_client(client); |
184 | 184 |
185 context_->Connect(url, platform_); | 185 context_->Connect(url, platform_); |
186 } | 186 } |
187 | 187 |
188 bool WebSocketStreamHandleImpl::send(const WebData& data) { | 188 bool WebSocketStreamHandleImpl::send(const WebData& data) { |
189 return context_->Send(data); | 189 return context_->Send(data); |
190 } | 190 } |
191 | 191 |
192 void WebSocketStreamHandleImpl::close() { | 192 void WebSocketStreamHandleImpl::close() { |
193 context_->Close(); | 193 context_->Close(); |
194 } | 194 } |
195 | 195 |
196 } // namespace webkit_glue | 196 } // namespace webkit_glue |
OLD | NEW |