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

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

Issue 2116983002: Change HostResolver::Resolve() to take an std::unique_ptr<Request>* rather than a RequestHandle* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "content/public/browser/browser_context.h" 8 #include "content/public/browser/browser_context.h"
9 #include "content/public/browser/storage_partition.h" 9 #include "content/public/browser/storage_partition.h"
10 #include "content/public/common/socket_permission_request.h" 10 #include "content/public/common/socket_permission_request.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 282
283 StartDnsLookup(net::HostPortPair(params_->peer_address, params_->peer_port)); 283 StartDnsLookup(net::HostPortPair(params_->peer_address, params_->peer_port));
284 } 284 }
285 285
286 void SocketsTcpConnectFunction::AfterDnsLookup(int lookup_result) { 286 void SocketsTcpConnectFunction::AfterDnsLookup(int lookup_result) {
287 if (lookup_result == net::OK) { 287 if (lookup_result == net::OK) {
288 StartConnect(); 288 StartConnect();
289 } else { 289 } else {
290 OnCompleted(lookup_result); 290 OnCompleted(lookup_result);
291 } 291 }
292
293 // TODO(maksims): investigate why std::unique_ptr<HostResolver::Request>'s
294 // destructor is not called automatically.
295 request_handle_.reset();
292 } 296 }
293 297
294 void SocketsTcpConnectFunction::StartConnect() { 298 void SocketsTcpConnectFunction::StartConnect() {
295 ResumableTCPSocket* socket = GetTcpSocket(params_->socket_id); 299 ResumableTCPSocket* socket = GetTcpSocket(params_->socket_id);
296 if (!socket) { 300 if (!socket) {
297 error_ = kSocketNotFoundError; 301 error_ = kSocketNotFoundError;
298 AsyncWorkCompleted(); 302 AsyncWorkCompleted();
299 return; 303 return;
300 } 304 }
301 305
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 RemoveSocket(params_->socket_id); 542 RemoveSocket(params_->socket_id);
539 error_ = net::ErrorToString(result); 543 error_ = net::ErrorToString(result);
540 } 544 }
541 545
542 results_ = api::sockets_tcp::Secure::Results::Create(result); 546 results_ = api::sockets_tcp::Secure::Results::Create(result);
543 AsyncWorkCompleted(); 547 AsyncWorkCompleted();
544 } 548 }
545 549
546 } // namespace api 550 } // namespace api
547 } // namespace extensions 551 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698