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

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

Issue 11416064: Convert URLLoader to the new proxy design (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments, merge Created 8 years 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) 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 26 matching lines...) Expand all
37 #include "content/renderer/gamepad_shared_memory_reader.h" 37 #include "content/renderer/gamepad_shared_memory_reader.h"
38 #include "content/renderer/media/audio_hardware.h" 38 #include "content/renderer/media/audio_hardware.h"
39 #include "content/renderer/media/media_stream_dispatcher.h" 39 #include "content/renderer/media/media_stream_dispatcher.h"
40 #include "content/renderer/media/pepper_platform_video_decoder_impl.h" 40 #include "content/renderer/media/pepper_platform_video_decoder_impl.h"
41 #include "content/renderer/p2p/socket_dispatcher.h" 41 #include "content/renderer/p2p/socket_dispatcher.h"
42 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h" 42 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h"
43 #include "content/renderer/pepper/pepper_broker_impl.h" 43 #include "content/renderer/pepper/pepper_broker_impl.h"
44 #include "content/renderer/pepper/pepper_device_enumeration_event_handler.h" 44 #include "content/renderer/pepper/pepper_device_enumeration_event_handler.h"
45 #include "content/renderer/pepper/pepper_hung_plugin_filter.h" 45 #include "content/renderer/pepper/pepper_hung_plugin_filter.h"
46 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" 46 #include "content/renderer/pepper/pepper_in_process_resource_creation.h"
47 #include "content/renderer/pepper/pepper_in_process_router.h"
47 #include "content/renderer/pepper/pepper_platform_audio_input_impl.h" 48 #include "content/renderer/pepper/pepper_platform_audio_input_impl.h"
48 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h" 49 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h"
49 #include "content/renderer/pepper/pepper_platform_context_3d_impl.h" 50 #include "content/renderer/pepper/pepper_platform_context_3d_impl.h"
50 #include "content/renderer/pepper/pepper_platform_image_2d_impl.h" 51 #include "content/renderer/pepper/pepper_platform_image_2d_impl.h"
51 #include "content/renderer/pepper/pepper_platform_video_capture_impl.h" 52 #include "content/renderer/pepper/pepper_platform_video_capture_impl.h"
52 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h" 53 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h"
54 #include "content/renderer/pepper/pepper_url_loader_host.h"
53 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" 55 #include "content/renderer/pepper/renderer_ppapi_host_impl.h"
54 #include "content/renderer/render_thread_impl.h" 56 #include "content/renderer/render_thread_impl.h"
55 #include "content/renderer/render_view_impl.h" 57 #include "content/renderer/render_view_impl.h"
56 #include "content/renderer/render_widget_fullscreen_pepper.h" 58 #include "content/renderer/render_widget_fullscreen_pepper.h"
57 #include "content/renderer/webplugin_delegate_proxy.h" 59 #include "content/renderer/webplugin_delegate_proxy.h"
58 #include "googleurl/src/gurl.h" 60 #include "googleurl/src/gurl.h"
59 #include "ipc/ipc_channel_handle.h" 61 #include "ipc/ipc_channel_handle.h"
60 #include "media/video/capture/video_capture_proxy.h" 62 #include "media/video/capture/video_capture_proxy.h"
61 #include "ppapi/c/dev/pp_video_dev.h" 63 #include "ppapi/c/dev/pp_video_dev.h"
62 #include "ppapi/c/pp_errors.h" 64 #include "ppapi/c/pp_errors.h"
63 #include "ppapi/c/private/ppb_flash.h" 65 #include "ppapi/c/private/ppb_flash.h"
64 #include "ppapi/host/ppapi_host.h" 66 #include "ppapi/host/ppapi_host.h"
65 #include "ppapi/proxy/host_dispatcher.h" 67 #include "ppapi/proxy/host_dispatcher.h"
66 #include "ppapi/proxy/ppapi_messages.h" 68 #include "ppapi/proxy/ppapi_messages.h"
69 #include "ppapi/proxy/url_loader_resource.h"
70 #include "ppapi/shared_impl/api_id.h"
67 #include "ppapi/shared_impl/file_path.h" 71 #include "ppapi/shared_impl/file_path.h"
68 #include "ppapi/shared_impl/platform_file.h" 72 #include "ppapi/shared_impl/platform_file.h"
73 #include "ppapi/shared_impl/ppapi_globals.h"
69 #include "ppapi/shared_impl/ppapi_permissions.h" 74 #include "ppapi/shared_impl/ppapi_permissions.h"
70 #include "ppapi/shared_impl/ppapi_preferences.h" 75 #include "ppapi/shared_impl/ppapi_preferences.h"
71 #include "ppapi/shared_impl/ppb_device_ref_shared.h" 76 #include "ppapi/shared_impl/ppb_device_ref_shared.h"
77 #include "ppapi/shared_impl/ppp_instance_combined.h"
78 #include "ppapi/shared_impl/resource_tracker.h"
72 #include "ppapi/thunk/enter.h" 79 #include "ppapi/thunk/enter.h"
73 #include "ppapi/thunk/ppb_tcp_server_socket_private_api.h" 80 #include "ppapi/thunk/ppb_tcp_server_socket_private_api.h"
74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" 81 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 82 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
76 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 83 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 84 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 85 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
79 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" 86 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
80 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 87 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
81 #include "ui/gfx/size.h" 88 #include "ui/gfx/size.h"
82 #include "webkit/fileapi/file_system_callback_dispatcher.h" 89 #include "webkit/fileapi/file_system_callback_dispatcher.h"
83 #include "webkit/plugins/npapi/webplugin.h" 90 #include "webkit/plugins/npapi/webplugin.h"
84 #include "webkit/plugins/ppapi/plugin_module.h" 91 #include "webkit/plugins/ppapi/plugin_module.h"
85 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 92 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
86 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" 93 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h"
87 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" 94 #include "webkit/plugins/ppapi/ppb_file_io_impl.h"
88 #include "webkit/plugins/ppapi/ppb_flash_impl.h" 95 #include "webkit/plugins/ppapi/ppb_flash_impl.h"
89 #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h" 96 #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h"
90 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h" 97 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h"
91 #include "webkit/plugins/ppapi/ppb_udp_socket_private_impl.h" 98 #include "webkit/plugins/ppapi/ppb_udp_socket_private_impl.h"
92 #include "webkit/plugins/ppapi/resource_helper.h" 99 #include "webkit/plugins/ppapi/resource_helper.h"
100 #include "webkit/plugins/ppapi/url_response_info_util.h"
93 #include "webkit/plugins/webplugininfo.h" 101 #include "webkit/plugins/webplugininfo.h"
94 102
95 using WebKit::WebView; 103 using WebKit::WebView;
96 using WebKit::WebFrame; 104 using WebKit::WebFrame;
97 105
98 namespace content { 106 namespace content {
99 107
100 namespace { 108 namespace {
101 109
102 // This class wraps a dispatcher and has the same lifetime. A dispatcher has 110 // This class wraps a dispatcher and has the same lifetime. A dispatcher has
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 PP_FlashLSORestrictions PepperPluginDelegateImpl::GetLocalDataRestrictions( 1375 PP_FlashLSORestrictions PepperPluginDelegateImpl::GetLocalDataRestrictions(
1368 const GURL& document_url, 1376 const GURL& document_url,
1369 const GURL& plugin_url) { 1377 const GURL& plugin_url) {
1370 PP_FlashLSORestrictions restrictions = PP_FLASHLSORESTRICTIONS_NONE; 1378 PP_FlashLSORestrictions restrictions = PP_FLASHLSORESTRICTIONS_NONE;
1371 render_view_->Send( 1379 render_view_->Send(
1372 new PepperMsg_GetLocalDataRestrictions(document_url, plugin_url, 1380 new PepperMsg_GetLocalDataRestrictions(document_url, plugin_url,
1373 &restrictions)); 1381 &restrictions));
1374 return restrictions; 1382 return restrictions;
1375 } 1383 }
1376 1384
1385 void PepperPluginDelegateImpl::HandleDocumentLoad(
1386 webkit::ppapi::PluginInstance* instance,
1387 const WebKit::WebURLResponse& response) {
1388 DCHECK(!instance->document_loader());
1389
1390 PP_Instance pp_instance = instance->pp_instance();
1391 RendererPpapiHostImpl* host_impl = static_cast<RendererPpapiHostImpl*>(
1392 instance->module()->GetEmbedderState());
1393
1394 // Create a loader resource host for this load. Note that we have to set
1395 // the document_loader before issuing the in-process
1396 // PPP_Instance.HandleDocumentLoad call below, since this may reentrantly
1397 // call into the instance and expect it to be valid.
1398 PepperURLLoaderHost* loader_host =
1399 new PepperURLLoaderHost(host_impl, true, pp_instance, 0);
1400 instance->set_document_loader(loader_host);
1401 loader_host->didReceiveResponse(NULL, response);
1402
1403 // This host will be pending until the resource object attaches to it.
1404 int pending_host_id = host_impl->GetPpapiHost()->AddPendingResourceHost(
1405 scoped_ptr<ppapi::host::ResourceHost>(loader_host));
1406 DCHECK(pending_host_id);
1407 ppapi::URLResponseInfoData data =
1408 webkit::ppapi::DataFromWebURLResponse(pp_instance, response);
1409
1410 if (host_impl->in_process_router()) {
1411 // Running in-process, we can just create the resource and call the
1412 // PPP_Instance function directly.
1413 scoped_refptr<ppapi::proxy::URLLoaderResource> loader_resource(
1414 new ppapi::proxy::URLLoaderResource(
1415 host_impl->in_process_router()->GetPluginConnection(),
1416 pp_instance, pending_host_id, data));
1417
1418 PP_Resource loader_pp_resource = loader_resource->GetReference();
1419 if (!instance->instance_interface()->HandleDocumentLoad(
1420 instance->pp_instance(), loader_pp_resource))
1421 loader_resource->Close();
1422 // We don't pass a ref into the plugin, if it wants one, it will have taken
1423 // an additional one.
1424 ppapi::PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(
1425 loader_pp_resource);
1426
1427 // Danger! If the plugin doesn't take a ref in HandleDocumentLoad, the
1428 // resource host will be destroyed as soon as our scoped_refptr for the
1429 // resource goes out of scope.
1430 //
1431 // Null it out so people don't accidentally add code below that uses it.
1432 loader_host = NULL;
1433 } else {
1434 // Running out-of-process. Initiate an IPC call to notify the plugin
1435 // process.
1436 ppapi::proxy::HostDispatcher* dispatcher =
1437 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance);
1438 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad(
1439 ppapi::API_ID_PPP_INSTANCE, pp_instance, pending_host_id, data));
1440 }
1441 }
1442
1377 base::SharedMemory* PepperPluginDelegateImpl::CreateAnonymousSharedMemory( 1443 base::SharedMemory* PepperPluginDelegateImpl::CreateAnonymousSharedMemory(
1378 uint32_t size) { 1444 uint32_t size) {
1379 if (size == 0) 1445 if (size == 0)
1380 return NULL; 1446 return NULL;
1381 base::SharedMemoryHandle handle; 1447 base::SharedMemoryHandle handle;
1382 if (!render_view_->Send( 1448 if (!render_view_->Send(
1383 new ChildProcessHostMsg_SyncAllocateSharedMemory(size, &handle))) { 1449 new ChildProcessHostMsg_SyncAllocateSharedMemory(size, &handle))) {
1384 DLOG(WARNING) << "Browser allocation request message failed"; 1450 DLOG(WARNING) << "Browser allocation request message failed";
1385 return NULL; 1451 return NULL;
1386 } 1452 }
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1740 RenderWidgetFullscreenPepper* container = 1806 RenderWidgetFullscreenPepper* container =
1741 static_cast<RenderWidgetFullscreenPepper*>( 1807 static_cast<RenderWidgetFullscreenPepper*>(
1742 instance->fullscreen_container()); 1808 instance->fullscreen_container());
1743 return container->mouse_lock_dispatcher(); 1809 return container->mouse_lock_dispatcher();
1744 } else { 1810 } else {
1745 return render_view_->mouse_lock_dispatcher(); 1811 return render_view_->mouse_lock_dispatcher();
1746 } 1812 }
1747 } 1813 }
1748 1814
1749 } // namespace content 1815 } // 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