Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 #ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_ | |
| 6 #define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_ | |
| 7 | |
| 8 #include <map> | |
|
Dan Beam
2014/01/08 03:25:49
#include <string>
#include "base/memory/scoped_pt
Evan Stade
2014/01/09 00:05:12
Done.
| |
| 9 | |
| 10 #include "base/memory/scoped_vector.h" | |
| 11 #include "net/url_request/url_fetcher_delegate.h" | |
| 12 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/downl oader.h" | |
| 13 | |
| 14 namespace net { | |
| 15 class URLFetcher; | |
| 16 class URLRequestContextGetter; | |
| 17 } | |
| 18 | |
| 19 // A class for downloading rules to let libaddressinput validate international | |
| 20 // addresses. | |
| 21 class ChromeDownloaderImpl : public i18n::addressinput::Downloader, | |
| 22 public net::URLFetcherDelegate { | |
| 23 public: | |
| 24 explicit ChromeDownloaderImpl(net::URLRequestContextGetter* getter); | |
| 25 virtual ~ChromeDownloaderImpl(); | |
| 26 | |
| 27 // i18n::addressinput::Downloader: | |
| 28 virtual void Download(const std::string& url, | |
| 29 scoped_ptr<Callback> downloaded) OVERRIDE; | |
| 30 | |
| 31 // net::URLFetcherDelegate: | |
| 32 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | |
| 33 | |
| 34 private: | |
| 35 struct Request { | |
| 36 Request(const std::string& url, scoped_ptr<Callback> callback); | |
| 37 | |
| 38 std::string url; | |
| 39 scoped_ptr<Callback> callback; | |
| 40 }; | |
| 41 | |
| 42 net::URLRequestContextGetter* const getter_; // weak | |
| 43 | |
| 44 // Maps from active url fetcher to request metadata. Both the key and value | |
| 45 // are owned. | |
| 46 std::map<const net::URLFetcher*, Request*> requests_; | |
|
Dan Beam
2014/01/08 03:25:49
I'm surprised we don't have an all-purpose ScopedM
Evan Stade
2014/01/09 00:05:12
good thing you were sitting down when you reviewed
| |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(ChromeDownloaderImpl); | |
| 49 }; | |
| 50 | |
| 51 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_ | |
| OLD | NEW |