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

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

Issue 23011018: Modify Pepper CreateResourceHostFromHost to create multiple hosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 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"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 return host; 65 return host;
66 } 66 }
67 67
68 bool PepperRendererConnection::OnMessageReceived(const IPC::Message& msg, 68 bool PepperRendererConnection::OnMessageReceived(const IPC::Message& msg,
69 bool* message_was_ok) { 69 bool* message_was_ok) {
70 if (in_process_host_->GetPpapiHost()->OnMessageReceived(msg)) 70 if (in_process_host_->GetPpapiHost()->OnMessageReceived(msg))
71 return true; 71 return true;
72 72
73 bool handled = true; 73 bool handled = true;
74 IPC_BEGIN_MESSAGE_MAP_EX(PepperRendererConnection, msg, *message_was_ok) 74 IPC_BEGIN_MESSAGE_MAP_EX(PepperRendererConnection, msg, *message_was_ok)
75 IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostFromHost, 75 IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHost,
76 OnMsgCreateResourceHostFromHost) 76 OnMsgCreateResourceHostsFromHost)
77 IPC_MESSAGE_HANDLER(PpapiHostMsg_FileRef_GetInfoForRenderer, 77 IPC_MESSAGE_HANDLER(PpapiHostMsg_FileRef_GetInfoForRenderer,
78 OnMsgFileRefGetInfoForRenderer) 78 OnMsgFileRefGetInfoForRenderer)
79 IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateInProcessInstance, 79 IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateInProcessInstance,
80 OnMsgDidCreateInProcessInstance) 80 OnMsgDidCreateInProcessInstance)
81 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteInProcessInstance, 81 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteInProcessInstance,
82 OnMsgDidDeleteInProcessInstance) 82 OnMsgDidDeleteInProcessInstance)
83 IPC_MESSAGE_UNHANDLED(handled = false) 83 IPC_MESSAGE_UNHANDLED(handled = false)
84 IPC_END_MESSAGE_MAP_EX() 84 IPC_END_MESSAGE_MAP_EX()
85 85
86 return handled; 86 return handled;
87 } 87 }
88 88
89 void PepperRendererConnection::OnMsgCreateResourceHostFromHost( 89 void PepperRendererConnection::OnMsgCreateResourceHostsFromHost(
90 int routing_id, 90 int routing_id,
91 int child_process_id, 91 int child_process_id,
92 const ppapi::proxy::ResourceMessageCallParams& params, 92 const ppapi::proxy::ResourceMessageCallParams& params,
93 PP_Instance instance, 93 PP_Instance instance,
94 const IPC::Message& nested_msg) { 94 const std::vector<IPC::Message>& nested_msgs) {
95 BrowserPpapiHostImpl* host = GetHostForChildProcess(child_process_id); 95 BrowserPpapiHostImpl* host = GetHostForChildProcess(child_process_id);
96 96
97 int pending_resource_host_id; 97 std::vector<int> pending_resource_host_ids(nested_msgs.size(), 0);
98 if (!host) { 98 if (!host) {
99 DLOG(ERROR) << "Invalid plugin process ID."; 99 DLOG(ERROR) << "Invalid plugin process ID.";
100 pending_resource_host_id = 0;
101 } else { 100 } else {
102 // FileRef_CreateExternal is only permitted from the renderer. Because of 101 for (size_t i = 0; i < nested_msgs.size(); ++i) {
103 // this, we handle this message here and not in 102 // FileRef_CreateExternal is only permitted from the renderer. Because of
104 // content_browser_pepper_host_factory.cc. 103 // this, we handle this message here and not in
105 scoped_ptr<ppapi::host::ResourceHost> resource_host; 104 // content_browser_pepper_host_factory.cc.
106 if (host->IsValidInstance(instance)) { 105 scoped_ptr<ppapi::host::ResourceHost> resource_host;
107 if (nested_msg.type() == PpapiHostMsg_FileRef_CreateExternal::ID) { 106 if (host->IsValidInstance(instance)) {
108 base::FilePath external_path; 107 if (nested_msgs[i].type() == PpapiHostMsg_FileRef_CreateExternal::ID) {
109 if (ppapi::UnpackMessage<PpapiHostMsg_FileRef_CreateExternal>( 108 base::FilePath external_path;
110 nested_msg, &external_path)) { 109 if (ppapi::UnpackMessage<PpapiHostMsg_FileRef_CreateExternal>(
111 resource_host.reset(new PepperFileRefHost( 110 nested_msgs[i], &external_path)) {
112 host, instance, params.pp_resource(), external_path)); 111 resource_host.reset(new PepperFileRefHost(
112 host, instance, params.pp_resource(), external_path));
113 }
113 } 114 }
114 } 115 }
116
117 if (!resource_host.get()) {
118 resource_host = host->GetPpapiHost()->CreateResourceHost(
119 params, instance, nested_msgs[i]);
120 }
121
122 if (resource_host.get()) {
123 pending_resource_host_ids[i] =
124 host->GetPpapiHost()->AddPendingResourceHost(resource_host.Pass());
125 }
115 } 126 }
116
117 if (!resource_host.get()) {
118 resource_host = host->GetPpapiHost()->CreateResourceHost(params,
119 instance,
120 nested_msg);
121 }
122 pending_resource_host_id =
123 host->GetPpapiHost()->AddPendingResourceHost(resource_host.Pass());
124 } 127 }
125 128
126 Send(new PpapiHostMsg_CreateResourceHostFromHostReply( 129 Send(new PpapiHostMsg_CreateResourceHostsFromHostReply(
127 routing_id, params.sequence(), pending_resource_host_id)); 130 routing_id, params.sequence(), pending_resource_host_ids));
128 } 131 }
129 132
130 void PepperRendererConnection::OnMsgFileRefGetInfoForRenderer( 133 void PepperRendererConnection::OnMsgFileRefGetInfoForRenderer(
131 int routing_id, 134 int routing_id,
132 int child_process_id, 135 int child_process_id,
133 int32_t sequence, 136 int32_t sequence,
134 const std::vector<PP_Resource>& resources) { 137 const std::vector<PP_Resource>& resources) {
135 std::vector<PP_Resource> out_resources; 138 std::vector<PP_Resource> out_resources;
136 std::vector<PP_FileSystemType> fs_types; 139 std::vector<PP_FileSystemType> fs_types;
137 std::vector<std::string> file_system_url_specs; 140 std::vector<std::string> file_system_url_specs;
(...skipping 30 matching lines...) Expand all
168 data.render_process_id = render_process_id_; 171 data.render_process_id = render_process_id_;
169 in_process_host_->AddInstance(instance, data); 172 in_process_host_->AddInstance(instance, data);
170 } 173 }
171 174
172 void PepperRendererConnection::OnMsgDidDeleteInProcessInstance( 175 void PepperRendererConnection::OnMsgDidDeleteInProcessInstance(
173 PP_Instance instance) { 176 PP_Instance instance) {
174 in_process_host_->DeleteInstance(instance); 177 in_process_host_->DeleteInstance(instance);
175 } 178 }
176 179
177 } // namespace content 180 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/pepper/pepper_renderer_connection.h ('k') | content/public/renderer/renderer_ppapi_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698