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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_renderer_connection.cc

Issue 26564009: [PPAPI] It is now possible to pass filesystems from JavaScript to NaCl modules. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address comments. Created 7 years, 1 month 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
« no previous file with comments | « chrome/test/ppapi/ppapi_browsertest.cc ('k') | content/renderer/pepper/host_var_tracker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/browser/renderer_host/pepper/pepper_renderer_connection.h" 5 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h"
6 6
7 #include "content/browser/browser_child_process_host_impl.h" 7 #include "content/browser/browser_child_process_host_impl.h"
8 #include "content/browser/ppapi_plugin_process_host.h" 8 #include "content/browser/ppapi_plugin_process_host.h"
9 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" 9 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
10 #include "content/common/pepper_renderer_instance_data.h" 10 #include "content/common/pepper_renderer_instance_data.h"
11 #include "content/common/view_messages.h" 11 #include "content/common/view_messages.h"
12 #include "content/browser/renderer_host/pepper/pepper_file_ref_host.h" 12 #include "content/browser/renderer_host/pepper/pepper_file_ref_host.h"
13 #include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h "
13 #include "content/public/browser/content_browser_client.h" 14 #include "content/public/browser/content_browser_client.h"
14 #include "content/public/common/content_client.h" 15 #include "content/public/common/content_client.h"
15 #include "ipc/ipc_message_macros.h" 16 #include "ipc/ipc_message_macros.h"
16 #include "ppapi/host/resource_host.h" 17 #include "ppapi/host/resource_host.h"
17 #include "ppapi/proxy/ppapi_message_utils.h" 18 #include "ppapi/proxy/ppapi_message_utils.h"
18 #include "ppapi/proxy/ppapi_messages.h" 19 #include "ppapi/proxy/ppapi_messages.h"
19 #include "ppapi/proxy/ppapi_message_utils.h" 20 #include "ppapi/proxy/ppapi_message_utils.h"
20 #include "ppapi/proxy/resource_message_params.h" 21 #include "ppapi/proxy/resource_message_params.h"
21 22
22 namespace content { 23 namespace content {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 const ppapi::proxy::ResourceMessageCallParams& params, 92 const ppapi::proxy::ResourceMessageCallParams& params,
92 PP_Instance instance, 93 PP_Instance instance,
93 const std::vector<IPC::Message>& nested_msgs) { 94 const std::vector<IPC::Message>& nested_msgs) {
94 BrowserPpapiHostImpl* host = GetHostForChildProcess(child_process_id); 95 BrowserPpapiHostImpl* host = GetHostForChildProcess(child_process_id);
95 96
96 std::vector<int> pending_resource_host_ids(nested_msgs.size(), 0); 97 std::vector<int> pending_resource_host_ids(nested_msgs.size(), 0);
97 if (!host) { 98 if (!host) {
98 DLOG(ERROR) << "Invalid plugin process ID."; 99 DLOG(ERROR) << "Invalid plugin process ID.";
99 } else { 100 } else {
100 for (size_t i = 0; i < nested_msgs.size(); ++i) { 101 for (size_t i = 0; i < nested_msgs.size(); ++i) {
101 // FileRef_CreateExternal is only permitted from the renderer. Because of 102 const IPC::Message& nested_msg = nested_msgs[i];
102 // this, we handle this message here and not in
103 // content_browser_pepper_host_factory.cc.
104 scoped_ptr<ppapi::host::ResourceHost> resource_host; 103 scoped_ptr<ppapi::host::ResourceHost> resource_host;
105 if (host->IsValidInstance(instance)) { 104 if (host->IsValidInstance(instance)) {
106 if (nested_msgs[i].type() == PpapiHostMsg_FileRef_CreateExternal::ID) { 105 if (nested_msg.type() == PpapiHostMsg_FileRef_CreateExternal::ID) {
106 // FileRef_CreateExternal is only permitted from the renderer. Because
107 // of this, we handle this message here and not in
108 // content_browser_pepper_host_factory.cc.
107 base::FilePath external_path; 109 base::FilePath external_path;
108 if (ppapi::UnpackMessage<PpapiHostMsg_FileRef_CreateExternal>( 110 if (ppapi::UnpackMessage<PpapiHostMsg_FileRef_CreateExternal>(
109 nested_msgs[i], &external_path)) { 111 nested_msg, &external_path)) {
110 resource_host.reset(new PepperFileRefHost( 112 resource_host.reset(new PepperFileRefHost(
111 host, instance, params.pp_resource(), external_path)); 113 host, instance, params.pp_resource(), external_path));
112 } 114 }
115 } else if (nested_msg.type() ==
116 PpapiHostMsg_FileSystem_CreateFromRenderer::ID) {
117 // Similarly, FileSystem_CreateFromRenderer is only permitted from the
118 // renderer.
119 std::string root_url;
120 PP_FileSystemType file_system_type;
121 if (ppapi::UnpackMessage<PpapiHostMsg_FileSystem_CreateFromRenderer>(
122 nested_msg, &root_url, &file_system_type)) {
123 resource_host.reset(
124 new PepperFileSystemBrowserHost(host,
125 instance,
126 params.pp_resource(),
127 GURL(root_url),
128 file_system_type));
129 }
113 } 130 }
114 } 131 }
115 132
116 if (!resource_host.get()) { 133 if (!resource_host.get()) {
117 resource_host = host->GetPpapiHost()->CreateResourceHost( 134 resource_host = host->GetPpapiHost()->CreateResourceHost(
118 params, instance, nested_msgs[i]); 135 params, instance, nested_msg);
119 } 136 }
120 137
121 if (resource_host.get()) { 138 if (resource_host.get()) {
122 pending_resource_host_ids[i] = 139 pending_resource_host_ids[i] =
123 host->GetPpapiHost()->AddPendingResourceHost(resource_host.Pass()); 140 host->GetPpapiHost()->AddPendingResourceHost(resource_host.Pass());
124 } 141 }
125 } 142 }
126 } 143 }
127 144
128 Send(new PpapiHostMsg_CreateResourceHostsFromHostReply( 145 Send(new PpapiHostMsg_CreateResourceHostsFromHostReply(
129 routing_id, params.sequence(), pending_resource_host_ids)); 146 routing_id, params.sequence(), pending_resource_host_ids));
130 } 147 }
131 148
132 void PepperRendererConnection::OnMsgDidCreateInProcessInstance( 149 void PepperRendererConnection::OnMsgDidCreateInProcessInstance(
133 PP_Instance instance, 150 PP_Instance instance,
134 const PepperRendererInstanceData& instance_data) { 151 const PepperRendererInstanceData& instance_data) {
135 PepperRendererInstanceData data = instance_data; 152 PepperRendererInstanceData data = instance_data;
136 data.render_process_id = render_process_id_; 153 data.render_process_id = render_process_id_;
137 in_process_host_->AddInstance(instance, data); 154 in_process_host_->AddInstance(instance, data);
138 } 155 }
139 156
140 void PepperRendererConnection::OnMsgDidDeleteInProcessInstance( 157 void PepperRendererConnection::OnMsgDidDeleteInProcessInstance(
141 PP_Instance instance) { 158 PP_Instance instance) {
142 in_process_host_->DeleteInstance(instance); 159 in_process_host_->DeleteInstance(instance);
143 } 160 }
144 161
145 } // namespace content 162 } // namespace content
OLDNEW
« no previous file with comments | « chrome/test/ppapi/ppapi_browsertest.cc ('k') | content/renderer/pepper/host_var_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698