Index: third_party/libaddressinput/chromium/chrome_downloader_impl.cc |
diff --git a/third_party/libaddressinput/chromium/chrome_downloader_impl.cc b/third_party/libaddressinput/chromium/chrome_downloader_impl.cc |
index 507cc9ed8f17b3389cafd78ac17e0696a0d7d7b1..950500ea2d351d32df9042b86b9629bc41e86faf 100644 |
--- a/third_party/libaddressinput/chromium/chrome_downloader_impl.cc |
+++ b/third_party/libaddressinput/chromium/chrome_downloader_impl.cc |
@@ -55,27 +55,9 @@ ChromeDownloaderImpl::~ChromeDownloaderImpl() { |
STLDeleteValues(&requests_); |
} |
-void ChromeDownloaderImpl::Download( |
- const std::string& url, |
- scoped_ptr<Callback> downloaded) { |
- GURL resource(url); |
- if (!resource.SchemeIsSecure()) { |
- (*downloaded)(false, url, make_scoped_ptr(new std::string())); |
- return; |
- } |
- |
- scoped_ptr<net::URLFetcher> fetcher( |
- net::URLFetcher::Create(resource, net::URLFetcher::GET, this)); |
- fetcher->SetLoadFlags( |
- net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); |
- fetcher->SetRequestContext(getter_); |
- |
- Request* request = new Request(url, fetcher.Pass(), downloaded.Pass()); |
- request->fetcher->SaveResponseWithWriter( |
- scoped_ptr<net::URLFetcherResponseWriter>( |
- new UnownedStringWriter(&request->data))); |
- requests_[request->fetcher.get()] = request; |
- request->fetcher->Start(); |
+void ChromeDownloaderImpl::Download(const std::string& url, |
+ const Callback& downloaded) const { |
+ const_cast<ChromeDownloaderImpl*>(this)->DoDownload(url, downloaded); |
} |
void ChromeDownloaderImpl::OnURLFetchComplete(const net::URLFetcher* source) { |
@@ -87,7 +69,7 @@ void ChromeDownloaderImpl::OnURLFetchComplete(const net::URLFetcher* source) { |
scoped_ptr<std::string> data(new std::string()); |
if (ok) |
data->swap(request->second->data); |
- (*request->second->callback)(ok, request->second->url, data.Pass()); |
+ request->second->callback(ok, request->second->url, data.release()); |
delete request->second; |
requests_.erase(request); |
@@ -95,9 +77,31 @@ void ChromeDownloaderImpl::OnURLFetchComplete(const net::URLFetcher* source) { |
ChromeDownloaderImpl::Request::Request(const std::string& url, |
scoped_ptr<net::URLFetcher> fetcher, |
- scoped_ptr<Callback> callback) |
+ const Callback& callback) |
: url(url), |
fetcher(fetcher.Pass()), |
- callback(callback.Pass()) {} |
+ callback(callback) {} |
+ |
+void ChromeDownloaderImpl::DoDownload(const std::string& url, |
+ const Callback& downloaded) { |
+ GURL resource(url); |
+ if (!resource.SchemeIsSecure()) { |
+ downloaded(false, url, NULL); |
+ return; |
+ } |
+ |
+ scoped_ptr<net::URLFetcher> fetcher( |
+ net::URLFetcher::Create(resource, net::URLFetcher::GET, this)); |
+ fetcher->SetLoadFlags( |
+ net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); |
+ fetcher->SetRequestContext(getter_); |
+ |
+ Request* request = new Request(url, fetcher.Pass(), downloaded); |
+ request->fetcher->SaveResponseWithWriter( |
+ scoped_ptr<net::URLFetcherResponseWriter>( |
+ new UnownedStringWriter(&request->data))); |
+ requests_[request->fetcher.get()] = request; |
+ request->fetcher->Start(); |
+} |
} // namespace autofill |