| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/renderer/pepper/pepper_url_loader_host.h" | 5 #include "content/renderer/pepper/pepper_url_loader_host.h" |
| 6 | 6 |
| 7 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 7 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 8 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 8 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| 9 #include "content/renderer/pepper/url_request_info_util.h" | 9 #include "content/renderer/pepper/url_request_info_util.h" |
| 10 #include "content/renderer/pepper/url_response_info_util.h" | 10 #include "content/renderer/pepper/url_response_info_util.h" |
| 11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 12 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
| 13 #include "ppapi/host/dispatch_host_message.h" | 13 #include "ppapi/host/dispatch_host_message.h" |
| 14 #include "ppapi/host/host_message_context.h" | 14 #include "ppapi/host/host_message_context.h" |
| 15 #include "ppapi/host/ppapi_host.h" | 15 #include "ppapi/host/ppapi_host.h" |
| 16 #include "ppapi/proxy/ppapi_messages.h" | 16 #include "ppapi/proxy/ppapi_messages.h" |
| 17 #include "ppapi/shared_impl/ppapi_globals.h" | 17 #include "ppapi/shared_impl/ppapi_globals.h" |
| 18 #include "third_party/WebKit/public/platform/WebURLError.h" | 18 #include "third_party/WebKit/public/platform/WebURLError.h" |
| 19 #include "third_party/WebKit/public/platform/WebURLLoader.h" | 19 #include "third_party/WebKit/public/platform/WebURLLoader.h" |
| 20 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 20 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 21 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 21 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 22 #include "third_party/WebKit/public/web/WebDocument.h" | 22 #include "third_party/WebKit/public/web/WebDocument.h" |
| 23 #include "third_party/WebKit/public/web/WebElement.h" | 23 #include "third_party/WebKit/public/web/WebElement.h" |
| 24 #include "third_party/WebKit/public/web/WebFrame.h" | 24 #include "third_party/WebKit/public/web/WebFrame.h" |
| 25 #include "third_party/WebKit/public/web/WebKit.h" | 25 #include "third_party/WebKit/public/web/WebKit.h" |
| 26 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 26 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 27 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 27 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 28 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h" | 28 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h" |
| 29 | 29 |
| 30 using WebKit::WebFrame; | 30 using blink::WebFrame; |
| 31 using WebKit::WebString; | 31 using blink::WebString; |
| 32 using WebKit::WebURL; | 32 using blink::WebURL; |
| 33 using WebKit::WebURLError; | 33 using blink::WebURLError; |
| 34 using WebKit::WebURLLoader; | 34 using blink::WebURLLoader; |
| 35 using WebKit::WebURLLoaderOptions; | 35 using blink::WebURLLoaderOptions; |
| 36 using WebKit::WebURLRequest; | 36 using blink::WebURLRequest; |
| 37 using WebKit::WebURLResponse; | 37 using blink::WebURLResponse; |
| 38 | 38 |
| 39 #ifdef _MSC_VER | 39 #ifdef _MSC_VER |
| 40 // Do not warn about use of std::copy with raw pointers. | 40 // Do not warn about use of std::copy with raw pointers. |
| 41 #pragma warning(disable : 4996) | 41 #pragma warning(disable : 4996) |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 namespace content { | 44 namespace content { |
| 45 | 45 |
| 46 PepperURLLoaderHost::PepperURLLoaderHost(RendererPpapiHostImpl* host, | 46 PepperURLLoaderHost::PepperURLLoaderHost(RendererPpapiHostImpl* host, |
| 47 bool main_document_loader, | 47 bool main_document_loader, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 DCHECK(instance_object->document_loader() == this); | 91 DCHECK(instance_object->document_loader() == this); |
| 92 instance_object->set_document_loader(NULL); | 92 instance_object->set_document_loader(NULL); |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 // There is a path whereby the destructor for the loader_ member can | 96 // There is a path whereby the destructor for the loader_ member can |
| 97 // invoke InstanceWasDeleted() upon this URLLoaderResource, thereby | 97 // invoke InstanceWasDeleted() upon this URLLoaderResource, thereby |
| 98 // re-entering the scoped_ptr destructor with the same scoped_ptr object | 98 // re-entering the scoped_ptr destructor with the same scoped_ptr object |
| 99 // via loader_.reset(). Be sure that loader_ is first NULL then destroy | 99 // via loader_.reset(). Be sure that loader_ is first NULL then destroy |
| 100 // the scoped_ptr. See http://crbug.com/159429. | 100 // the scoped_ptr. See http://crbug.com/159429. |
| 101 scoped_ptr<WebKit::WebURLLoader> for_destruction_only(loader_.release()); | 101 scoped_ptr<blink::WebURLLoader> for_destruction_only(loader_.release()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 int32_t PepperURLLoaderHost::OnResourceMessageReceived( | 104 int32_t PepperURLLoaderHost::OnResourceMessageReceived( |
| 105 const IPC::Message& msg, | 105 const IPC::Message& msg, |
| 106 ppapi::host::HostMessageContext* context) { | 106 ppapi::host::HostMessageContext* context) { |
| 107 IPC_BEGIN_MESSAGE_MAP(PepperURLLoaderHost, msg) | 107 IPC_BEGIN_MESSAGE_MAP(PepperURLLoaderHost, msg) |
| 108 PPAPI_DISPATCH_HOST_RESOURCE_CALL( | 108 PPAPI_DISPATCH_HOST_RESOURCE_CALL( |
| 109 PpapiHostMsg_URLLoader_Open, | 109 PpapiHostMsg_URLLoader_Open, |
| 110 OnHostMsgOpen) | 110 OnHostMsgOpen) |
| 111 PPAPI_DISPATCH_HOST_RESOURCE_CALL( | 111 PPAPI_DISPATCH_HOST_RESOURCE_CALL( |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 360 } |
| 361 } | 361 } |
| 362 | 362 |
| 363 void PepperURLLoaderHost::Close() { | 363 void PepperURLLoaderHost::Close() { |
| 364 if (loader_.get()) | 364 if (loader_.get()) |
| 365 loader_->cancel(); | 365 loader_->cancel(); |
| 366 else if (main_document_loader_) | 366 else if (main_document_loader_) |
| 367 GetFrame()->stopLoading(); | 367 GetFrame()->stopLoading(); |
| 368 } | 368 } |
| 369 | 369 |
| 370 WebKit::WebFrame* PepperURLLoaderHost::GetFrame() { | 370 blink::WebFrame* PepperURLLoaderHost::GetFrame() { |
| 371 PepperPluginInstance* instance_object = | 371 PepperPluginInstance* instance_object = |
| 372 renderer_ppapi_host_->GetPluginInstance(pp_instance()); | 372 renderer_ppapi_host_->GetPluginInstance(pp_instance()); |
| 373 if (!instance_object) | 373 if (!instance_object) |
| 374 return NULL; | 374 return NULL; |
| 375 return instance_object->GetContainer()->element().document().frame(); | 375 return instance_object->GetContainer()->element().document().frame(); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void PepperURLLoaderHost::SetDefersLoading(bool defers_loading) { | 378 void PepperURLLoaderHost::SetDefersLoading(bool defers_loading) { |
| 379 if (loader_.get()) | 379 if (loader_.get()) |
| 380 loader_->setDefersLoading(defers_loading); | 380 loader_->setDefersLoading(defers_loading); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 ppapi::proxy::ResourceMessageReplyParams params; | 422 ppapi::proxy::ResourceMessageReplyParams params; |
| 423 SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_UpdateProgress( | 423 SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_UpdateProgress( |
| 424 record_upload ? bytes_sent_ : -1, | 424 record_upload ? bytes_sent_ : -1, |
| 425 record_upload ? total_bytes_to_be_sent_ : -1, | 425 record_upload ? total_bytes_to_be_sent_ : -1, |
| 426 record_download ? bytes_received_ : -1, | 426 record_download ? bytes_received_ : -1, |
| 427 record_download ? total_bytes_to_be_received_ : -1)); | 427 record_download ? total_bytes_to_be_received_ : -1)); |
| 428 } | 428 } |
| 429 } | 429 } |
| 430 | 430 |
| 431 } // namespace content | 431 } // namespace content |
| OLD | NEW |