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

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: 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/public/renderer/renderer_ppapi_host.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;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 static_cast<webkit::ppapi::PluginInstanceImpl*>(
88 renderer_ppapi_host_->GetPluginInstance(pp_instance()));
88 if (instance_object) { 89 if (instance_object) {
89 DCHECK(instance_object->document_loader() == this); 90 DCHECK(instance_object->document_loader() == this);
90 instance_object->set_document_loader(NULL); 91 instance_object->set_document_loader(NULL);
91 } 92 }
92 } 93 }
93 94
94 // There is a path whereby the destructor for the loader_ member can 95 // There is a path whereby the destructor for the loader_ member can
95 // invoke InstanceWasDeleted() upon this URLLoaderResource, thereby 96 // invoke InstanceWasDeleted() upon this URLLoaderResource, thereby
96 // re-entering the scoped_ptr destructor with the same scoped_ptr object 97 // 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 98 // 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(); 329 loader_->cancel();
329 else if (main_document_loader_) 330 else if (main_document_loader_)
330 GetFrame()->stopLoading(); 331 GetFrame()->stopLoading();
331 } 332 }
332 333
333 WebKit::WebFrame* PepperURLLoaderHost::GetFrame() { 334 WebKit::WebFrame* PepperURLLoaderHost::GetFrame() {
334 webkit::ppapi::PluginInstance* instance_object = 335 webkit::ppapi::PluginInstance* instance_object =
335 renderer_ppapi_host_->GetPluginInstance(pp_instance()); 336 renderer_ppapi_host_->GetPluginInstance(pp_instance());
336 if (!instance_object) 337 if (!instance_object)
337 return NULL; 338 return NULL;
338 return instance_object->container()->element().document().frame(); 339 return instance_object->GetContainer()->element().document().frame();
339 } 340 }
340 341
341 void PepperURLLoaderHost::SetDefersLoading(bool defers_loading) { 342 void PepperURLLoaderHost::SetDefersLoading(bool defers_loading) {
342 if (loader_.get()) 343 if (loader_.get())
343 loader_->setDefersLoading(defers_loading); 344 loader_->setDefersLoading(defers_loading);
344 345
345 // TODO(brettw) bug 96770: We need a way to set the defers loading flag on 346 // TODO(brettw) bug 96770: We need a way to set the defers loading flag on
346 // main document loads (when the loader_ is null). 347 // main document loads (when the loader_ is null).
347 } 348 }
348 349
(...skipping 22 matching lines...) Expand all
371 ppapi::proxy::ResourceMessageReplyParams params; 372 ppapi::proxy::ResourceMessageReplyParams params;
372 SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_UpdateProgress( 373 SendUpdateToPlugin(new PpapiPluginMsg_URLLoader_UpdateProgress(
373 record_upload ? bytes_sent_ : -1, 374 record_upload ? bytes_sent_ : -1,
374 record_upload ? total_bytes_to_be_sent_ : -1, 375 record_upload ? total_bytes_to_be_sent_ : -1,
375 record_download ? bytes_received_ : -1, 376 record_download ? bytes_received_ : -1,
376 record_download ? total_bytes_to_be_received_ : -1)); 377 record_download ? total_bytes_to_be_received_ : -1));
377 } 378 }
378 } 379 }
379 380
380 } // namespace content 381 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698