OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_ | 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_ |
6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_ | 6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "net/url_request/url_fetcher.h" | 12 #include "net/url_request/url_fetcher.h" |
13 #include "net/url_request/url_fetcher_delegate.h" | 13 #include "net/url_request/url_fetcher_delegate.h" |
14 | 14 |
15 class GURL; | 15 class GURL; |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class DictionaryValue; | 18 class DictionaryValue; |
19 } | 19 } |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 class URLRequestContextGetter; | 22 class URLRequestContextGetter; |
23 class URLRequestStatus; | 23 class URLRequestStatus; |
24 } // namespace net | 24 } // namespace net |
25 | 25 |
| 26 namespace cloud_print { |
| 27 |
26 // A wrapper around URLFetcher for CloudPrint. URLFetcher applies retry logic | 28 // A wrapper around URLFetcher for CloudPrint. URLFetcher applies retry logic |
27 // only on HTTP response codes >= 500. In the cloud print case, we want to | 29 // only on HTTP response codes >= 500. In the cloud print case, we want to |
28 // retry on all network errors. In addition, we want to treat non-JSON responses | 30 // retry on all network errors. In addition, we want to treat non-JSON responses |
29 // (for all CloudPrint APIs that expect JSON responses) as errors and they | 31 // (for all CloudPrint APIs that expect JSON responses) as errors and they |
30 // must also be retried. | 32 // must also be retried. |
31 class CloudPrintURLFetcher | 33 class CloudPrintURLFetcher |
32 : public base::RefCountedThreadSafe<CloudPrintURLFetcher>, | 34 : public base::RefCountedThreadSafe<CloudPrintURLFetcher>, |
33 public net::URLFetcherDelegate { | 35 public net::URLFetcherDelegate { |
34 public: | 36 public: |
35 enum ResponseAction { | 37 enum ResponseAction { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 Delegate* delegate_; | 131 Delegate* delegate_; |
130 int num_retries_; | 132 int num_retries_; |
131 net::URLFetcher::RequestType request_type_; | 133 net::URLFetcher::RequestType request_type_; |
132 std::string additional_headers_; | 134 std::string additional_headers_; |
133 std::string post_data_mime_type_; | 135 std::string post_data_mime_type_; |
134 std::string post_data_; | 136 std::string post_data_; |
135 }; | 137 }; |
136 | 138 |
137 typedef CloudPrintURLFetcher::Delegate CloudPrintURLFetcherDelegate; | 139 typedef CloudPrintURLFetcher::Delegate CloudPrintURLFetcherDelegate; |
138 | 140 |
| 141 } // namespace cloud_print |
| 142 |
139 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_ | 143 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_ |
OLD | NEW |