Chromium Code Reviews| 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..183c296fcd284fed4451946e305e7bbdde65a5e9 |
| --- /dev/null |
| +++ b/third_party/libaddressinput/chromium/chrome_downloader_impl.h |
| @@ -0,0 +1,51 @@ |
| +// 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> |
|
Dan Beam
2014/01/08 03:25:49
#include <string>
#include "base/memory/scoped_pt
Evan Stade
2014/01/09 00:05:12
Done.
|
| + |
| +#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_; |
|
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
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(ChromeDownloaderImpl); |
| +}; |
| + |
| +#endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_DOWNLOADER_IMPL_H_ |