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

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: Fixing another cross-platform build issue (try 2) Created 7 years, 1 month 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
310 void TCPSocket::Release() {
311 // Really, the 'server' bool/checks are to get around warn_unused_result on
312 // scoped_ptr.release().
313 bool server = false;
314 is_connected_ = false; // Note: does _not_ disconnect any underlying sockets.
315 server = server_socket_.release() != NULL;
316 connect_callback_.Reset();
317 read_callback_.Reset();
318 accept_callback_.Reset();
319 server = accept_socket_.release() != NULL || server;
Ryan Sleevi 2013/11/25 17:30:13 The whole |server| checks are *really* odd to me.
Lally Singh 2013/12/05 17:07:12 Fair enough. Cleaned up.
320 net::TCPClientSocket* sock = socket_.release();
321 if (server) {
322 VLOG(1) << "TCPSocket::Release getting called in server mode. Odd.";
323 } else if (sock == 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