| 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 #include "net/url_request/url_fetcher_core.h" | 5 #include "net/url_request/url_fetcher_core.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 } | 258 } |
| 259 | 259 |
| 260 void URLFetcherCore::SetAutomaticallyRetryOnNetworkChanges(int max_retries) { | 260 void URLFetcherCore::SetAutomaticallyRetryOnNetworkChanges(int max_retries) { |
| 261 max_retries_on_network_changes_ = max_retries; | 261 max_retries_on_network_changes_ = max_retries; |
| 262 } | 262 } |
| 263 | 263 |
| 264 void URLFetcherCore::SaveResponseToFileAtPath( | 264 void URLFetcherCore::SaveResponseToFileAtPath( |
| 265 const base::FilePath& file_path, | 265 const base::FilePath& file_path, |
| 266 scoped_refptr<base::TaskRunner> file_task_runner) { | 266 scoped_refptr<base::TaskRunner> file_task_runner) { |
| 267 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); | 267 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); |
| 268 response_writer_.reset(new URLFetcherFileWriter(file_task_runner, file_path)); | 268 SaveResponseWithWriter(scoped_ptr<URLFetcherResponseWriter>( |
| 269 new URLFetcherFileWriter(file_task_runner, file_path))); |
| 269 } | 270 } |
| 270 | 271 |
| 271 void URLFetcherCore::SaveResponseToTemporaryFile( | 272 void URLFetcherCore::SaveResponseToTemporaryFile( |
| 272 scoped_refptr<base::TaskRunner> file_task_runner) { | 273 scoped_refptr<base::TaskRunner> file_task_runner) { |
| 273 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); | 274 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); |
| 274 response_writer_.reset( | 275 SaveResponseWithWriter(scoped_ptr<URLFetcherResponseWriter>( |
| 275 new URLFetcherFileWriter(file_task_runner, base::FilePath())); | 276 new URLFetcherFileWriter(file_task_runner, base::FilePath()))); |
| 277 } |
| 278 |
| 279 void URLFetcherCore::SaveResponseWithWriter( |
| 280 scoped_ptr<URLFetcherResponseWriter> response_writer) { |
| 281 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); |
| 282 response_writer_ = response_writer.Pass(); |
| 276 } | 283 } |
| 277 | 284 |
| 278 HttpResponseHeaders* URLFetcherCore::GetResponseHeaders() const { | 285 HttpResponseHeaders* URLFetcherCore::GetResponseHeaders() const { |
| 279 return response_headers_.get(); | 286 return response_headers_.get(); |
| 280 } | 287 } |
| 281 | 288 |
| 282 // TODO(panayiotis): socket_address_ is written in the IO thread, | 289 // TODO(panayiotis): socket_address_ is written in the IO thread, |
| 283 // if this is accessed in the UI thread, this could result in a race. | 290 // if this is accessed in the UI thread, this could result in a race. |
| 284 // Same for response_headers_ above and was_fetched_via_proxy_ below. | 291 // Same for response_headers_ above and was_fetched_via_proxy_ below. |
| 285 HostPortPair URLFetcherCore::GetSocketAddress() const { | 292 HostPortPair URLFetcherCore::GetSocketAddress() const { |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 } | 906 } |
| 900 | 907 |
| 901 void URLFetcherCore::InformDelegateDownloadDataInDelegateThread( | 908 void URLFetcherCore::InformDelegateDownloadDataInDelegateThread( |
| 902 scoped_ptr<std::string> download_data) { | 909 scoped_ptr<std::string> download_data) { |
| 903 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); | 910 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); |
| 904 if (delegate_) | 911 if (delegate_) |
| 905 delegate_->OnURLFetchDownloadData(fetcher_, download_data.Pass()); | 912 delegate_->OnURLFetchDownloadData(fetcher_, download_data.Pass()); |
| 906 } | 913 } |
| 907 | 914 |
| 908 } // namespace net | 915 } // namespace net |
| OLD | NEW |