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 #include "content/renderer/pepper/pepper_websocket_host.h" | 5 #include "content/renderer/pepper/pepper_websocket_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "content/public/renderer/renderer_ppapi_host.h" | 9 #include "content/public/renderer/renderer_ppapi_host.h" |
10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 unhandled_buffered_amount, was_clean, code, reason.utf8())); | 187 unhandled_buffered_amount, was_clean, code, reason.utf8())); |
188 } else { | 188 } else { |
189 accepting_close_ = false; | 189 accepting_close_ = false; |
190 host()->SendUnsolicitedReply( | 190 host()->SendUnsolicitedReply( |
191 pp_resource(), | 191 pp_resource(), |
192 PpapiPluginMsg_WebSocket_ClosedReply( | 192 PpapiPluginMsg_WebSocket_ClosedReply( |
193 unhandled_buffered_amount, was_clean, code, reason.utf8())); | 193 unhandled_buffered_amount, was_clean, code, reason.utf8())); |
194 } | 194 } |
195 | 195 |
196 // Disconnect. | 196 // Disconnect. |
197 if (websocket_) | 197 if (websocket_) { |
198 websocket_->disconnect(); | 198 websocket_->disconnect(); |
| 199 websocket_.reset(); |
| 200 } |
199 } | 201 } |
200 | 202 |
201 int32_t PepperWebSocketHost::OnHostMsgConnect( | 203 int32_t PepperWebSocketHost::OnHostMsgConnect( |
202 ppapi::host::HostMessageContext* context, | 204 ppapi::host::HostMessageContext* context, |
203 const std::string& url, | 205 const std::string& url, |
204 const std::vector<std::string>& protocols) { | 206 const std::vector<std::string>& protocols) { |
205 // Validate url and convert it to WebURL. | 207 // Validate url and convert it to WebURL. |
206 GURL gurl(url); | 208 GURL gurl(url); |
207 url_ = gurl.spec(); | 209 url_ = gurl.spec(); |
208 if (!gurl.is_valid()) | 210 if (!gurl.is_valid()) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 319 |
318 int32_t PepperWebSocketHost::OnHostMsgFail( | 320 int32_t PepperWebSocketHost::OnHostMsgFail( |
319 ppapi::host::HostMessageContext* context, | 321 ppapi::host::HostMessageContext* context, |
320 const std::string& message) { | 322 const std::string& message) { |
321 if (websocket_) | 323 if (websocket_) |
322 websocket_->fail(WebString::fromUTF8(message)); | 324 websocket_->fail(WebString::fromUTF8(message)); |
323 return PP_OK; | 325 return PP_OK; |
324 } | 326 } |
325 | 327 |
326 } // namespace content | 328 } // namespace content |
OLD | NEW |