| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 virtual ResponseAction OnRequestAuthError() = 0; | 108 virtual ResponseAction OnRequestAuthError() = 0; |
| 109 | 109 |
| 110 // Authentication information may change between retries. | 110 // Authentication information may change between retries. |
| 111 // CloudPrintURLFetcher will request auth info before sending any request. | 111 // CloudPrintURLFetcher will request auth info before sending any request. |
| 112 virtual std::string GetAuthHeader() = 0; | 112 virtual std::string GetAuthHeader() = 0; |
| 113 | 113 |
| 114 protected: | 114 protected: |
| 115 virtual ~Delegate() {} | 115 virtual ~Delegate() {} |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 static CloudPrintURLFetcher* Create(); | 118 static CloudPrintURLFetcher* Create( |
| 119 const net::PartialNetworkTrafficAnnotationTag& |
| 120 partial_traffic_annotation); |
| 119 static void set_test_factory(CloudPrintURLFetcherFactory* factory); | 121 static void set_test_factory(CloudPrintURLFetcherFactory* factory); |
| 120 | 122 |
| 121 bool IsSameRequest(const net::URLFetcher* source); | 123 bool IsSameRequest(const net::URLFetcher* source); |
| 122 | 124 |
| 123 void StartGetRequest(RequestType type, | 125 void StartGetRequest(RequestType type, |
| 124 const GURL& url, | 126 const GURL& url, |
| 125 Delegate* delegate, | 127 Delegate* delegate, |
| 126 int max_retries, | 128 int max_retries, |
| 127 const std::string& additional_headers); | 129 const std::string& additional_headers); |
| 128 void StartPostRequest(RequestType type, | 130 void StartPostRequest(RequestType type, |
| 129 const GURL& url, | 131 const GURL& url, |
| 130 Delegate* delegate, | 132 Delegate* delegate, |
| 131 int max_retries, | 133 int max_retries, |
| 132 const std::string& post_data_mime_type, | 134 const std::string& post_data_mime_type, |
| 133 const std::string& post_data, | 135 const std::string& post_data, |
| 134 const std::string& additional_headers); | 136 const std::string& additional_headers); |
| 135 | 137 |
| 136 // net::URLFetcherDelegate implementation. | 138 // net::URLFetcherDelegate implementation. |
| 137 void OnURLFetchComplete(const net::URLFetcher* source) override; | 139 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 138 | 140 |
| 139 protected: | 141 protected: |
| 140 CloudPrintURLFetcher(); | 142 CloudPrintURLFetcher(const net::PartialNetworkTrafficAnnotationTag& |
| 143 partial_traffic_annotation); |
| 141 friend class base::RefCountedThreadSafe<CloudPrintURLFetcher>; | 144 friend class base::RefCountedThreadSafe<CloudPrintURLFetcher>; |
| 142 ~CloudPrintURLFetcher() override; | 145 ~CloudPrintURLFetcher() override; |
| 143 | 146 |
| 144 // Virtual for testing. | 147 // Virtual for testing. |
| 145 virtual net::URLRequestContextGetter* GetRequestContextGetter(); | 148 virtual net::URLRequestContextGetter* GetRequestContextGetter(); |
| 146 | 149 |
| 147 private: | 150 private: |
| 148 void StartRequestHelper(RequestType type, | 151 void StartRequestHelper(RequestType type, |
| 149 const GURL& url, | 152 const GURL& url, |
| 150 net::URLFetcher::RequestType request_type, | 153 net::URLFetcher::RequestType request_type, |
| 151 Delegate* delegate, | 154 Delegate* delegate, |
| 152 int max_retries, | 155 int max_retries, |
| 153 const std::string& post_data_mime_type, | 156 const std::string& post_data_mime_type, |
| 154 const std::string& post_data, | 157 const std::string& post_data, |
| 155 const std::string& additional_headers); | 158 const std::string& additional_headers); |
| 156 void SetupRequestHeaders(); | 159 void SetupRequestHeaders(); |
| 157 | 160 |
| 158 std::unique_ptr<net::URLFetcher> request_; | 161 std::unique_ptr<net::URLFetcher> request_; |
| 159 Delegate* delegate_; | 162 Delegate* delegate_; |
| 160 int num_retries_; | 163 int num_retries_; |
| 161 std::string additional_headers_; | 164 std::string additional_headers_; |
| 162 std::string post_data_mime_type_; | 165 std::string post_data_mime_type_; |
| 163 std::string post_data_; | 166 std::string post_data_; |
| 164 | 167 |
| 165 RequestType type_; | 168 RequestType type_; |
| 166 base::Time start_time_; | 169 base::Time start_time_; |
| 170 const net::PartialNetworkTrafficAnnotationTag partial_traffic_annotation_; |
| 167 }; | 171 }; |
| 168 | 172 |
| 169 } // namespace cloud_print | 173 } // namespace cloud_print |
| 170 | 174 |
| 171 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_ | 175 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_URL_FETCHER_H_ |
| OLD | NEW |