| Index: extensions/browser/api/socket/tcp_socket.cc
|
| diff --git a/extensions/browser/api/socket/tcp_socket.cc b/extensions/browser/api/socket/tcp_socket.cc
|
| index 49f17dcf418d2324b13527353ab0d2eee2f9ec4c..826646bc10f78fb299169e558bd0535104475e92 100644
|
| --- a/extensions/browser/api/socket/tcp_socket.cc
|
| +++ b/extensions/browser/api/socket/tcp_socket.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "extensions/browser/api/socket/tcp_socket.h"
|
|
|
| +#include "base/logging.h"
|
| #include "extensions/browser/api/api_resource.h"
|
| #include "net/base/address_list.h"
|
| #include "net/base/ip_endpoint.h"
|
| @@ -304,6 +305,34 @@ void TCPSocket::OnAccept(int result) {
|
| accept_callback_.Reset();
|
| }
|
|
|
| +void TCPSocket::Release() {
|
| + // Release() is only invoked when the underlying sockets are taken (via
|
| + // ClientStream()) by TLSSocket. TLSSocket only supports CLIENT-mode
|
| + // sockets.
|
| + DCHECK(!server_socket_.release() && !accept_socket_.release() &&
|
| + socket_mode_ == CLIENT)
|
| + << "Called in server mode.";
|
| +
|
| + // Release() doesn't disconnect the underlying sockets, but it does
|
| + // disconnect them from this TCPSocket.
|
| + is_connected_ = false;
|
| +
|
| + connect_callback_.Reset();
|
| + read_callback_.Reset();
|
| + accept_callback_.Reset();
|
| +
|
| + net::TCPClientSocket* client_socket = socket_.release();
|
| + DCHECK(client_socket) << "Called on null client socket.";
|
| +}
|
| +
|
| +net::TCPClientSocket* TCPSocket::ClientStream() {
|
| + if (socket_mode_ != CLIENT || GetSocketType() != TYPE_TCP)
|
| + return NULL;
|
| + return socket_.get();
|
| +}
|
| +
|
| +bool TCPSocket::HasPendingRead() const { return !read_callback_.is_null(); }
|
| +
|
| ResumableTCPSocket::ResumableTCPSocket(const std::string& owner_extension_id)
|
| : TCPSocket(owner_extension_id),
|
| persistent_(false),
|
|
|