Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(910)

Side by Side Diff: webkit/plugins/ppapi/ppb_url_loader_impl.cc

Issue 9015009: Use the new callback tracker and delete the old one (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 18 matching lines...) Expand all
29 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 29 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
30 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" 30 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h"
31 #include "webkit/plugins/ppapi/ppb_url_response_info_impl.h" 31 #include "webkit/plugins/ppapi/ppb_url_response_info_impl.h"
32 #include "webkit/plugins/ppapi/resource_helper.h" 32 #include "webkit/plugins/ppapi/resource_helper.h"
33 33
34 using appcache::WebApplicationCacheHostImpl; 34 using appcache::WebApplicationCacheHostImpl;
35 using ppapi::Resource; 35 using ppapi::Resource;
36 using ppapi::thunk::EnterResourceNoLock; 36 using ppapi::thunk::EnterResourceNoLock;
37 using ppapi::thunk::PPB_URLLoader_API; 37 using ppapi::thunk::PPB_URLLoader_API;
38 using ppapi::thunk::PPB_URLRequestInfo_API; 38 using ppapi::thunk::PPB_URLRequestInfo_API;
39 using ppapi::TrackedCallback;
39 using WebKit::WebFrame; 40 using WebKit::WebFrame;
40 using WebKit::WebString; 41 using WebKit::WebString;
41 using WebKit::WebURL; 42 using WebKit::WebURL;
42 using WebKit::WebURLError; 43 using WebKit::WebURLError;
43 using WebKit::WebURLLoader; 44 using WebKit::WebURLLoader;
44 using WebKit::WebURLLoaderOptions; 45 using WebKit::WebURLLoaderOptions;
45 using WebKit::WebURLRequest; 46 using WebKit::WebURLRequest;
46 using WebKit::WebURLResponse; 47 using WebKit::WebURLResponse;
47 48
48 #ifdef _MSC_VER 49 #ifdef _MSC_VER
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 391 }
391 392
392 void PPB_URLLoader_Impl::RegisterCallback(PP_CompletionCallback callback) { 393 void PPB_URLLoader_Impl::RegisterCallback(PP_CompletionCallback callback) {
393 DCHECK(callback.func); 394 DCHECK(callback.func);
394 DCHECK(!pending_callback_.get() || pending_callback_->completed()); 395 DCHECK(!pending_callback_.get() || pending_callback_->completed());
395 396
396 PluginModule* plugin_module = ResourceHelper::GetPluginModule(this); 397 PluginModule* plugin_module = ResourceHelper::GetPluginModule(this);
397 if (!plugin_module) 398 if (!plugin_module)
398 return; 399 return;
399 400
400 pending_callback_ = new TrackedCompletionCallback( 401 pending_callback_ = new TrackedCallback(this, callback);
401 plugin_module->GetCallbackTracker(), pp_resource(), callback);
402 } 402 }
403 403
404 void PPB_URLLoader_Impl::RunCallback(int32_t result) { 404 void PPB_URLLoader_Impl::RunCallback(int32_t result) {
405 // This may be null only when this is a main document loader. 405 // This may be null only when this is a main document loader.
406 if (!pending_callback_.get()) { 406 if (!pending_callback_.get()) {
407 CHECK(main_document_loader_); 407 CHECK(main_document_loader_);
408 return; 408 return;
409 } 409 }
410 410 TrackedCallback::ClearAndRun(&pending_callback_, result);
411 scoped_refptr<TrackedCompletionCallback> callback;
412 callback.swap(pending_callback_);
413 callback->Run(result); // Will complete abortively if necessary.
414 } 411 }
415 412
416 size_t PPB_URLLoader_Impl::FillUserBuffer() { 413 size_t PPB_URLLoader_Impl::FillUserBuffer() {
417 DCHECK(user_buffer_); 414 DCHECK(user_buffer_);
418 DCHECK(user_buffer_size_); 415 DCHECK(user_buffer_size_);
419 416
420 size_t bytes_to_copy = std::min(buffer_.size(), user_buffer_size_); 417 size_t bytes_to_copy = std::min(buffer_.size(), user_buffer_size_);
421 std::copy(buffer_.begin(), buffer_.begin() + bytes_to_copy, user_buffer_); 418 std::copy(buffer_.begin(), buffer_.begin() + bytes_to_copy, user_buffer_);
422 buffer_.erase(buffer_.begin(), buffer_.begin() + bytes_to_copy); 419 buffer_.erase(buffer_.begin(), buffer_.begin() + bytes_to_copy);
423 420
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 bool PPB_URLLoader_Impl::RecordDownloadProgress() const { 459 bool PPB_URLLoader_Impl::RecordDownloadProgress() const {
463 return request_data_.record_download_progress; 460 return request_data_.record_download_progress;
464 } 461 }
465 462
466 bool PPB_URLLoader_Impl::RecordUploadProgress() const { 463 bool PPB_URLLoader_Impl::RecordUploadProgress() const {
467 return request_data_.record_upload_progress; 464 return request_data_.record_upload_progress;
468 } 465 }
469 466
470 } // namespace ppapi 467 } // namespace ppapi
471 } // namespace webkit 468 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698