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

Unified Diff: chrome/browser/extensions/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: An un-DCHECK-ification, a new test, a test clarification, and a lot of nit-double-spaces. Created 6 years, 9 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
Index: chrome/browser/extensions/api/socket/tcp_socket.cc
diff --git a/chrome/browser/extensions/api/socket/tcp_socket.cc b/chrome/browser/extensions/api/socket/tcp_socket.cc
index 4f9273468ab31690db5401025e197e63b9aa6cb3..c4d1a3d4387367cc35f33b3dcd2bbc53f23a1cad 100644
--- a/chrome/browser/extensions/api/socket/tcp_socket.cc
+++ b/chrome/browser/extensions/api/socket/tcp_socket.cc
@@ -306,6 +306,35 @@ 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)
+ << "TCPSocket::Release 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;
+ 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.
+ DCHECK(client_socket) << "TCPSocket::Release 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),

Powered by Google App Engine
This is Rietveld 408576698