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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 public net::URLFetcherDelegate { | 31 public net::URLFetcherDelegate { |
32 public: | 32 public: |
33 WebstoreDataFetcher(WebstoreDataFetcherDelegate* delegate, | 33 WebstoreDataFetcher(WebstoreDataFetcherDelegate* delegate, |
34 net::URLRequestContextGetter* request_context, | 34 net::URLRequestContextGetter* request_context, |
35 const GURL& referrer_url, | 35 const GURL& referrer_url, |
36 const std::string webstore_item_id); | 36 const std::string webstore_item_id); |
37 virtual ~WebstoreDataFetcher(); | 37 virtual ~WebstoreDataFetcher(); |
38 | 38 |
39 void Start(); | 39 void Start(); |
40 | 40 |
| 41 void set_max_auto_retries(int max_retries) { |
| 42 max_auto_retries_ = max_retries; |
| 43 } |
| 44 |
41 private: | 45 private: |
42 void OnJsonParseSuccess(scoped_ptr<base::Value> parsed_json); | 46 void OnJsonParseSuccess(scoped_ptr<base::Value> parsed_json); |
43 void OnJsonParseFailure(const std::string& error); | 47 void OnJsonParseFailure(const std::string& error); |
44 | 48 |
45 // net::URLFetcherDelegate overrides: | 49 // net::URLFetcherDelegate overrides: |
46 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 50 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
47 | 51 |
48 WebstoreDataFetcherDelegate* delegate_; | 52 WebstoreDataFetcherDelegate* delegate_; |
49 net::URLRequestContextGetter* request_context_; | 53 net::URLRequestContextGetter* request_context_; |
50 GURL referrer_url_; | 54 GURL referrer_url_; |
51 std::string id_; | 55 std::string id_; |
52 | 56 |
53 // For fetching webstore JSON data. | 57 // For fetching webstore JSON data. |
54 scoped_ptr<net::URLFetcher> webstore_data_url_fetcher_; | 58 scoped_ptr<net::URLFetcher> webstore_data_url_fetcher_; |
55 | 59 |
| 60 // Maximum auto retry times on server 5xx error or ERR_NETWORK_CHANGED. |
| 61 // Default is 0 which means to use the URLFetcher default behavior. |
| 62 int max_auto_retries_; |
| 63 |
56 DISALLOW_COPY_AND_ASSIGN(WebstoreDataFetcher); | 64 DISALLOW_COPY_AND_ASSIGN(WebstoreDataFetcher); |
57 }; | 65 }; |
58 | 66 |
59 } // namespace extensions | 67 } // namespace extensions |
60 | 68 |
61 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_ | 69 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_ |
OLD | NEW |