| Index: webkit/plugins/ppapi/ppb_url_loader_impl.cc
|
| diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.cc b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
|
| index 95349b7a433fd6b407fbb14f5694e894e45cd2a2..3ae1676b044eed497548976dcf61b931a3b9125f 100644
|
| --- a/webkit/plugins/ppapi/ppb_url_loader_impl.cc
|
| +++ b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
|
| @@ -29,8 +29,10 @@
|
| #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
|
| #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h"
|
| #include "webkit/plugins/ppapi/ppb_url_response_info_impl.h"
|
| +#include "webkit/plugins/ppapi/resource_helper.h"
|
|
|
| using appcache::WebApplicationCacheHostImpl;
|
| +using ppapi::Resource;
|
| using ppapi::thunk::EnterResourceNoLock;
|
| using ppapi::thunk::PPB_URLLoader_API;
|
| using ppapi::thunk::PPB_URLRequestInfo_API;
|
| @@ -51,7 +53,16 @@ using WebKit::WebURLResponse;
|
| namespace webkit {
|
| namespace ppapi {
|
|
|
| -PPB_URLLoader_Impl::PPB_URLLoader_Impl(PluginInstance* instance,
|
| +namespace {
|
| +
|
| +WebFrame* GetFrameForResource(const Resource* resource) {
|
| + return ResourceHelper::GetPluginInstance(resource)->
|
| + container()->element().document().frame();
|
| +}
|
| +
|
| +}
|
| +
|
| +PPB_URLLoader_Impl::PPB_URLLoader_Impl(PP_Instance instance,
|
| bool main_document_loader)
|
| : Resource(instance),
|
| main_document_loader_(main_document_loader),
|
| @@ -99,7 +110,7 @@ int32_t PPB_URLLoader_Impl::Open(PP_Resource request_id,
|
| if (loader_.get())
|
| return PP_ERROR_INPROGRESS;
|
|
|
| - WebFrame* frame = instance()->container()->element().document().frame();
|
| + WebFrame* frame = GetFrameForResource(this);
|
| if (!frame)
|
| return PP_ERROR_FAILED;
|
| WebURLRequest web_request(request->ToWebURLRequest(frame));
|
| @@ -226,12 +237,10 @@ int32_t PPB_URLLoader_Impl::FinishStreamingToFile(
|
| }
|
|
|
| void PPB_URLLoader_Impl::Close() {
|
| - if (loader_.get()) {
|
| + if (loader_.get())
|
| loader_->cancel();
|
| - } else if (main_document_loader_) {
|
| - WebFrame* frame = instance()->container()->element().document().frame();
|
| - frame->stopLoading();
|
| - }
|
| + else if (main_document_loader_)
|
| + GetFrameForResource(this)->stopLoading();
|
| // TODO(viettrungluu): Check what happens to the callback (probably the
|
| // wrong thing). May need to post abort here. crbug.com/69457
|
| }
|
| @@ -363,7 +372,8 @@ void PPB_URLLoader_Impl::RegisterCallback(PP_CompletionCallback callback) {
|
| DCHECK(!pending_callback_.get() || pending_callback_->completed());
|
|
|
| pending_callback_ = new TrackedCompletionCallback(
|
| - instance()->module()->GetCallbackTracker(), pp_resource(), callback);
|
| + ResourceHelper::GetPluginModule(this)->GetCallbackTracker(),
|
| + pp_resource(), callback);
|
| }
|
|
|
| void PPB_URLLoader_Impl::RunCallback(int32_t result) {
|
| @@ -404,7 +414,7 @@ size_t PPB_URLLoader_Impl::FillUserBuffer() {
|
|
|
| void PPB_URLLoader_Impl::SaveResponse(const WebURLResponse& response) {
|
| scoped_refptr<PPB_URLResponseInfo_Impl> response_info(
|
| - new PPB_URLResponseInfo_Impl(instance()));
|
| + new PPB_URLResponseInfo_Impl(pp_instance()));
|
| if (response_info->Initialize(response))
|
| response_info_ = response_info;
|
| }
|
| @@ -418,7 +428,7 @@ void PPB_URLLoader_Impl::UpdateStatus() {
|
| // getting download progress when they happen to set the upload progress
|
| // flag.
|
| status_callback_(
|
| - instance()->pp_instance(), pp_resource(),
|
| + pp_instance(), pp_resource(),
|
| RecordUploadProgress() ? bytes_sent_ : -1,
|
| RecordUploadProgress() ? total_bytes_to_be_sent_ : -1,
|
| RecordDownloadProgress() ? bytes_received_ : -1,
|
|
|