summaryrefslogtreecommitdiffstats
path: root/ppapi/host
diff options
context:
space:
mode:
authorraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-07 22:15:25 +0000
committerraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-07 22:15:25 +0000
commitc542557af5a9ebd2a03ef1e2be2936d36403c75d (patch)
treee827d418c00d9b504d72ce34261d1077d5b6732f /ppapi/host
parentb2206da557c9bb6e7758e02fe74153eacab5c677 (diff)
downloadchromium_src-c542557af5a9ebd2a03ef1e2be2936d36403c75d.zip
chromium_src-c542557af5a9ebd2a03ef1e2be2936d36403c75d.tar.gz
chromium_src-c542557af5a9ebd2a03ef1e2be2936d36403c75d.tar.bz2
Allow renderer to create pepper ResourceHosts in the browser
This CL allows pending ResourceHosts to be created in the browser from the renderer. The functionality is currently exposed through the RendererPpapiHost. The creation call is asynchronous - a callback will be called in the renderer with a pending host ID when the host has been created. BUG=246396 Review URL: https://chromiumcodereview.appspot.com/15947004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204954 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/host')
-rw-r--r--ppapi/host/ppapi_host.cc41
-rw-r--r--ppapi/host/ppapi_host.h6
2 files changed, 37 insertions, 10 deletions
diff --git a/ppapi/host/ppapi_host.cc b/ppapi/host/ppapi_host.cc
index 0b24e10..a200f3b6 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;
diff --git a/ppapi/host/ppapi_host.h b/ppapi/host/ppapi_host.h
index c661a9b..0b3d23d 100644
--- a/ppapi/host/ppapi_host.h
+++ b/ppapi/host/ppapi_host.h
@@ -61,6 +61,12 @@ class PPAPI_HOST_EXPORT PpapiHost : public IPC::Sender, public IPC::Listener {
// Sends the given unsolicited reply message to the plugin.
void SendUnsolicitedReply(PP_Resource resource, const IPC::Message& msg);
+ // Create a ResourceHost with the given |nested_msg|.
+ scoped_ptr<ResourceHost> CreateResourceHost(
+ const proxy::ResourceMessageCallParams& params,
+ PP_Instance instance,
+ const IPC::Message& nested_msg);
+
// Adds the given host resource as a pending one (with no corresponding
// PluginResource object and no PP_Resource ID yet). The pending resource ID
// is returned. See PpapiHostMsg_AttachToPendingHost.