| 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 "ppapi/proxy/ppb_url_loader_proxy.h" | 5 #include "ppapi/proxy/ppb_url_loader_proxy.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 327 |
| 328 if (result >= 0) { | 328 if (result >= 0) { |
| 329 // Fill the user buffer. We may get fewer bytes than requested in the | 329 // Fill the user buffer. We may get fewer bytes than requested in the |
| 330 // case of stream end. | 330 // case of stream end. |
| 331 int32_t bytes_to_return = std::min(current_read_buffer_size_, | 331 int32_t bytes_to_return = std::min(current_read_buffer_size_, |
| 332 static_cast<int32_t>(buffer_.size())); | 332 static_cast<int32_t>(buffer_.size())); |
| 333 PopBuffer(current_read_buffer_, bytes_to_return); | 333 PopBuffer(current_read_buffer_, bytes_to_return); |
| 334 result = bytes_to_return; | 334 result = bytes_to_return; |
| 335 } | 335 } |
| 336 | 336 |
| 337 TrackedCallback::ClearAndRun(¤t_callback_, result); | 337 current_callback_->Run(result); |
| 338 } | 338 } |
| 339 | 339 |
| 340 void URLLoader::CallbackComplete(int32_t result) { | 340 void URLLoader::CallbackComplete(int32_t result) { |
| 341 TrackedCallback::ClearAndRun(¤t_callback_, result); | 341 current_callback_->Run(result); |
| 342 } | 342 } |
| 343 | 343 |
| 344 void URLLoader::PopBuffer(void* output_buffer, int32_t output_size) { | 344 void URLLoader::PopBuffer(void* output_buffer, int32_t output_size) { |
| 345 CHECK(output_size <= static_cast<int32_t>(buffer_.size())); | 345 CHECK(output_size <= static_cast<int32_t>(buffer_.size())); |
| 346 std::copy(buffer_.begin(), | 346 std::copy(buffer_.begin(), |
| 347 buffer_.begin() + output_size, | 347 buffer_.begin() + output_size, |
| 348 static_cast<char*>(output_buffer)); | 348 static_cast<char*>(output_buffer)); |
| 349 buffer_.erase(buffer_.begin(), | 349 buffer_.erase(buffer_.begin(), |
| 350 buffer_.begin() + output_size); | 350 buffer_.begin() + output_size); |
| 351 } | 351 } |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 } | 588 } |
| 589 | 589 |
| 590 void PPB_URLLoader_Proxy::OnCallback(int32_t result, | 590 void PPB_URLLoader_Proxy::OnCallback(int32_t result, |
| 591 const HostResource& resource) { | 591 const HostResource& resource) { |
| 592 dispatcher()->Send(new PpapiMsg_PPBURLLoader_CallbackComplete( | 592 dispatcher()->Send(new PpapiMsg_PPBURLLoader_CallbackComplete( |
| 593 API_ID_PPB_URL_LOADER, resource, result)); | 593 API_ID_PPB_URL_LOADER, resource, result)); |
| 594 } | 594 } |
| 595 | 595 |
| 596 } // namespace proxy | 596 } // namespace proxy |
| 597 } // namespace ppapi | 597 } // namespace ppapi |
| OLD | NEW |