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 "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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 438 |
439 // If |user_buffer_| was set as part of registering a callback, the paths | 439 // If |user_buffer_| was set as part of registering a callback, the paths |
440 // which trigger that callack must have cleared it since the callback is now | 440 // which trigger that callack must have cleared it since the callback is now |
441 // free to delete it. | 441 // free to delete it. |
442 DCHECK(!user_buffer_); | 442 DCHECK(!user_buffer_); |
443 | 443 |
444 // As a second line of defense, clear the |user_buffer_| in case the | 444 // As a second line of defense, clear the |user_buffer_| in case the |
445 // callbacks get called in an unexpected order. | 445 // callbacks get called in an unexpected order. |
446 user_buffer_ = NULL; | 446 user_buffer_ = NULL; |
447 user_buffer_size_ = 0; | 447 user_buffer_size_ = 0; |
448 TrackedCallback::ClearAndRun(&pending_callback_, result); | 448 pending_callback_->Run(result); |
449 } | 449 } |
450 | 450 |
451 size_t PPB_URLLoader_Impl::FillUserBuffer() { | 451 size_t PPB_URLLoader_Impl::FillUserBuffer() { |
452 DCHECK(user_buffer_); | 452 DCHECK(user_buffer_); |
453 DCHECK(user_buffer_size_); | 453 DCHECK(user_buffer_size_); |
454 | 454 |
455 size_t bytes_to_copy = std::min(buffer_.size(), user_buffer_size_); | 455 size_t bytes_to_copy = std::min(buffer_.size(), user_buffer_size_); |
456 std::copy(buffer_.begin(), buffer_.begin() + bytes_to_copy, user_buffer_); | 456 std::copy(buffer_.begin(), buffer_.begin() + bytes_to_copy, user_buffer_); |
457 buffer_.erase(buffer_.begin(), buffer_.begin() + bytes_to_copy); | 457 buffer_.erase(buffer_.begin(), buffer_.begin() + bytes_to_copy); |
458 | 458 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 bool PPB_URLLoader_Impl::RecordDownloadProgress() const { | 497 bool PPB_URLLoader_Impl::RecordDownloadProgress() const { |
498 return request_data_.record_download_progress; | 498 return request_data_.record_download_progress; |
499 } | 499 } |
500 | 500 |
501 bool PPB_URLLoader_Impl::RecordUploadProgress() const { | 501 bool PPB_URLLoader_Impl::RecordUploadProgress() const { |
502 return request_data_.record_upload_progress; | 502 return request_data_.record_upload_progress; |
503 } | 503 } |
504 | 504 |
505 } // namespace ppapi | 505 } // namespace ppapi |
506 } // namespace webkit | 506 } // namespace webkit |
OLD | NEW |