diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-05 00:41:20 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-05 00:41:20 +0000 |
commit | db70c13d9f08ac942e6bb839ecad2650b9101415 (patch) | |
tree | cbbb55c448cc926f95c65522ef2f452fc2586717 /ppapi/host/ppapi_host.cc | |
parent | d129dc5c96943de51cde503eff4b86d18e05fef8 (diff) | |
download | chromium_src-db70c13d9f08ac942e6bb839ecad2650b9101415.zip chromium_src-db70c13d9f08ac942e6bb839ecad2650b9101415.tar.gz chromium_src-db70c13d9f08ac942e6bb839ecad2650b9101415.tar.bz2 |
Add ability to create pending resource hosts.
Allows the host side to register a ResourceHost as pending and send an ID to the plugin, to be connected to a PluginResource at a future time.
BUG=
Review URL: https://chromiumcodereview.appspot.com/11414147
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171099 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/host/ppapi_host.cc')
-rw-r--r-- | ppapi/host/ppapi_host.cc | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/ppapi/host/ppapi_host.cc b/ppapi/host/ppapi_host.cc index 436462c..6cc4db7 100644 --- a/ppapi/host/ppapi_host.cc +++ b/ppapi/host/ppapi_host.cc @@ -28,7 +28,8 @@ const size_t kMaxResourcesPerPlugin = 1 << 14; PpapiHost::PpapiHost(IPC::Sender* sender, const PpapiPermissions& perms) : sender_(sender), - permissions_(perms) { + permissions_(perms), + next_pending_resource_host_id_(1) { } PpapiHost::~PpapiHost() { @@ -51,6 +52,8 @@ bool PpapiHost::OnMessageReceived(const IPC::Message& msg) { OnHostMsgResourceSyncCall) IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceCreated, OnHostMsgResourceCreated) + IPC_MESSAGE_HANDLER(PpapiHostMsg_AttachToPendingHost, + OnHostMsgAttachToPendingHost) IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceDestroyed, OnHostMsgResourceDestroyed) IPC_MESSAGE_UNHANDLED(handled = false) @@ -81,10 +84,21 @@ void PpapiHost::SendReply(const ReplyMessageContext& context, void PpapiHost::SendUnsolicitedReply(PP_Resource resource, const IPC::Message& msg) { + DCHECK(resource); // If this fails, host is probably pending. proxy::ResourceMessageReplyParams params(resource, 0); Send(new PpapiPluginMsg_ResourceReply(params, msg)); } +int PpapiHost::AddPendingResourceHost(scoped_ptr<ResourceHost> resource_host) { + // The resource ID should not be assigned. + DCHECK(resource_host->pp_resource() == 0); + + int pending_id = next_pending_resource_host_id_++; + pending_resource_hosts_[pending_id] = + linked_ptr<ResourceHost>(resource_host.release()); + return pending_id; +} + void PpapiHost::AddHostFactoryFilter(scoped_ptr<HostFactory> filter) { host_factory_filters_.push_back(filter.release()); } @@ -151,10 +165,27 @@ void PpapiHost::OnHostMsgResourceCreated( return; } + // Resource should have been assigned a nonzero PP_Resource. + DCHECK(resource_host->pp_resource()); + resources_[params.pp_resource()] = linked_ptr<ResourceHost>(resource_host.release()); } +void PpapiHost::OnHostMsgAttachToPendingHost(PP_Resource pp_resource, + int pending_host_id) { + PendingHostResourceMap::iterator found = + pending_resource_hosts_.find(pending_host_id); + if (found == pending_resource_hosts_.end()) { + // Plugin sent a bad ID. + NOTREACHED(); + return; + } + found->second->SetPPResourceForPendingHost(pp_resource); + resources_[pp_resource] = found->second; + pending_resource_hosts_.erase(found); +} + void PpapiHost::OnHostMsgResourceDestroyed(PP_Resource resource) { ResourceMap::iterator found = resources_.find(resource); if (found == resources_.end()) { |