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 12de56f73683543a344c2ef10ae35b6365fdddd0..321b6312322b9273ca535d48cdfe84f8f57cf4a4 100644 |
--- a/extensions/browser/api/socket/tcp_socket.cc |
+++ b/extensions/browser/api/socket/tcp_socket.cc |
@@ -4,6 +4,8 @@ |
#include "extensions/browser/api/socket/tcp_socket.h" |
+#include "base/logging.h" |
+#include "base/macros.h" |
#include "extensions/browser/api/api_resource.h" |
#include "net/base/address_list.h" |
#include "net/base/ip_endpoint.h" |
@@ -300,6 +302,36 @@ 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(); |
+ |
+ DCHECK(socket_.get()) << "Called on null client socket."; |
+ ignore_result(socket_.release()); |
+} |
+ |
+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), |