Chromium Code Reviews| 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 "chrome/browser/extensions/api/socket/tcp_socket.h" | 5 #include "chrome/browser/extensions/api/socket/tcp_socket.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/api_resource.h" | 7 #include "chrome/browser/extensions/api/api_resource.h" |
| 8 #include "net/base/address_list.h" | 8 #include "net/base/address_list.h" |
| 9 #include "net/base/ip_endpoint.h" | 9 #include "net/base/ip_endpoint.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 DCHECK(!accept_callback_.is_null()); | 299 DCHECK(!accept_callback_.is_null()); |
| 300 if (result == net::OK && accept_socket_.get()) { | 300 if (result == net::OK && accept_socket_.get()) { |
| 301 accept_callback_.Run( | 301 accept_callback_.Run( |
| 302 result, static_cast<net::TCPClientSocket*>(accept_socket_.release())); | 302 result, static_cast<net::TCPClientSocket*>(accept_socket_.release())); |
| 303 } else { | 303 } else { |
| 304 accept_callback_.Run(result, NULL); | 304 accept_callback_.Run(result, NULL); |
| 305 } | 305 } |
| 306 accept_callback_.Reset(); | 306 accept_callback_.Reset(); |
| 307 } | 307 } |
| 308 | 308 |
| 309 void TCPSocket::Release() { | |
| 310 // Release() is only invoked when the underlying sockets are taken (via | |
| 311 // ClientStream()) by TLSSocket. TLSSocket only supports CLIENT-mode | |
| 312 // sockets. | |
| 313 DCHECK(!server_socket_.release() && !accept_socket_.release() && | |
| 314 socket_mode_ == CLIENT) | |
| 315 << "TCPSocket::Release called in server mode."; | |
| 316 | |
| 317 // Release() doesn't disconnect the underlying sockets, but it does | |
| 318 // disconnect them from this TCPSocket. | |
| 319 is_connected_ = false; | |
| 320 | |
| 321 connect_callback_.Reset(); | |
| 322 read_callback_.Reset(); | |
| 323 accept_callback_.Reset(); | |
| 324 | |
| 325 net::TCPClientSocket* client_socket; | |
| 326 client_socket = socket_.release(); | |
|
Ryan Sleevi
2014/03/18 01:05:13
may get a clang warning here (because client_socke
lally
2014/03/26 03:17:51
release() has WARN_UNUSED_RESULT on it, so the bar
Ryan Sleevi
2014/03/26 19:57:40
https://code.google.com/p/chromium/codesearch#chro
lally
2014/03/28 16:22:50
Done.
| |
| 327 DCHECK(client_socket) << "TCPSocket::Release on null client socket."; | |
| 328 } | |
| 329 | |
| 330 net::TCPClientSocket* TCPSocket::ClientStream() { | |
| 331 if (socket_mode_ != CLIENT || GetSocketType() != TYPE_TCP) | |
| 332 return NULL; | |
| 333 return socket_.get(); | |
| 334 } | |
| 335 | |
| 336 bool TCPSocket::HasPendingRead() const { return !read_callback_.is_null(); } | |
| 337 | |
| 309 ResumableTCPSocket::ResumableTCPSocket(const std::string& owner_extension_id) | 338 ResumableTCPSocket::ResumableTCPSocket(const std::string& owner_extension_id) |
| 310 : TCPSocket(owner_extension_id), | 339 : TCPSocket(owner_extension_id), |
| 311 persistent_(false), | 340 persistent_(false), |
| 312 buffer_size_(0), | 341 buffer_size_(0), |
| 313 paused_(false) { | 342 paused_(false) { |
| 314 } | 343 } |
| 315 | 344 |
| 316 ResumableTCPSocket::ResumableTCPSocket(net::TCPClientSocket* tcp_client_socket, | 345 ResumableTCPSocket::ResumableTCPSocket(net::TCPClientSocket* tcp_client_socket, |
| 317 const std::string& owner_extension_id, | 346 const std::string& owner_extension_id, |
| 318 bool is_connected) | 347 bool is_connected) |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 331 : TCPSocket(owner_extension_id), | 360 : TCPSocket(owner_extension_id), |
| 332 persistent_(false), | 361 persistent_(false), |
| 333 paused_(false) { | 362 paused_(false) { |
| 334 } | 363 } |
| 335 | 364 |
| 336 bool ResumableTCPServerSocket::IsPersistent() const { | 365 bool ResumableTCPServerSocket::IsPersistent() const { |
| 337 return persistent(); | 366 return persistent(); |
| 338 } | 367 } |
| 339 | 368 |
| 340 } // namespace extensions | 369 } // namespace extensions |
| OLD | NEW |