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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 public net::URLFetcherDelegate { | 34 public net::URLFetcherDelegate { |
35 public: | 35 public: |
36 enum ResponseAction { | 36 enum ResponseAction { |
37 CONTINUE_PROCESSING, | 37 CONTINUE_PROCESSING, |
38 STOP_PROCESSING, | 38 STOP_PROCESSING, |
39 RETRY_REQUEST, | 39 RETRY_REQUEST, |
40 }; | 40 }; |
41 | 41 |
42 class Delegate { | 42 class Delegate { |
43 public: | 43 public: |
44 virtual ~Delegate() { } | |
45 // Override this to handle the raw response as it is available. No response | 44 // Override this to handle the raw response as it is available. No response |
46 // error checking is done before this method is called. If the delegate | 45 // error checking is done before this method is called. If the delegate |
47 // returns CONTINUE_PROCESSING, we will then check for network | 46 // returns CONTINUE_PROCESSING, we will then check for network |
48 // errors. Most implementations will not override this. | 47 // errors. Most implementations will not override this. |
49 virtual ResponseAction HandleRawResponse( | 48 virtual ResponseAction HandleRawResponse( |
50 const net::URLFetcher* source, | 49 const net::URLFetcher* source, |
51 const GURL& url, | 50 const GURL& url, |
52 const net::URLRequestStatus& status, | 51 const net::URLRequestStatus& status, |
53 int response_code, | 52 int response_code, |
54 const net::ResponseCookies& cookies, | 53 const net::ResponseCookies& cookies, |
(...skipping 28 matching lines...) Expand all Loading... |
83 // HandleRawResponse returns CONTINUE_PROCESSING). | 82 // HandleRawResponse returns CONTINUE_PROCESSING). |
84 // Returning RETRY_REQUEST will retry current request. (auth information | 83 // Returning RETRY_REQUEST will retry current request. (auth information |
85 // may have been updated and new info is available through the | 84 // may have been updated and new info is available through the |
86 // Authenticator interface). | 85 // Authenticator interface). |
87 // Returning CONTINUE_PROCESSING will treat auth error as a network error. | 86 // Returning CONTINUE_PROCESSING will treat auth error as a network error. |
88 virtual ResponseAction OnRequestAuthError() = 0; | 87 virtual ResponseAction OnRequestAuthError() = 0; |
89 | 88 |
90 // Authentication information may change between retries. | 89 // Authentication information may change between retries. |
91 // CloudPrintURLFetcher will request auth info before sending any request. | 90 // CloudPrintURLFetcher will request auth info before sending any request. |
92 virtual std::string GetAuthHeader() = 0; | 91 virtual std::string GetAuthHeader() = 0; |
| 92 |
| 93 protected: |
| 94 virtual ~Delegate() {} |
93 }; | 95 }; |
94 CloudPrintURLFetcher(); | 96 CloudPrintURLFetcher(); |
95 | 97 |
96 bool IsSameRequest(const net::URLFetcher* source); | 98 bool IsSameRequest(const net::URLFetcher* source); |
97 | 99 |
98 void StartGetRequest(const GURL& url, | 100 void StartGetRequest(const GURL& url, |
99 Delegate* delegate, | 101 Delegate* delegate, |
100 int max_retries, | 102 int max_retries, |
101 const std::string& additional_headers); | 103 const std::string& additional_headers); |
102 void StartPostRequest(const GURL& url, | 104 void StartPostRequest(const GURL& url, |
(...skipping 28 matching lines...) Expand all Loading... |
131 int num_retries_; | 133 int num_retries_; |
132 net::URLFetcher::RequestType request_type_; | 134 net::URLFetcher::RequestType request_type_; |
133 std::string additional_headers_; | 135 std::string additional_headers_; |
134 std::string post_data_mime_type_; | 136 std::string post_data_mime_type_; |
135 std::string post_data_; | 137 std::string post_data_; |
136 }; | 138 }; |
137 | 139 |
138 typedef CloudPrintURLFetcher::Delegate CloudPrintURLFetcherDelegate; | 140 typedef CloudPrintURLFetcher::Delegate CloudPrintURLFetcherDelegate; |
139 | 141 |
140 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_ | 142 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_ |
OLD | NEW |