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

Side by Side Diff: extensions/browser/api/sockets_tcp/sockets_tcp_api.cc

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/sockets_tcp/sockets_tcp_api.h" 5 #include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h"
6 6
7 #include "content/public/browser/browser_context.h" 7 #include "content/public/browser/browser_context.h"
8 #include "content/public/browser/storage_partition.h" 8 #include "content/public/browser/storage_partition.h"
9 #include "content/public/common/socket_permission_request.h" 9 #include "content/public/common/socket_permission_request.h"
10 #include "extensions/browser/api/socket/tcp_socket.h" 10 #include "extensions/browser/api/socket/tcp_socket.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 } // namespace 82 } // namespace
83 83
84 namespace extensions { 84 namespace extensions {
85 namespace api { 85 namespace api {
86 86
87 using content::SocketPermissionRequest; 87 using content::SocketPermissionRequest;
88 88
89 TCPSocketAsyncApiFunction::~TCPSocketAsyncApiFunction() {} 89 TCPSocketAsyncApiFunction::~TCPSocketAsyncApiFunction() {}
90 90
91 scoped_ptr<SocketResourceManagerInterface> 91 std::unique_ptr<SocketResourceManagerInterface>
92 TCPSocketAsyncApiFunction::CreateSocketResourceManager() { 92 TCPSocketAsyncApiFunction::CreateSocketResourceManager() {
93 return scoped_ptr<SocketResourceManagerInterface>( 93 return std::unique_ptr<SocketResourceManagerInterface>(
94 new SocketResourceManager<ResumableTCPSocket>()); 94 new SocketResourceManager<ResumableTCPSocket>());
95 } 95 }
96 96
97 ResumableTCPSocket* TCPSocketAsyncApiFunction::GetTcpSocket(int socket_id) { 97 ResumableTCPSocket* TCPSocketAsyncApiFunction::GetTcpSocket(int socket_id) {
98 return static_cast<ResumableTCPSocket*>(GetSocket(socket_id)); 98 return static_cast<ResumableTCPSocket*>(GetSocket(socket_id));
99 } 99 }
100 100
101 TCPSocketExtensionWithDnsLookupFunction:: 101 TCPSocketExtensionWithDnsLookupFunction::
102 ~TCPSocketExtensionWithDnsLookupFunction() {} 102 ~TCPSocketExtensionWithDnsLookupFunction() {}
103 103
104 scoped_ptr<SocketResourceManagerInterface> 104 std::unique_ptr<SocketResourceManagerInterface>
105 TCPSocketExtensionWithDnsLookupFunction::CreateSocketResourceManager() { 105 TCPSocketExtensionWithDnsLookupFunction::CreateSocketResourceManager() {
106 return scoped_ptr<SocketResourceManagerInterface>( 106 return std::unique_ptr<SocketResourceManagerInterface>(
107 new SocketResourceManager<ResumableTCPSocket>()); 107 new SocketResourceManager<ResumableTCPSocket>());
108 } 108 }
109 109
110 ResumableTCPSocket* TCPSocketExtensionWithDnsLookupFunction::GetTcpSocket( 110 ResumableTCPSocket* TCPSocketExtensionWithDnsLookupFunction::GetTcpSocket(
111 int socket_id) { 111 int socket_id) {
112 return static_cast<ResumableTCPSocket*>(GetSocket(socket_id)); 112 return static_cast<ResumableTCPSocket*>(GetSocket(socket_id));
113 } 113 }
114 114
115 SocketsTcpCreateFunction::SocketsTcpCreateFunction() {} 115 SocketsTcpCreateFunction::SocketsTcpCreateFunction() {}
116 116
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 TLSSocket::UpgradeSocketToTLS( 515 TLSSocket::UpgradeSocketToTLS(
516 socket, 516 socket,
517 url_request_context->ssl_config_service(), 517 url_request_context->ssl_config_service(),
518 url_request_context->cert_verifier(), 518 url_request_context->cert_verifier(),
519 url_request_context->transport_security_state(), 519 url_request_context->transport_security_state(),
520 extension_id(), 520 extension_id(),
521 &legacy_params, 521 &legacy_params,
522 base::Bind(&SocketsTcpSecureFunction::TlsConnectDone, this)); 522 base::Bind(&SocketsTcpSecureFunction::TlsConnectDone, this));
523 } 523 }
524 524
525 void SocketsTcpSecureFunction::TlsConnectDone(scoped_ptr<TLSSocket> socket, 525 void SocketsTcpSecureFunction::TlsConnectDone(std::unique_ptr<TLSSocket> socket,
526 int result) { 526 int result) {
527 // If an error occurred, socket MUST be NULL 527 // If an error occurred, socket MUST be NULL
528 DCHECK(result == net::OK || socket == NULL); 528 DCHECK(result == net::OK || socket == NULL);
529 529
530 if (socket && result == net::OK) { 530 if (socket && result == net::OK) {
531 socket->set_persistent(persistent_); 531 socket->set_persistent(persistent_);
532 socket->set_paused(paused_); 532 socket->set_paused(paused_);
533 ReplaceSocket(params_->socket_id, socket.release()); 533 ReplaceSocket(params_->socket_id, socket.release());
534 } else { 534 } else {
535 RemoveSocket(params_->socket_id); 535 RemoveSocket(params_->socket_id);
536 error_ = net::ErrorToString(result); 536 error_ = net::ErrorToString(result);
537 } 537 }
538 538
539 results_ = api::sockets_tcp::Secure::Results::Create(result); 539 results_ = api::sockets_tcp::Secure::Results::Create(result);
540 AsyncWorkCompleted(); 540 AsyncWorkCompleted();
541 } 541 }
542 542
543 } // namespace api 543 } // namespace api
544 } // namespace extensions 544 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/sockets_tcp/sockets_tcp_api.h ('k') | extensions/browser/api/sockets_tcp/sockets_tcp_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698