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

Unified Diff: ppapi/host/ppapi_host.cc

Issue 15947004: Allow renderer to create pepper ResourceHosts in the browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/host/ppapi_host.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/host/ppapi_host.cc
diff --git a/ppapi/host/ppapi_host.cc b/ppapi/host/ppapi_host.cc
index 0b24e10d7d3b826934339c9972e6953c4cb94da3..a200f3b6483ea65b4b3ead00b128ba04ee03f977 100644
--- a/ppapi/host/ppapi_host.cc
+++ b/ppapi/host/ppapi_host.cc
@@ -99,9 +99,32 @@ void PpapiHost::SendUnsolicitedReply(PP_Resource resource,
Send(new PpapiPluginMsg_ResourceReply(params, msg));
}
+scoped_ptr<ResourceHost> PpapiHost::CreateResourceHost(
+ const proxy::ResourceMessageCallParams& params,
+ PP_Instance instance,
+ const IPC::Message& nested_msg) {
+ scoped_ptr<ResourceHost> resource_host;
+ DCHECK(!host_factory_filters_.empty()); // Caller forgot to add a factory.
+ for (size_t i = 0; i < host_factory_filters_.size(); i++) {
+ resource_host = host_factory_filters_[i]->CreateResourceHost(
+ this, params, instance, nested_msg).Pass();
+ if (resource_host.get())
+ break;
+ }
+ return resource_host.Pass();
+}
+
int PpapiHost::AddPendingResourceHost(scoped_ptr<ResourceHost> resource_host) {
// The resource ID should not be assigned.
- DCHECK(resource_host->pp_resource() == 0);
+ if (!resource_host.get() || resource_host->pp_resource() != 0) {
+ NOTREACHED();
+ return 0;
+ }
+
+ if (pending_resource_hosts_.size() + resources_.size()
+ >= kMaxResourcesPerPlugin) {
+ return 0;
+ }
int pending_id = next_pending_resource_host_id_++;
pending_resource_hosts_[pending_id] =
@@ -168,18 +191,16 @@ void PpapiHost::OnHostMsgResourceCreated(
TRACE_EVENT2("ppapi proxy", "PpapiHost::OnHostMsgResourceCreated",
"Class", IPC_MESSAGE_ID_CLASS(nested_msg.type()),
"Line", IPC_MESSAGE_ID_LINE(nested_msg.type()));
- if (resources_.size() >= kMaxResourcesPerPlugin)
+
+ if (pending_resource_hosts_.size() + resources_.size()
+ >= kMaxResourcesPerPlugin) {
return;
+ }
// Run through all filters until one grabs this message.
- scoped_ptr<ResourceHost> resource_host;
- DCHECK(!host_factory_filters_.empty()); // Caller forgot to add a factory.
- for (size_t i = 0; i < host_factory_filters_.size(); i++) {
- resource_host = host_factory_filters_[i]->CreateResourceHost(
- this, params, instance, nested_msg).Pass();
- if (resource_host.get())
- break;
- }
+ scoped_ptr<ResourceHost> resource_host = CreateResourceHost(params, instance,
+ nested_msg);
+
if (!resource_host.get()) {
NOTREACHED();
return;
« no previous file with comments | « ppapi/host/ppapi_host.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698