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 #include "chrome/browser/printing/cloud_print/privet_url_fetcher.h" | 5 #include "chrome/browser/printing/cloud_print/privet_url_fetcher.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 url_fetcher_->AddExtraRequestHeader( | 164 url_fetcher_->AddExtraRequestHeader( |
165 std::string(kXPrivetTokenHeaderPrefix) + token); | 165 std::string(kXPrivetTokenHeaderPrefix) + token); |
166 | 166 |
167 if (has_byte_range_) { | 167 if (has_byte_range_) { |
168 url_fetcher_->AddExtraRequestHeader( | 168 url_fetcher_->AddExtraRequestHeader( |
169 MakeRangeHeader(byte_range_start_, byte_range_end_)); | 169 MakeRangeHeader(byte_range_start_, byte_range_end_)); |
170 } | 170 } |
171 | 171 |
172 if (make_response_file_) { | 172 if (make_response_file_) { |
173 url_fetcher_->SaveResponseToTemporaryFile( | 173 url_fetcher_->SaveResponseToTemporaryFile( |
174 content::BrowserThread::GetMessageLoopProxyForThread( | 174 content::BrowserThread::GetTaskRunnerForThread( |
175 content::BrowserThread::FILE)); | 175 content::BrowserThread::FILE)); |
176 } | 176 } |
177 | 177 |
178 // URLFetcher requires us to set upload data for POST requests. | 178 // URLFetcher requires us to set upload data for POST requests. |
179 if (request_type_ == net::URLFetcher::POST) { | 179 if (request_type_ == net::URLFetcher::POST) { |
180 if (!upload_file_path_.empty()) { | 180 if (!upload_file_path_.empty()) { |
181 url_fetcher_->SetUploadFilePath( | 181 url_fetcher_->SetUploadFilePath( |
182 upload_content_type_, upload_file_path_, 0 /*offset*/, | 182 upload_content_type_, upload_file_path_, 0 /*offset*/, |
183 std::numeric_limits<uint64_t>::max() /*length*/, | 183 std::numeric_limits<uint64_t>::max() /*length*/, |
184 content::BrowserThread::GetMessageLoopProxyForThread( | 184 content::BrowserThread::GetTaskRunnerForThread( |
185 content::BrowserThread::FILE)); | 185 content::BrowserThread::FILE)); |
186 } else { | 186 } else { |
187 url_fetcher_->SetUploadData(upload_content_type_, upload_data_); | 187 url_fetcher_->SetUploadData(upload_content_type_, upload_data_); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 url_fetcher_->Start(); | 191 url_fetcher_->Start(); |
192 } else { | 192 } else { |
193 delegate_->OnError(this, UNKNOWN_ERROR); | 193 delegate_->OnError(this, UNKNOWN_ERROR); |
194 } | 194 } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 } | 381 } |
382 | 382 |
383 bool PrivetURLFetcher::PrivetErrorTransient(const std::string& error) { | 383 bool PrivetURLFetcher::PrivetErrorTransient(const std::string& error) { |
384 return (error == kPrivetErrorDeviceBusy) || | 384 return (error == kPrivetErrorDeviceBusy) || |
385 (error == kPrivetV3ErrorDeviceBusy) || | 385 (error == kPrivetV3ErrorDeviceBusy) || |
386 (error == kPrivetErrorPendingUserAction) || | 386 (error == kPrivetErrorPendingUserAction) || |
387 (error == kPrivetErrorPrinterBusy); | 387 (error == kPrivetErrorPrinterBusy); |
388 } | 388 } |
389 | 389 |
390 } // namespace cloud_print | 390 } // namespace cloud_print |
OLD | NEW |