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

Side by Side 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: Added a check on whether the socket to be TLS'd has a pending read. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
314 DCHECK(!server_socket_.release() && !accept_socket_.release())
315 << "TCPSocket::Release called in server mode.";
316
317 DCHECK(socket_mode_ == CLIENT);
318
319 // Release() doesn't disconnect the underlying sockets, but it does
320 // disconnect them from this TCPSocket.
321 is_connected_ = false;
322
323 connect_callback_.Reset();
324 read_callback_.Reset();
325 accept_callback_.Reset();
326
327 DCHECK(socket_.release() != NULL)
Ryan Sleevi 2014/03/12 23:35:27 SECURITY BUG: This will not actually release socke
lally 2014/03/17 01:58:06 Yikes. Fixed.
328 << "TCPSocket::Release on null client socket.";
329 }
330
331 net::TCPClientSocket* TCPSocket::ClientStream() {
332 if (socket_mode_ != CLIENT || GetSocketType() != TYPE_TCP)
333 return NULL;
334 return socket_.get();
335 }
336
337 bool TCPSocket::HasPendingRead() const {
338 return !read_callback_.is_null();
339 }
340
309 ResumableTCPSocket::ResumableTCPSocket(const std::string& owner_extension_id) 341 ResumableTCPSocket::ResumableTCPSocket(const std::string& owner_extension_id)
310 : TCPSocket(owner_extension_id), 342 : TCPSocket(owner_extension_id),
311 persistent_(false), 343 persistent_(false),
312 buffer_size_(0), 344 buffer_size_(0),
313 paused_(false) { 345 paused_(false) {
314 } 346 }
315 347
316 ResumableTCPSocket::ResumableTCPSocket(net::TCPClientSocket* tcp_client_socket, 348 ResumableTCPSocket::ResumableTCPSocket(net::TCPClientSocket* tcp_client_socket,
317 const std::string& owner_extension_id, 349 const std::string& owner_extension_id,
318 bool is_connected) 350 bool is_connected)
(...skipping 12 matching lines...) Expand all
331 : TCPSocket(owner_extension_id), 363 : TCPSocket(owner_extension_id),
332 persistent_(false), 364 persistent_(false),
333 paused_(false) { 365 paused_(false) {
334 } 366 }
335 367
336 bool ResumableTCPServerSocket::IsPersistent() const { 368 bool ResumableTCPServerSocket::IsPersistent() const {
337 return persistent(); 369 return persistent();
338 } 370 }
339 371
340 } // namespace extensions 372 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698