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

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: Double. Spaces removed. Created 6 years, 10 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 if (server_socket_.release() || accept_socket_.release()) {
311 VLOG(1) << "TCPSocket::Release getting called in server mode.";
Ryan Sleevi 2014/02/24 20:06:49 Question: Is this a (C++/Chromium) developer error
lally 2014/02/27 17:05:59 Good question. The only call site is within TLSSo
312 return;
313 }
314
315 // Release() doesn't disconnect the underlying sockets, but it does
316 // disconnect them from this TCPSocket.
317 is_connected_ = false;
318
319 connect_callback_.Reset();
320 read_callback_.Reset();
321 accept_callback_.Reset();
322
323 if (socket_.release() == NULL && socket_mode_ == CLIENT) {
324 VLOG(1) << "TCPSocket::Release on null client socket.";
325 }
326 }
327
328 net::TCPClientSocket* TCPSocket::ClientStream() {
329 if (socket_mode_ != CLIENT || GetSocketType() != TYPE_TCP)
330 return NULL;
331 return socket_.get();
332 }
333
309 ResumableTCPSocket::ResumableTCPSocket(const std::string& owner_extension_id) 334 ResumableTCPSocket::ResumableTCPSocket(const std::string& owner_extension_id)
310 : TCPSocket(owner_extension_id), 335 : TCPSocket(owner_extension_id),
311 persistent_(false), 336 persistent_(false),
312 buffer_size_(0), 337 buffer_size_(0),
313 paused_(false) { 338 paused_(false) {
314 } 339 }
315 340
316 ResumableTCPSocket::ResumableTCPSocket(net::TCPClientSocket* tcp_client_socket, 341 ResumableTCPSocket::ResumableTCPSocket(net::TCPClientSocket* tcp_client_socket,
317 const std::string& owner_extension_id, 342 const std::string& owner_extension_id,
318 bool is_connected) 343 bool is_connected)
(...skipping 12 matching lines...) Expand all
331 : TCPSocket(owner_extension_id), 356 : TCPSocket(owner_extension_id),
332 persistent_(false), 357 persistent_(false),
333 paused_(false) { 358 paused_(false) {
334 } 359 }
335 360
336 bool ResumableTCPServerSocket::IsPersistent() const { 361 bool ResumableTCPServerSocket::IsPersistent() const {
337 return persistent(); 362 return persistent();
338 } 363 }
339 364
340 } // namespace extensions 365 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698