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

Side by Side Diff: extensions/browser/api/dns/dns_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
« no previous file with comments | « extensions/browser/api/dns/dns_api.h ('k') | extensions/browser/api/dns/dns_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/dns/dns_api.h" 5 #include "extensions/browser/api/dns/dns_api.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "content/public/browser/browser_context.h" 9 #include "content/public/browser/browser_context.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 13 matching lines...) Expand all
24 24
25 DnsResolveFunction::DnsResolveFunction() 25 DnsResolveFunction::DnsResolveFunction()
26 : resource_context_(NULL), 26 : resource_context_(NULL),
27 response_(false), 27 response_(false),
28 request_handle_(new net::HostResolver::RequestHandle()), 28 request_handle_(new net::HostResolver::RequestHandle()),
29 addresses_(new net::AddressList) {} 29 addresses_(new net::AddressList) {}
30 30
31 DnsResolveFunction::~DnsResolveFunction() {} 31 DnsResolveFunction::~DnsResolveFunction() {}
32 32
33 bool DnsResolveFunction::RunAsync() { 33 bool DnsResolveFunction::RunAsync() {
34 scoped_ptr<Resolve::Params> params(Resolve::Params::Create(*args_)); 34 std::unique_ptr<Resolve::Params> params(Resolve::Params::Create(*args_));
35 EXTENSION_FUNCTION_VALIDATE(params.get()); 35 EXTENSION_FUNCTION_VALIDATE(params.get());
36 36
37 hostname_ = params->hostname; 37 hostname_ = params->hostname;
38 resource_context_ = browser_context()->GetResourceContext(); 38 resource_context_ = browser_context()->GetResourceContext();
39 39
40 bool result = BrowserThread::PostTask( 40 bool result = BrowserThread::PostTask(
41 BrowserThread::IO, 41 BrowserThread::IO,
42 FROM_HERE, 42 FROM_HERE,
43 base::Bind(&DnsResolveFunction::WorkOnIOThread, this)); 43 base::Bind(&DnsResolveFunction::WorkOnIOThread, this));
44 DCHECK(result); 44 DCHECK(result);
(...skipping 28 matching lines...) Expand all
73 if (resolve_result != net::ERR_IO_PENDING) 73 if (resolve_result != net::ERR_IO_PENDING)
74 OnLookupFinished(resolve_result); 74 OnLookupFinished(resolve_result);
75 } 75 }
76 76
77 void DnsResolveFunction::RespondOnUIThread() { 77 void DnsResolveFunction::RespondOnUIThread() {
78 DCHECK_CURRENTLY_ON(BrowserThread::UI); 78 DCHECK_CURRENTLY_ON(BrowserThread::UI);
79 SendResponse(response_); 79 SendResponse(response_);
80 } 80 }
81 81
82 void DnsResolveFunction::OnLookupFinished(int resolve_result) { 82 void DnsResolveFunction::OnLookupFinished(int resolve_result) {
83 scoped_ptr<ResolveCallbackResolveInfo> resolve_info( 83 std::unique_ptr<ResolveCallbackResolveInfo> resolve_info(
84 new ResolveCallbackResolveInfo()); 84 new ResolveCallbackResolveInfo());
85 resolve_info->result_code = resolve_result; 85 resolve_info->result_code = resolve_result;
86 if (resolve_result == net::OK) { 86 if (resolve_result == net::OK) {
87 DCHECK(!addresses_->empty()); 87 DCHECK(!addresses_->empty());
88 resolve_info->address.reset( 88 resolve_info->address.reset(
89 new std::string(addresses_->front().ToStringWithoutPort())); 89 new std::string(addresses_->front().ToStringWithoutPort()));
90 } 90 }
91 results_ = Resolve::Results::Create(*resolve_info); 91 results_ = Resolve::Results::Create(*resolve_info);
92 response_ = true; 92 response_ = true;
93 93
94 bool post_task_result = BrowserThread::PostTask( 94 bool post_task_result = BrowserThread::PostTask(
95 BrowserThread::UI, 95 BrowserThread::UI,
96 FROM_HERE, 96 FROM_HERE,
97 base::Bind(&DnsResolveFunction::RespondOnUIThread, this)); 97 base::Bind(&DnsResolveFunction::RespondOnUIThread, this));
98 DCHECK(post_task_result); 98 DCHECK(post_task_result);
99 99
100 Release(); // Added in WorkOnIOThread(). 100 Release(); // Added in WorkOnIOThread().
101 } 101 }
102 102
103 } // namespace extensions 103 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/dns/dns_api.h ('k') | extensions/browser/api/dns/dns_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698