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

Unified Diff: third_party/libaddressinput/chromium/chrome_downloader_impl.cc

Issue 386873002: Reland "Use upstream libaddressinput in Chrome." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix iOS compile. Created 6 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698