| 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 "ppapi/shared_impl/private/tcp_socket_private_impl.h" | 5 #include "ppapi/shared_impl/private/tcp_socket_private_impl.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 } | 257 } |
| 258 | 258 |
| 259 if (succeeded) { | 259 if (succeeded) { |
| 260 connection_state_ = SSL_CONNECTED; | 260 connection_state_ = SSL_CONNECTED; |
| 261 server_certificate_ = new PPB_X509Certificate_Private_Shared( | 261 server_certificate_ = new PPB_X509Certificate_Private_Shared( |
| 262 resource_type_, | 262 resource_type_, |
| 263 pp_instance(), | 263 pp_instance(), |
| 264 certificate_fields); | 264 certificate_fields); |
| 265 TrackedCallback::ClearAndRun(&ssl_handshake_callback_, PP_OK); | 265 TrackedCallback::ClearAndRun(&ssl_handshake_callback_, PP_OK); |
| 266 } else { | 266 } else { |
| 267 // The resource might be released in the callback so we need to hold |
| 268 // a reference so we can Disconnect() first. |
| 269 AddRef(); |
| 267 TrackedCallback::ClearAndRun(&ssl_handshake_callback_, PP_ERROR_FAILED); | 270 TrackedCallback::ClearAndRun(&ssl_handshake_callback_, PP_ERROR_FAILED); |
| 268 Disconnect(); | 271 Disconnect(); |
| 272 Release(); |
| 269 } | 273 } |
| 270 } | 274 } |
| 271 | 275 |
| 272 void TCPSocketPrivateImpl::OnReadCompleted(bool succeeded, | 276 void TCPSocketPrivateImpl::OnReadCompleted(bool succeeded, |
| 273 const std::string& data) { | 277 const std::string& data) { |
| 274 if (!TrackedCallback::IsPending(read_callback_) || !read_buffer_) { | 278 if (!TrackedCallback::IsPending(read_callback_) || !read_buffer_) { |
| 275 NOTREACHED(); | 279 NOTREACHED(); |
| 276 return; | 280 return; |
| 277 } | 281 } |
| 278 | 282 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 return connection_state_ == CONNECTED || connection_state_ == SSL_CONNECTED; | 326 return connection_state_ == CONNECTED || connection_state_ == SSL_CONNECTED; |
| 323 } | 327 } |
| 324 | 328 |
| 325 void TCPSocketPrivateImpl::PostAbortIfNecessary( | 329 void TCPSocketPrivateImpl::PostAbortIfNecessary( |
| 326 scoped_refptr<TrackedCallback>* callback) { | 330 scoped_refptr<TrackedCallback>* callback) { |
| 327 if (callback->get()) | 331 if (callback->get()) |
| 328 (*callback)->PostAbort(); | 332 (*callback)->PostAbort(); |
| 329 } | 333 } |
| 330 | 334 |
| 331 } // namespace ppapi | 335 } // namespace ppapi |
| OLD | NEW |