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_
11 #include "base/memory/scoped_vector.h"
12 #include "net/url_request/url_fetcher_delegate.h"
13 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/downloader.h"
17 class URLRequestContextGetter;
20 // A class for downloading rules to let libaddressinput validate international
22 class ChromeDownloaderImpl : public i18n::addressinput::Downloader,
23 public net::URLFetcherDelegate {
25 explicit ChromeDownloaderImpl(net::URLRequestContextGetter* getter);
26 virtual ~ChromeDownloaderImpl();
28 // i18n::addressinput::Downloader:
29 virtual void Download(const std::string& url,
30 scoped_ptr<Callback> downloaded) OVERRIDE;
32 // net::URLFetcherDelegate:
33 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
37 Request(const std::string& url, scoped_ptr<Callback> callback);
40 scoped_ptr<Callback> callback;
43 net::URLRequestContextGetter* const getter_; // weak
45 // Maps from active url fetcher to request metadata. Both the key and value
47 std::map<const net::URLFetcher*, Request*> requests_;
49 DISALLOW_COPY_AND_ASSIGN(ChromeDownloaderImpl);
52 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_