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

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

Issue 14371021: Implementation of URLLoader using PluginResource/ResourceHost. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase, track src/webkit gypi changes. Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_plugin_delegate_impl.h" 5 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <cstddef> 8 #include <cstddef>
9 #include <map> 9 #include <map>
10 #include <queue> 10 #include <queue>
(...skipping 28 matching lines...) Expand all
39 #include "content/renderer/gamepad_shared_memory_reader.h" 39 #include "content/renderer/gamepad_shared_memory_reader.h"
40 #include "content/renderer/media/media_stream_dispatcher.h" 40 #include "content/renderer/media/media_stream_dispatcher.h"
41 #include "content/renderer/media/pepper_platform_video_decoder_impl.h" 41 #include "content/renderer/media/pepper_platform_video_decoder_impl.h"
42 #include "content/renderer/p2p/socket_dispatcher.h" 42 #include "content/renderer/p2p/socket_dispatcher.h"
43 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h" 43 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h"
44 #include "content/renderer/pepper/pepper_broker_impl.h" 44 #include "content/renderer/pepper/pepper_broker_impl.h"
45 #include "content/renderer/pepper/pepper_device_enumeration_event_handler.h" 45 #include "content/renderer/pepper/pepper_device_enumeration_event_handler.h"
46 #include "content/renderer/pepper/pepper_file_system_host.h" 46 #include "content/renderer/pepper/pepper_file_system_host.h"
47 #include "content/renderer/pepper/pepper_hung_plugin_filter.h" 47 #include "content/renderer/pepper/pepper_hung_plugin_filter.h"
48 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" 48 #include "content/renderer/pepper/pepper_in_process_resource_creation.h"
49 #include "content/renderer/pepper/pepper_in_process_router.h"
49 #include "content/renderer/pepper/pepper_platform_audio_input_impl.h" 50 #include "content/renderer/pepper/pepper_platform_audio_input_impl.h"
50 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h" 51 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h"
51 #include "content/renderer/pepper/pepper_platform_context_3d_impl.h" 52 #include "content/renderer/pepper/pepper_platform_context_3d_impl.h"
52 #include "content/renderer/pepper/pepper_platform_image_2d_impl.h" 53 #include "content/renderer/pepper/pepper_platform_image_2d_impl.h"
53 #include "content/renderer/pepper/pepper_platform_video_capture_impl.h" 54 #include "content/renderer/pepper/pepper_platform_video_capture_impl.h"
54 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h" 55 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h"
56 #include "content/renderer/pepper/pepper_url_loader_host.h"
55 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" 57 #include "content/renderer/pepper/renderer_ppapi_host_impl.h"
56 #include "content/renderer/render_thread_impl.h" 58 #include "content/renderer/render_thread_impl.h"
57 #include "content/renderer/render_view_impl.h" 59 #include "content/renderer/render_view_impl.h"
58 #include "content/renderer/render_widget_fullscreen_pepper.h" 60 #include "content/renderer/render_widget_fullscreen_pepper.h"
59 #include "content/renderer/webplugin_delegate_proxy.h" 61 #include "content/renderer/webplugin_delegate_proxy.h"
60 #include "googleurl/src/gurl.h" 62 #include "googleurl/src/gurl.h"
61 #include "ipc/ipc_channel_handle.h" 63 #include "ipc/ipc_channel_handle.h"
62 #include "media/base/audio_hardware_config.h" 64 #include "media/base/audio_hardware_config.h"
63 #include "media/video/capture/video_capture_proxy.h" 65 #include "media/video/capture/video_capture_proxy.h"
64 #include "ppapi/c/dev/pp_video_dev.h" 66 #include "ppapi/c/dev/pp_video_dev.h"
65 #include "ppapi/c/pp_errors.h" 67 #include "ppapi/c/pp_errors.h"
66 #include "ppapi/c/private/ppb_flash.h" 68 #include "ppapi/c/private/ppb_flash.h"
67 #include "ppapi/host/ppapi_host.h" 69 #include "ppapi/host/ppapi_host.h"
68 #include "ppapi/proxy/host_dispatcher.h" 70 #include "ppapi/proxy/host_dispatcher.h"
69 #include "ppapi/proxy/ppapi_messages.h" 71 #include "ppapi/proxy/ppapi_messages.h"
72 #include "ppapi/proxy/url_loader_resource.h"
73 #include "ppapi/shared_impl/api_id.h"
70 #include "ppapi/shared_impl/file_path.h" 74 #include "ppapi/shared_impl/file_path.h"
71 #include "ppapi/shared_impl/platform_file.h" 75 #include "ppapi/shared_impl/platform_file.h"
76 #include "ppapi/shared_impl/ppapi_globals.h"
72 #include "ppapi/shared_impl/ppapi_permissions.h" 77 #include "ppapi/shared_impl/ppapi_permissions.h"
73 #include "ppapi/shared_impl/ppapi_preferences.h" 78 #include "ppapi/shared_impl/ppapi_preferences.h"
74 #include "ppapi/shared_impl/ppb_device_ref_shared.h" 79 #include "ppapi/shared_impl/ppb_device_ref_shared.h"
80 #include "ppapi/shared_impl/ppp_instance_combined.h"
81 #include "ppapi/shared_impl/resource_tracker.h"
75 #include "ppapi/thunk/enter.h" 82 #include "ppapi/thunk/enter.h"
76 #include "ppapi/thunk/ppb_tcp_server_socket_private_api.h" 83 #include "ppapi/thunk/ppb_tcp_server_socket_private_api.h"
77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" 84 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 85 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
79 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 86 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
80 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 87 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
81 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 88 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
82 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 89 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
83 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" 90 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
84 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
85 #include "ui/gfx/size.h" 92 #include "ui/gfx/size.h"
86 #include "webkit/fileapi/file_system_callback_dispatcher.h" 93 #include "webkit/fileapi/file_system_callback_dispatcher.h"
87 #include "webkit/plugins/npapi/webplugin.h" 94 #include "webkit/plugins/npapi/webplugin.h"
88 #include "webkit/plugins/ppapi/plugin_module.h" 95 #include "webkit/plugins/ppapi/plugin_module.h"
89 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 96 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
90 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" 97 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h"
91 #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h" 98 #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h"
92 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h" 99 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h"
93 #include "webkit/plugins/ppapi/resource_helper.h" 100 #include "webkit/plugins/ppapi/resource_helper.h"
101 #include "webkit/plugins/ppapi/url_response_info_util.h"
94 #include "webkit/plugins/webplugininfo.h" 102 #include "webkit/plugins/webplugininfo.h"
95 103
96 using WebKit::WebView; 104 using WebKit::WebView;
97 using WebKit::WebFrame; 105 using WebKit::WebFrame;
98 106
99 namespace content { 107 namespace content {
100 108
101 namespace { 109 namespace {
102 110
103 // This class wraps a dispatcher and has the same lifetime. A dispatcher has 111 // This class wraps a dispatcher and has the same lifetime. A dispatcher has
(...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 } 1336 }
1329 1337
1330 void PepperPluginDelegateImpl::SaveURLAs(const GURL& url) { 1338 void PepperPluginDelegateImpl::SaveURLAs(const GURL& url) {
1331 WebFrame* frame = render_view_->webview()->mainFrame(); 1339 WebFrame* frame = render_view_->webview()->mainFrame();
1332 Referrer referrer(frame->document().url(), 1340 Referrer referrer(frame->document().url(),
1333 frame->document().referrerPolicy()); 1341 frame->document().referrerPolicy());
1334 render_view_->Send(new ViewHostMsg_SaveURLAs( 1342 render_view_->Send(new ViewHostMsg_SaveURLAs(
1335 render_view_->routing_id(), url, referrer)); 1343 render_view_->routing_id(), url, referrer));
1336 } 1344 }
1337 1345
1346 void PepperPluginDelegateImpl::HandleDocumentLoad(
1347 webkit::ppapi::PluginInstance* instance,
1348 const WebKit::WebURLResponse& response) {
1349 DCHECK(!instance->document_loader());
1350
1351 PP_Instance pp_instance = instance->pp_instance();
1352 RendererPpapiHostImpl* host_impl = static_cast<RendererPpapiHostImpl*>(
1353 instance->module()->GetEmbedderState());
1354
1355 // Create a loader resource host for this load. Note that we have to set
1356 // the document_loader before issuing the in-process
1357 // PPP_Instance.HandleDocumentLoad call below, since this may reentrantly
1358 // call into the instance and expect it to be valid.
1359 PepperURLLoaderHost* loader_host =
1360 new PepperURLLoaderHost(host_impl, true, pp_instance, 0);
1361 instance->set_document_loader(loader_host);
1362 loader_host->didReceiveResponse(NULL, response);
1363
1364 // This host will be pending until the resource object attaches to it.
1365 int pending_host_id = host_impl->GetPpapiHost()->AddPendingResourceHost(
1366 scoped_ptr<ppapi::host::ResourceHost>(loader_host));
1367 DCHECK(pending_host_id);
1368 ppapi::URLResponseInfoData data =
1369 webkit::ppapi::DataFromWebURLResponse(pp_instance, response);
1370
1371 if (host_impl->in_process_router()) {
1372 // Running in-process, we can just create the resource and call the
1373 // PPP_Instance function directly.
1374 scoped_refptr<ppapi::proxy::URLLoaderResource> loader_resource(
1375 new ppapi::proxy::URLLoaderResource(
1376 host_impl->in_process_router()->GetPluginConnection(),
1377 pp_instance, pending_host_id, data));
1378
1379 PP_Resource loader_pp_resource = loader_resource->GetReference();
1380 if (!instance->instance_interface()->HandleDocumentLoad(
1381 instance->pp_instance(), loader_pp_resource))
1382 loader_resource->Close();
1383 // We don't pass a ref into the plugin, if it wants one, it will have taken
1384 // an additional one.
1385 ppapi::PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(
1386 loader_pp_resource);
1387
1388 // Danger! If the plugin doesn't take a ref in HandleDocumentLoad, the
1389 // resource host will be destroyed as soon as our scoped_refptr for the
1390 // resource goes out of scope.
1391 //
1392 // Null it out so people don't accidentally add code below that uses it.
1393 loader_host = NULL;
1394 } else {
1395 // Running out-of-process. Initiate an IPC call to notify the plugin
1396 // process.
1397 ppapi::proxy::HostDispatcher* dispatcher =
1398 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance);
1399 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad(
1400 ppapi::API_ID_PPP_INSTANCE, pp_instance, pending_host_id, data));
1401 }
1402 }
1403
1338 base::SharedMemory* PepperPluginDelegateImpl::CreateAnonymousSharedMemory( 1404 base::SharedMemory* PepperPluginDelegateImpl::CreateAnonymousSharedMemory(
1339 size_t size) { 1405 size_t size) {
1340 return RenderThread::Get()->HostAllocateSharedMemoryBuffer(size).release(); 1406 return RenderThread::Get()->HostAllocateSharedMemoryBuffer(size).release();
1341 } 1407 }
1342 1408
1343 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { 1409 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() {
1344 return ppapi::Preferences(render_view_->webkit_preferences()); 1410 return ppapi::Preferences(render_view_->webkit_preferences());
1345 } 1411 }
1346 1412
1347 bool PepperPluginDelegateImpl::LockMouse( 1413 bool PepperPluginDelegateImpl::LockMouse(
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 should_close_source); 1716 should_close_source);
1651 } 1717 }
1652 1718
1653 bool PepperPluginDelegateImpl::IsRunningInProcess(PP_Instance instance) const { 1719 bool PepperPluginDelegateImpl::IsRunningInProcess(PP_Instance instance) const {
1654 RendererPpapiHostImpl* host = 1720 RendererPpapiHostImpl* host =
1655 RendererPpapiHostImpl::GetForPPInstance(instance); 1721 RendererPpapiHostImpl::GetForPPInstance(instance);
1656 return host && host->IsRunningInProcess(); 1722 return host && host->IsRunningInProcess();
1657 } 1723 }
1658 1724
1659 } // namespace content 1725 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_plugin_delegate_impl.h ('k') | content/renderer/pepper/pepper_url_loader_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698