[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / third_party / libaddressinput / chromium / chrome_downloader_impl.h
blobff9ff9fd4a9bed8e2f99defe670297bfa3e93885
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
3 // found in the LICENSE file.
5 #ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_
6 #define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_
8 #include <map>
9 #include <string>
11 #include "base/memory/scoped_vector.h"
12 #include "net/url_request/url_fetcher_delegate.h"
13 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/downloader.h"
15 namespace net {
16 class URLFetcher;
17 class URLRequestContextGetter;
20 namespace autofill {
22 // A class for downloading rules to let libaddressinput validate international
23 // addresses.
24 class ChromeDownloaderImpl : public ::i18n::addressinput::Downloader,
25 public net::URLFetcherDelegate {
26 public:
27 explicit ChromeDownloaderImpl(net::URLRequestContextGetter* getter);
28 virtual ~ChromeDownloaderImpl();
30 // ::i18n::addressinput::Downloader:
31 virtual void Download(const std::string& url,
32 const Callback& downloaded) const OVERRIDE;
34 // net::URLFetcherDelegate:
35 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
37 private:
38 struct Request {
39 Request(const std::string& url,
40 scoped_ptr<net::URLFetcher> fetcher,
41 const Callback& callback);
43 std::string url;
44 // The data that's received.
45 std::string data;
46 // The object that manages retrieving the data.
47 scoped_ptr<net::URLFetcher> fetcher;
48 const Callback& callback;
51 // Non-const version of Download().
52 void DoDownload(const std::string& url, const Callback& downloaded);
54 net::URLRequestContextGetter* const getter_; // weak
56 // Maps from active url fetcher to request metadata. The value is owned.
57 std::map<const net::URLFetcher*, Request*> requests_;
59 DISALLOW_COPY_AND_ASSIGN(ChromeDownloaderImpl);
62 } // namespace autofill
64 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_