OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/common/net/url_fetcher.h" | 5 #include "content/common/net/url_fetcher.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 NewRunnableMethod(core_, &Core::InformDelegateFetchIsComplete)); | 392 NewRunnableMethod(core_, &Core::InformDelegateFetchIsComplete)); |
393 return; | 393 return; |
394 } | 394 } |
395 | 395 |
396 total_bytes_written_ += bytes_written; | 396 total_bytes_written_ += bytes_written; |
397 buffer_offset_ += bytes_written; | 397 buffer_offset_ += bytes_written; |
398 pending_bytes_ -= bytes_written; | 398 pending_bytes_ -= bytes_written; |
399 | 399 |
400 if (pending_bytes_ > 0) { | 400 if (pending_bytes_ > 0) { |
401 base::FileUtilProxy::Write( | 401 base::FileUtilProxy::Write( |
402 file_message_loop_proxy_, | 402 file_message_loop_proxy_, temp_file_handle_, |
403 temp_file_handle_, | |
404 total_bytes_written_, // Append to the end | 403 total_bytes_written_, // Append to the end |
405 (core_->buffer_->data() + buffer_offset_), | 404 (core_->buffer_->data() + buffer_offset_), pending_bytes_, |
406 pending_bytes_, | 405 base::Bind(&URLFetcher::Core::TempFileWriter::ContinueWrite, |
407 callback_factory_.NewCallback( | 406 weak_factory_.GetWeakPtr())); |
408 &URLFetcher::Core::TempFileWriter::ContinueWrite)); | |
409 } else { | 407 } else { |
410 // Finished writing core_->buffer_ to the file. Read some more. | 408 // Finished writing core_->buffer_ to the file. Read some more. |
411 core_->ReadResponse(); | 409 core_->ReadResponse(); |
412 } | 410 } |
413 } | 411 } |
414 | 412 |
415 void URLFetcher::Core::TempFileWriter::DisownTempFile() { | 413 void URLFetcher::Core::TempFileWriter::DisownTempFile() { |
416 DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread()); | 414 DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread()); |
417 | 415 |
418 // Disowning is done by the delegate's OnURLFetchComplete method. | 416 // Disowning is done by the delegate's OnURLFetchComplete method. |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 } | 1136 } |
1139 | 1137 |
1140 // static | 1138 // static |
1141 int URLFetcher::GetNumFetcherCores() { | 1139 int URLFetcher::GetNumFetcherCores() { |
1142 return Core::g_registry.Get().size(); | 1140 return Core::g_registry.Get().size(); |
1143 } | 1141 } |
1144 | 1142 |
1145 URLFetcher::Delegate* URLFetcher::delegate() const { | 1143 URLFetcher::Delegate* URLFetcher::delegate() const { |
1146 return core_->delegate(); | 1144 return core_->delegate(); |
1147 } | 1145 } |
OLD | NEW |