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

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

Issue 388613002: Revert 282408 "Use upstream libaddressinput in Chrome." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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: trunk/src/third_party/libaddressinput/chromium/chrome_downloader_impl.cc
===================================================================
--- trunk/src/third_party/libaddressinput/chromium/chrome_downloader_impl.cc (revision 282425)
+++ trunk/src/third_party/libaddressinput/chromium/chrome_downloader_impl.cc (working copy)
@@ -55,9 +55,27 @@
STLDeleteValues(&requests_);
}
-void ChromeDownloaderImpl::Download(const std::string& url,
- const Callback& downloaded) const {
- const_cast<ChromeDownloaderImpl*>(this)->DoDownload(url, downloaded);
+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::OnURLFetchComplete(const net::URLFetcher* source) {
@@ -69,7 +87,7 @@
scoped_ptr<std::string> data(new std::string());
if (ok)
data->swap(request->second->data);
- request->second->callback(ok, request->second->url, data.release());
+ (*request->second->callback)(ok, request->second->url, data.Pass());
delete request->second;
requests_.erase(request);
@@ -77,31 +95,9 @@
ChromeDownloaderImpl::Request::Request(const std::string& url,
scoped_ptr<net::URLFetcher> fetcher,
- const Callback& callback)
+ scoped_ptr<Callback> callback)
: url(url),
fetcher(fetcher.Pass()),
- callback(callback) {}
+ callback(callback.Pass()) {}
-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