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

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: Save and Restores Persistent/Paused state when securing. Created 6 years, 11 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
310 void TCPSocket::Release() {
311 if (server_socket_.release() || accept_socket_.release()) {
312 VLOG(1) << "TCPSocket::Release getting called in server mode.";
313 return;
314 }
315
316 // Release() doesn't disconnect the underlying sockets, but it does
317 // disconnect them from this TCPSocket.
318 is_connected_ = false;
319
320 connect_callback_.Reset();
321 read_callback_.Reset();
322 accept_callback_.Reset();
323
324 if (socket_.release() == NULL && socket_mode_ == CLIENT) {
325 VLOG(1) << "TCPSocket::Release on null client socket.";
326 }
327 }
328
329 net::TCPClientSocket* TCPSocket::ClientStream() {
330 if (socket_mode_ != CLIENT || GetSocketType() != TYPE_TCP)
331 return NULL;
332 return socket_.get();
333 }
334
309 ResumableTCPSocket::ResumableTCPSocket(const std::string& owner_extension_id) 335 ResumableTCPSocket::ResumableTCPSocket(const std::string& owner_extension_id)
310 : TCPSocket(owner_extension_id), 336 : TCPSocket(owner_extension_id),
311 persistent_(false), 337 persistent_(false),
312 buffer_size_(0), 338 buffer_size_(0),
313 paused_(false) { 339 paused_(false) {
314 } 340 }
315 341
316 ResumableTCPSocket::ResumableTCPSocket(net::TCPClientSocket* tcp_client_socket, 342 ResumableTCPSocket::ResumableTCPSocket(net::TCPClientSocket* tcp_client_socket,
317 const std::string& owner_extension_id, 343 const std::string& owner_extension_id,
318 bool is_connected) 344 bool is_connected)
(...skipping 12 matching lines...) Expand all
331 : TCPSocket(owner_extension_id), 357 : TCPSocket(owner_extension_id),
332 persistent_(false), 358 persistent_(false),
333 paused_(false) { 359 paused_(false) {
334 } 360 }
335 361
336 bool ResumableTCPServerSocket::IsPersistent() const { 362 bool ResumableTCPServerSocket::IsPersistent() const {
337 return persistent(); 363 return persistent();
338 } 364 }
339 365
340 } // namespace extensions 366 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698