Index: third_party/libaddressinput/chromium/chrome_downloader_impl.h |
diff --git a/third_party/libaddressinput/chromium/chrome_downloader_impl.h b/third_party/libaddressinput/chromium/chrome_downloader_impl.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..70fe16a3711f4e40dab5ce73f01d229bcd87e3d8 |
--- /dev/null |
+++ b/third_party/libaddressinput/chromium/chrome_downloader_impl.h |
@@ -0,0 +1,52 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_ |
+#define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_ |
+ |
+#include <map> |
+#include <string> |
+ |
+#include "base/memory/scoped_vector.h" |
+#include "net/url_request/url_fetcher_delegate.h" |
+#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/downloader.h" |
+ |
+namespace net { |
+class URLFetcher; |
+class URLRequestContextGetter; |
+} |
+ |
+// A class for downloading rules to let libaddressinput validate international |
+// addresses. |
+class ChromeDownloaderImpl : public i18n::addressinput::Downloader, |
+ public net::URLFetcherDelegate { |
+ public: |
+ explicit ChromeDownloaderImpl(net::URLRequestContextGetter* getter); |
+ virtual ~ChromeDownloaderImpl(); |
+ |
+ // i18n::addressinput::Downloader: |
+ virtual void Download(const std::string& url, |
+ scoped_ptr<Callback> downloaded) OVERRIDE; |
+ |
+ // net::URLFetcherDelegate: |
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
+ |
+ private: |
+ struct Request { |
+ Request(const std::string& url, scoped_ptr<Callback> callback); |
+ |
+ std::string url; |
+ scoped_ptr<Callback> callback; |
+ }; |
+ |
+ net::URLRequestContextGetter* const getter_; // weak |
+ |
+ // Maps from active url fetcher to request metadata. Both the key and value |
+ // are owned. |
+ std::map<const net::URLFetcher*, Request*> requests_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ChromeDownloaderImpl); |
+}; |
+ |
+#endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_ |