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

Side by Side Diff: content/renderer/pepper/pepper_url_loader_host.cc

Issue 19744007: Create a public API around webkit::ppapi::PluginInstance and use it in chrome. After this, webkit/p… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments and undo checkdeps change Created 7 years, 5 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) 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/public/renderer/renderer_ppapi_host.h" 7 #include "content/renderer/pepper/renderer_ppapi_host_impl.h"
8 #include "content/renderer/pepper/url_response_info_util.h" 8 #include "content/renderer/pepper/url_response_info_util.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
11 #include "ppapi/host/dispatch_host_message.h" 11 #include "ppapi/host/dispatch_host_message.h"
12 #include "ppapi/host/host_message_context.h" 12 #include "ppapi/host/host_message_context.h"
13 #include "ppapi/host/ppapi_host.h" 13 #include "ppapi/host/ppapi_host.h"
14 #include "ppapi/proxy/ppapi_messages.h" 14 #include "ppapi/proxy/ppapi_messages.h"
15 #include "ppapi/shared_impl/ppapi_globals.h" 15 #include "ppapi/shared_impl/ppapi_globals.h"
16 #include "third_party/WebKit/public/platform/WebURLError.h" 16 #include "third_party/WebKit/public/platform/WebURLError.h"
17 #include "third_party/WebKit/public/platform/WebURLLoader.h" 17 #include "third_party/WebKit/public/platform/WebURLLoader.h"
18 #include "third_party/WebKit/public/platform/WebURLRequest.h" 18 #include "third_party/WebKit/public/platform/WebURLRequest.h"
19 #include "third_party/WebKit/public/platform/WebURLResponse.h" 19 #include "third_party/WebKit/public/platform/WebURLResponse.h"
20 #include "third_party/WebKit/public/web/WebDocument.h" 20 #include "third_party/WebKit/public/web/WebDocument.h"
21 #include "third_party/WebKit/public/web/WebElement.h" 21 #include "third_party/WebKit/public/web/WebElement.h"
22 #include "third_party/WebKit/public/web/WebFrame.h" 22 #include "third_party/WebKit/public/web/WebFrame.h"
23 #include "third_party/WebKit/public/web/WebKit.h" 23 #include "third_party/WebKit/public/web/WebKit.h"
24 #include "third_party/WebKit/public/web/WebPluginContainer.h" 24 #include "third_party/WebKit/public/web/WebPluginContainer.h"
25 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 25 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
26 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h" 26 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h"
27 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 27 #include "webkit/plugins/ppapi/ppapi_plugin_instance_impl.h"
28 #include "webkit/plugins/ppapi/url_request_info_util.h" 28 #include "webkit/plugins/ppapi/url_request_info_util.h"
29 29
30 using WebKit::WebFrame; 30 using WebKit::WebFrame;
31 using WebKit::WebString; 31 using WebKit::WebString;
32 using WebKit::WebURL; 32 using WebKit::WebURL;
33 using WebKit::WebURLError; 33 using WebKit::WebURLError;
34 using WebKit::WebURLLoader; 34 using WebKit::WebURLLoader;
35 using WebKit::WebURLLoaderOptions; 35 using WebKit::WebURLLoaderOptions;
36 using WebKit::WebURLRequest; 36 using WebKit::WebURLRequest;
37 using WebKit::WebURLResponse; 37 using WebKit::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(RendererPpapiHost* host, 46 PepperURLLoaderHost::PepperURLLoaderHost(RendererPpapiHostImpl* host,
47 bool main_document_loader, 47 bool main_document_loader,
48 PP_Instance instance, 48 PP_Instance instance,
49 PP_Resource resource) 49 PP_Resource resource)
50 : ResourceHost(host->GetPpapiHost(), instance, resource), 50 : ResourceHost(host->GetPpapiHost(), instance, resource),
51 renderer_ppapi_host_(host), 51 renderer_ppapi_host_(host),
52 main_document_loader_(main_document_loader), 52 main_document_loader_(main_document_loader),
53 has_universal_access_(false), 53 has_universal_access_(false),
54 bytes_sent_(0), 54 bytes_sent_(0),
55 total_bytes_to_be_sent_(-1), 55 total_bytes_to_be_sent_(-1),
56 bytes_received_(0), 56 bytes_received_(0),
(...skipping 19 matching lines...) Expand all
76 // we don't want to cancel other loads when the main one is closed. 76 // we don't want to cancel other loads when the main one is closed.
77 // 77 //
78 // "Leaking" the main document load here by not closing it will only affect 78 // "Leaking" the main document load here by not closing it will only affect
79 // plugins handling main document loads (which are very few, mostly only PDF) 79 // plugins handling main document loads (which are very few, mostly only PDF)
80 // that dereference without explicitly closing the main document load (which 80 // that dereference without explicitly closing the main document load (which
81 // PDF doesn't do -- it explicitly closes it before issuing the second 81 // PDF doesn't do -- it explicitly closes it before issuing the second
82 // request). And the worst thing that will happen is that any remaining data 82 // request). And the worst thing that will happen is that any remaining data
83 // will get queued inside WebKit. 83 // will get queued inside WebKit.
84 if (main_document_loader_) { 84 if (main_document_loader_) {
85 // The PluginInstance has a non-owning pointer to us. 85 // The PluginInstance has a non-owning pointer to us.
86 webkit::ppapi::PluginInstance* instance_object = 86 webkit::ppapi::PluginInstanceImpl* instance_object =
87 renderer_ppapi_host_->GetPluginInstance(pp_instance()); 87 renderer_ppapi_host_->GetPluginInstanceImpl(pp_instance());
88 if (instance_object) { 88 if (instance_object) {
89 DCHECK(instance_object->document_loader() == this); 89 DCHECK(instance_object->document_loader() == this);
90 instance_object->set_document_loader(NULL); 90 instance_object->set_document_loader(NULL);
91 } 91 }
92 } 92 }
93 93
94 // There is a path whereby the destructor for the loader_ member can 94 // There is a path whereby the destructor for the loader_ member can
95 // invoke InstanceWasDeleted() upon this URLLoaderResource, thereby 95 // invoke InstanceWasDeleted() upon this URLLoaderResource, thereby
96 // re-entering the scoped_ptr destructor with the same scoped_ptr object 96 // re-entering the scoped_ptr destructor with the same scoped_ptr object
97 // via loader_.reset(). Be sure that loader_ is first NULL then destroy 97 // via loader_.reset(). Be sure that loader_ is first NULL then destroy
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 loader_->cancel(); 328 loader_->cancel();
329 else if (main_document_loader_) 329 else if (main_document_loader_)
330 GetFrame()->stopLoading(); 330 GetFrame()->stopLoading();
331 } 331 }
332 332
333 WebKit::WebFrame* PepperURLLoaderHost::GetFrame() { 333 WebKit::WebFrame* PepperURLLoaderHost::GetFrame() {
334 webkit::ppapi::PluginInstance* instance_object = 334 webkit::ppapi::PluginInstance* instance_object =
335 renderer_ppapi_host_->GetPluginInstance(pp_instance()); 335 renderer_ppapi_host_->GetPluginInstance(pp_instance());
336 if (!instance_object) 336 if (!instance_object)
337 return NULL; 337 return NULL;
338 return instance_object->container()->element().document().frame(); 338 return instance_object->GetContainer()->element().document().frame();
339 } 339 }
340 340
341 void PepperURLLoaderHost::SetDefersLoading(bool defers_loading) { 341 void PepperURLLoaderHost::SetDefersLoading(bool defers_loading) {
342 if (loader_.get()) 342 if (loader_.get())
343 loader_->setDefersLoading(defers_loading); 343 loader_->setDefersLoading(defers_loading);
344 344
345 // TODO(brettw) bug 96770: We need a way to set the defers loading flag on 345 // TODO(brettw) bug 96770: We need a way to set the defers loading flag on
346 // main document loads (when the loader_ is null). 346 // main document loads (when the loader_ is null).
347 } 347 }
348 348
(...skipping 22 matching lines...) Expand all
371 ppapi::proxy::ResourceMessageReplyParams params; 371 ppapi::proxy::ResourceMessageReplyParams params;
372 SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_UpdateProgress( 372 SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_UpdateProgress(
373 record_upload ? bytes_sent_ : -1, 373 record_upload ? bytes_sent_ : -1,
374 record_upload ? total_bytes_to_be_sent_ : -1, 374 record_upload ? total_bytes_to_be_sent_ : -1,
375 record_download ? bytes_received_ : -1, 375 record_download ? bytes_received_ : -1,
376 record_download ? total_bytes_to_be_received_ : -1)); 376 record_download ? total_bytes_to_be_received_ : -1));
377 } 377 }
378 } 378 }
379 379
380 } // namespace content 380 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_url_loader_host.h ('k') | content/renderer/pepper/pepper_video_capture_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698