Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: extensions/browser/api/socket/tcp_socket.cc

Issue 76403004: An implementation of chrome.socket.secure(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Morning LKGR Rebase. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/browser/api/socket/tcp_socket.h ('k') | extensions/browser/api/socket/tls_socket.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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),
« no previous file with comments | « extensions/browser/api/socket/tcp_socket.h ('k') | extensions/browser/api/socket/tls_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698