| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_EXTENSIONS_BLACKLIST_STATE_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_BLACKLIST_STATE_FETCHER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_BLACKLIST_STATE_FETCHER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_BLACKLIST_STATE_FETCHER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class BlacklistStateFetcher : public net::URLFetcherDelegate { | 25 class BlacklistStateFetcher : public net::URLFetcherDelegate { |
| 26 public: | 26 public: |
| 27 typedef base::Callback<void(BlacklistState)> RequestCallback; | 27 typedef base::Callback<void(BlacklistState)> RequestCallback; |
| 28 | 28 |
| 29 BlacklistStateFetcher(); | 29 BlacklistStateFetcher(); |
| 30 | 30 |
| 31 ~BlacklistStateFetcher() override; | 31 ~BlacklistStateFetcher() override; |
| 32 | 32 |
| 33 virtual void Request(const std::string& id, const RequestCallback& callback); | 33 virtual void Request(const std::string& id, const RequestCallback& callback); |
| 34 | 34 |
| 35 void SetSafeBrowsingConfig(const SafeBrowsingProtocolConfig& config); | 35 void SetSafeBrowsingConfig( |
| 36 const safe_browsing::SafeBrowsingProtocolConfig& config); |
| 36 | 37 |
| 37 void SetURLRequestContextForTest( | 38 void SetURLRequestContextForTest( |
| 38 net::URLRequestContextGetter* request_context); | 39 net::URLRequestContextGetter* request_context); |
| 39 | 40 |
| 40 protected: | 41 protected: |
| 41 // net::URLFetcherDelegate interface. | 42 // net::URLFetcherDelegate interface. |
| 42 void OnURLFetchComplete(const net::URLFetcher* source) override; | 43 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 43 | 44 |
| 44 private: | 45 private: |
| 45 typedef std::multimap<std::string, RequestCallback> CallbackMultiMap; | 46 typedef std::multimap<std::string, RequestCallback> CallbackMultiMap; |
| 46 | 47 |
| 47 GURL RequestUrl() const; | 48 GURL RequestUrl() const; |
| 48 | 49 |
| 49 void SendRequest(const std::string& id); | 50 void SendRequest(const std::string& id); |
| 50 | 51 |
| 51 // ID for URLFetchers for testing. | 52 // ID for URLFetchers for testing. |
| 52 int url_fetcher_id_; | 53 int url_fetcher_id_; |
| 53 | 54 |
| 54 scoped_ptr<SafeBrowsingProtocolConfig> safe_browsing_config_; | 55 scoped_ptr<safe_browsing::SafeBrowsingProtocolConfig> safe_browsing_config_; |
| 55 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 56 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
| 56 scoped_refptr<net::URLRequestContextGetter> parent_request_context_for_test_; | 57 scoped_refptr<net::URLRequestContextGetter> parent_request_context_for_test_; |
| 57 | 58 |
| 58 // Extension id by URLFetcher. | 59 // Extension id by URLFetcher. |
| 59 std::map<const net::URLFetcher*, std::string> requests_; | 60 std::map<const net::URLFetcher*, std::string> requests_; |
| 60 | 61 |
| 61 // Callbacks by extension ID. | 62 // Callbacks by extension ID. |
| 62 CallbackMultiMap callbacks_; | 63 CallbackMultiMap callbacks_; |
| 63 | 64 |
| 64 base::WeakPtrFactory<BlacklistStateFetcher> weak_ptr_factory_; | 65 base::WeakPtrFactory<BlacklistStateFetcher> weak_ptr_factory_; |
| 65 | 66 |
| 66 DISALLOW_COPY_AND_ASSIGN(BlacklistStateFetcher); | 67 DISALLOW_COPY_AND_ASSIGN(BlacklistStateFetcher); |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 } // namespace extensions | 70 } // namespace extensions |
| 70 | 71 |
| 71 #endif // CHROME_BROWSER_EXTENSIONS_BLACKLIST_STATE_FETCHER_H_ | 72 #endif // CHROME_BROWSER_EXTENSIONS_BLACKLIST_STATE_FETCHER_H_ |
| 72 | |
| OLD | NEW |