| 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/local_discovery/privet_url_fetcher.h" | 5 #include "chrome/browser/local_discovery/privet_url_fetcher.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> |
| 8 | 11 |
| 9 #include "base/bind.h" | 12 #include "base/bind.h" |
| 10 #include "base/debug/dump_without_crashing.h" | 13 #include "base/debug/dump_without_crashing.h" |
| 11 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
| 12 #include "base/location.h" | 15 #include "base/location.h" |
| 13 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
| 14 #include "base/rand_util.h" | 17 #include "base/rand_util.h" |
| 15 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 16 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 17 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 if (make_response_file_) { | 171 if (make_response_file_) { |
| 169 url_fetcher_->SaveResponseToTemporaryFile( | 172 url_fetcher_->SaveResponseToTemporaryFile( |
| 170 content::BrowserThread::GetMessageLoopProxyForThread( | 173 content::BrowserThread::GetMessageLoopProxyForThread( |
| 171 content::BrowserThread::FILE)); | 174 content::BrowserThread::FILE)); |
| 172 } | 175 } |
| 173 | 176 |
| 174 // URLFetcher requires us to set upload data for POST requests. | 177 // URLFetcher requires us to set upload data for POST requests. |
| 175 if (request_type_ == net::URLFetcher::POST) { | 178 if (request_type_ == net::URLFetcher::POST) { |
| 176 if (!upload_file_path_.empty()) { | 179 if (!upload_file_path_.empty()) { |
| 177 url_fetcher_->SetUploadFilePath( | 180 url_fetcher_->SetUploadFilePath( |
| 178 upload_content_type_, | 181 upload_content_type_, upload_file_path_, 0 /*offset*/, |
| 179 upload_file_path_, | 182 std::numeric_limits<uint64_t>::max() /*length*/, |
| 180 0 /*offset*/, | |
| 181 kuint64max /*length*/, | |
| 182 content::BrowserThread::GetMessageLoopProxyForThread( | 183 content::BrowserThread::GetMessageLoopProxyForThread( |
| 183 content::BrowserThread::FILE)); | 184 content::BrowserThread::FILE)); |
| 184 } else { | 185 } else { |
| 185 url_fetcher_->SetUploadData(upload_content_type_, upload_data_); | 186 url_fetcher_->SetUploadData(upload_content_type_, upload_data_); |
| 186 } | 187 } |
| 187 } | 188 } |
| 188 | 189 |
| 189 url_fetcher_->Start(); | 190 url_fetcher_->Start(); |
| 190 } else { | 191 } else { |
| 191 delegate_->OnError(this, UNKNOWN_ERROR); | 192 delegate_->OnError(this, UNKNOWN_ERROR); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 } | 380 } |
| 380 | 381 |
| 381 bool PrivetURLFetcher::PrivetErrorTransient(const std::string& error) { | 382 bool PrivetURLFetcher::PrivetErrorTransient(const std::string& error) { |
| 382 return (error == kPrivetErrorDeviceBusy) || | 383 return (error == kPrivetErrorDeviceBusy) || |
| 383 (error == kPrivetV3ErrorDeviceBusy) || | 384 (error == kPrivetV3ErrorDeviceBusy) || |
| 384 (error == kPrivetErrorPendingUserAction) || | 385 (error == kPrivetErrorPendingUserAction) || |
| 385 (error == kPrivetErrorPrinterBusy); | 386 (error == kPrivetErrorPrinterBusy); |
| 386 } | 387 } |
| 387 | 388 |
| 388 } // namespace local_discovery | 389 } // namespace local_discovery |
| OLD | NEW |