| 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_WEBSTORE_DATA_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // DictionaryValue. | 30 // DictionaryValue. |
| 31 class WebstoreDataFetcher : public base::SupportsWeakPtr<WebstoreDataFetcher>, | 31 class WebstoreDataFetcher : public base::SupportsWeakPtr<WebstoreDataFetcher>, |
| 32 public net::URLFetcherDelegate { | 32 public net::URLFetcherDelegate { |
| 33 public: | 33 public: |
| 34 WebstoreDataFetcher(WebstoreDataFetcherDelegate* delegate, | 34 WebstoreDataFetcher(WebstoreDataFetcherDelegate* delegate, |
| 35 net::URLRequestContextGetter* request_context, | 35 net::URLRequestContextGetter* request_context, |
| 36 const GURL& referrer_url, | 36 const GURL& referrer_url, |
| 37 const std::string webstore_item_id); | 37 const std::string webstore_item_id); |
| 38 ~WebstoreDataFetcher() override; | 38 ~WebstoreDataFetcher() override; |
| 39 | 39 |
| 40 // Makes this request use a POST instead of GET, and sends |json| in the |
| 41 // body of the request. If |json| is empty, this is a no-op. |
| 42 void SetJsonPostData(const std::string& json); |
| 43 |
| 40 void Start(); | 44 void Start(); |
| 41 | 45 |
| 42 void set_max_auto_retries(int max_retries) { | 46 void set_max_auto_retries(int max_retries) { |
| 43 max_auto_retries_ = max_retries; | 47 max_auto_retries_ = max_retries; |
| 44 } | 48 } |
| 45 | 49 |
| 46 private: | 50 private: |
| 47 void OnJsonParseSuccess(std::unique_ptr<base::Value> parsed_json); | 51 void OnJsonParseSuccess(std::unique_ptr<base::Value> parsed_json); |
| 48 void OnJsonParseFailure(const std::string& error); | 52 void OnJsonParseFailure(const std::string& error); |
| 49 | 53 |
| 50 // net::URLFetcherDelegate overrides: | 54 // net::URLFetcherDelegate overrides: |
| 51 void OnURLFetchComplete(const net::URLFetcher* source) override; | 55 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 52 | 56 |
| 53 WebstoreDataFetcherDelegate* delegate_; | 57 WebstoreDataFetcherDelegate* delegate_; |
| 54 net::URLRequestContextGetter* request_context_; | 58 net::URLRequestContextGetter* request_context_; |
| 55 GURL referrer_url_; | 59 GURL referrer_url_; |
| 56 std::string id_; | 60 std::string id_; |
| 61 std::string json_post_data_; |
| 57 | 62 |
| 58 // For fetching webstore JSON data. | 63 // For fetching webstore JSON data. |
| 59 std::unique_ptr<net::URLFetcher> webstore_data_url_fetcher_; | 64 std::unique_ptr<net::URLFetcher> webstore_data_url_fetcher_; |
| 60 | 65 |
| 61 // Maximum auto retry times on server 5xx error or ERR_NETWORK_CHANGED. | 66 // Maximum auto retry times on server 5xx error or ERR_NETWORK_CHANGED. |
| 62 // Default is 0 which means to use the URLFetcher default behavior. | 67 // Default is 0 which means to use the URLFetcher default behavior. |
| 63 int max_auto_retries_; | 68 int max_auto_retries_; |
| 64 | 69 |
| 65 DISALLOW_COPY_AND_ASSIGN(WebstoreDataFetcher); | 70 DISALLOW_COPY_AND_ASSIGN(WebstoreDataFetcher); |
| 66 }; | 71 }; |
| 67 | 72 |
| 68 } // namespace extensions | 73 } // namespace extensions |
| 69 | 74 |
| 70 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_ | 75 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_ |
| OLD | NEW |