OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_ | 5 #ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_ |
6 #define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_ | 6 #define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
12 #include "net/url_request/url_fetcher_delegate.h" | 12 #include "net/url_request/url_fetcher_delegate.h" |
13 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/downl
oader.h" | 13 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/downl
oader.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 class URLFetcher; | 16 class URLFetcher; |
17 class URLRequestContextGetter; | 17 class URLRequestContextGetter; |
18 } | 18 } |
19 | 19 |
| 20 namespace autofill { |
| 21 |
20 // A class for downloading rules to let libaddressinput validate international | 22 // A class for downloading rules to let libaddressinput validate international |
21 // addresses. | 23 // addresses. |
22 class ChromeDownloaderImpl : public i18n::addressinput::Downloader, | 24 class ChromeDownloaderImpl : public ::i18n::addressinput::Downloader, |
23 public net::URLFetcherDelegate { | 25 public net::URLFetcherDelegate { |
24 public: | 26 public: |
25 explicit ChromeDownloaderImpl(net::URLRequestContextGetter* getter); | 27 explicit ChromeDownloaderImpl(net::URLRequestContextGetter* getter); |
26 virtual ~ChromeDownloaderImpl(); | 28 virtual ~ChromeDownloaderImpl(); |
27 | 29 |
28 // i18n::addressinput::Downloader: | 30 // ::i18n::addressinput::Downloader: |
29 virtual void Download(const std::string& url, | 31 virtual void Download(const std::string& url, |
30 scoped_ptr<Callback> downloaded) OVERRIDE; | 32 scoped_ptr<Callback> downloaded) OVERRIDE; |
31 | 33 |
32 // net::URLFetcherDelegate: | 34 // net::URLFetcherDelegate: |
33 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 35 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
34 | 36 |
35 private: | 37 private: |
36 struct Request { | 38 struct Request { |
37 Request(const std::string& url, scoped_ptr<Callback> callback); | 39 Request(const std::string& url, scoped_ptr<Callback> callback); |
38 | 40 |
39 std::string url; | 41 std::string url; |
40 scoped_ptr<Callback> callback; | 42 scoped_ptr<Callback> callback; |
41 }; | 43 }; |
42 | 44 |
43 net::URLRequestContextGetter* const getter_; // weak | 45 net::URLRequestContextGetter* const getter_; // weak |
44 | 46 |
45 // Maps from active url fetcher to request metadata. Both the key and value | 47 // Maps from active url fetcher to request metadata. Both the key and value |
46 // are owned. | 48 // are owned. |
47 std::map<const net::URLFetcher*, Request*> requests_; | 49 std::map<const net::URLFetcher*, Request*> requests_; |
48 | 50 |
49 DISALLOW_COPY_AND_ASSIGN(ChromeDownloaderImpl); | 51 DISALLOW_COPY_AND_ASSIGN(ChromeDownloaderImpl); |
50 }; | 52 }; |
51 | 53 |
| 54 } // namespace autofill |
| 55 |
52 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_ | 56 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_ |
OLD | NEW |