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

Side by Side Diff: components/autofill/core/browser/validation_downloader.cc

Issue 96323002: Implement i18n::addressinput::Downloader for requestAutocomplete() (and (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/autofill/core/browser/validation_downloader.h"
6
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "net/url_request/url_fetcher.h"
10
11 namespace autofill {
12
13 ValidationDownloader::ValidationDownloader(net::UrlRequestContextGetter* getter)
14 : getter_(getter) {}
15
16 ValidationDownloader::~ValidationDownloader() {}
please use gerrit instead 2013/12/02 17:33:26 Please invoke the remaining |callbacks_| with para
17
18 void ValidationDownloader::Download(
19 const std::string& url,
20 const i18n::addressinput::Downloader::Callback& downloaded) {
21 net::URLFetcher* fetcher(
Evan Stade 2013/12/02 21:50:04 The entirety of this function should be: new I1
22 net::URLFetcher::Create(GURL(url), net::URLFetcher::GET, this));
23 fetchers_.push_back(fetcher);
24 fetcher->SetRequestContext(getter_);
Evan Stade 2013/12/04 20:23:38 Also you will want: fetcher->SetLoadFlags(
25 callbacks_[fetcher] = downloaded;
26 fetcher->Start();
27 }
28
29 void ValidationDownloader::OnURLFetchComplete(const net::URLFetcher* source) {
30 DCHECK(fetchers_.find(source) != fetchers_.end());
31
32 CallbackMap::iterator it = callbacks_.find(source);
33 if (it == callbacks_.end()) {
34 NOTREACHED();
35 return;
36 }
37
38 bool ok = source->GetReponseCode() == net::HTTP_OK;
39 std::string url = source->GetOriginalURL().spec();
40 (it->second)(ok, url, ok ? source->GetResponseAsString() : std::string());
41 callbacks_.erase(it);
42
43 // |source| is owned by |fetchers_| and will be deleted later.
please use gerrit instead 2013/12/02 17:03:54 You could also do: fetchers_.erase(source);
44 }
45
46 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698