| 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 "webkit/plugins/ppapi/ppb_url_loader_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
| 9 #include "ppapi/c/pp_completion_callback.h" | 9 #include "ppapi/c/pp_completion_callback.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 | 398 |
| 399 size_t PPB_URLLoader_Impl::FillUserBuffer() { | 399 size_t PPB_URLLoader_Impl::FillUserBuffer() { |
| 400 DCHECK(user_buffer_); | 400 DCHECK(user_buffer_); |
| 401 DCHECK(user_buffer_size_); | 401 DCHECK(user_buffer_size_); |
| 402 | 402 |
| 403 size_t bytes_to_copy = std::min(buffer_.size(), user_buffer_size_); | 403 size_t bytes_to_copy = std::min(buffer_.size(), user_buffer_size_); |
| 404 std::copy(buffer_.begin(), buffer_.begin() + bytes_to_copy, user_buffer_); | 404 std::copy(buffer_.begin(), buffer_.begin() + bytes_to_copy, user_buffer_); |
| 405 buffer_.erase(buffer_.begin(), buffer_.begin() + bytes_to_copy); | 405 buffer_.erase(buffer_.begin(), buffer_.begin() + bytes_to_copy); |
| 406 | 406 |
| 407 // If the buffer is getting too empty, resume asynchronous loading. | 407 // If the buffer is getting too empty, resume asynchronous loading. |
| 408 DCHECK(!is_asynchronous_load_suspended_); | |
| 409 if (is_asynchronous_load_suspended_ && | 408 if (is_asynchronous_load_suspended_ && |
| 410 buffer_.size() <= static_cast<size_t>( | 409 buffer_.size() <= static_cast<size_t>( |
| 411 request_data_.prefetch_buffer_lower_threshold)) { | 410 request_data_.prefetch_buffer_lower_threshold)) { |
| 412 DVLOG(1) << "Resuming async load - buffer size: " << buffer_.size(); | 411 DVLOG(1) << "Resuming async load - buffer size: " << buffer_.size(); |
| 413 loader_->setDefersLoading(false); | 412 loader_->setDefersLoading(false); |
| 414 is_asynchronous_load_suspended_ = false; | 413 is_asynchronous_load_suspended_ = false; |
| 415 } | 414 } |
| 416 | 415 |
| 417 // Reset for next time. | 416 // Reset for next time. |
| 418 user_buffer_ = NULL; | 417 user_buffer_ = NULL; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 447 bool PPB_URLLoader_Impl::RecordDownloadProgress() const { | 446 bool PPB_URLLoader_Impl::RecordDownloadProgress() const { |
| 448 return request_data_.record_download_progress; | 447 return request_data_.record_download_progress; |
| 449 } | 448 } |
| 450 | 449 |
| 451 bool PPB_URLLoader_Impl::RecordUploadProgress() const { | 450 bool PPB_URLLoader_Impl::RecordUploadProgress() const { |
| 452 return request_data_.record_upload_progress; | 451 return request_data_.record_upload_progress; |
| 453 } | 452 } |
| 454 | 453 |
| 455 } // namespace ppapi | 454 } // namespace ppapi |
| 456 } // namespace webkit | 455 } // namespace webkit |
| OLD | NEW |