summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-26 07:38:33 +0000
committermgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-26 07:38:33 +0000
commit29b8f2312c189bd8394ea13e5063acfe9c395507 (patch)
tree57fffd40ef4a0286d15dabc93f81bb86c8ffcd95
parent8b5cd4ec8654fc5db76765ff1ffb6f4d9ee23e7e (diff)
downloadchromium_src-29b8f2312c189bd8394ea13e5063acfe9c395507.zip
chromium_src-29b8f2312c189bd8394ea13e5063acfe9c395507.tar.gz
chromium_src-29b8f2312c189bd8394ea13e5063acfe9c395507.tar.bz2
[PPAPI] ResourceVar now holds a pending renderer and browser host ID.
It is likely that resources will be backed by a host in the renderer or browser, or both. Therefore, HostResourceVar should provide a consistent way to tell the plugin the pending host IDs. BUG=177017 Review URL: https://codereview.chromium.org/24196005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225380 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/renderer/pepper/host_resource_var.cc17
-rw-r--r--content/renderer/pepper/host_resource_var.h23
-rw-r--r--ppapi/proxy/raw_var_data.cc14
-rw-r--r--ppapi/proxy/raw_var_data.h6
-rw-r--r--ppapi/shared_impl/resource_var.cc8
-rw-r--r--ppapi/shared_impl/resource_var.h6
6 files changed, 66 insertions, 8 deletions
diff --git a/content/renderer/pepper/host_resource_var.cc b/content/renderer/pepper/host_resource_var.cc
index a59bed3..810a949 100644
--- a/content/renderer/pepper/host_resource_var.cc
+++ b/content/renderer/pepper/host_resource_var.cc
@@ -9,16 +9,29 @@ namespace content {
HostResourceVar::HostResourceVar() : pp_resource_(0) {}
HostResourceVar::HostResourceVar(PP_Resource pp_resource)
- : pp_resource_(pp_resource) {}
+ : pp_resource_(pp_resource),
+ pending_renderer_host_id_(0),
+ pending_browser_host_id_(0) {}
-HostResourceVar::HostResourceVar(const IPC::Message& creation_message)
+HostResourceVar::HostResourceVar(int pending_renderer_host_id,
+ const IPC::Message& creation_message)
: pp_resource_(0),
+ pending_renderer_host_id_(pending_renderer_host_id),
+ pending_browser_host_id_(0),
creation_message_(new IPC::Message(creation_message)) {}
PP_Resource HostResourceVar::GetPPResource() const {
return pp_resource_;
}
+int HostResourceVar::GetPendingRendererHostId() const {
+ return pending_renderer_host_id_;
+}
+
+int HostResourceVar::GetPendingBrowserHostId() const {
+ return pending_browser_host_id_;
+}
+
const IPC::Message* HostResourceVar::GetCreationMessage() const {
return creation_message_.get();
}
diff --git a/content/renderer/pepper/host_resource_var.h b/content/renderer/pepper/host_resource_var.h
index 79fe487..cc6b057 100644
--- a/content/renderer/pepper/host_resource_var.h
+++ b/content/renderer/pepper/host_resource_var.h
@@ -24,23 +24,38 @@ class HostResourceVar : public ppapi::ResourceVar {
explicit HostResourceVar(PP_Resource pp_resource);
// Makes a resource var with a pending resource host.
- // The |creation_message| contains data needed to create the plugin-side
- // resource. Its type depends on the type of resource.
- explicit HostResourceVar(const IPC::Message& creation_message);
+ // The |pending_renderer_host_id| is a pending resource host ID in the
+ // renderer to attach from the plugin. Depending on the type of resource, this
+ // may be 0. The |creation_message| contains additional data needed to create
+ // the plugin-side resource. Its type depends on the type of resource.
+ HostResourceVar(int pending_renderer_host_id,
+ const IPC::Message& creation_message);
// ResourceVar override.
virtual PP_Resource GetPPResource() const OVERRIDE;
+ virtual int GetPendingRendererHostId() const OVERRIDE;
+ virtual int GetPendingBrowserHostId() const OVERRIDE;
virtual const IPC::Message* GetCreationMessage() const OVERRIDE;
virtual bool IsPending() const OVERRIDE;
+ void set_pending_browser_host_id(int id) {
+ pending_browser_host_id_ = id;
+ }
+
protected:
virtual ~HostResourceVar();
private:
// Real resource ID in the plugin. 0 if one has not yet been created
- // (indicating that there is a pending host resource).
+ // (indicating that there is a pending resource host).
PP_Resource pp_resource_;
+ // Pending resource host ID in the renderer.
+ int pending_renderer_host_id_;
+
+ // Pending resource host ID in the browser.
+ int pending_browser_host_id_;
+
// If the plugin-side resource has not yet been created, carries a message to
// create a resource of the specific type on the plugin side. Otherwise, NULL.
scoped_ptr<IPC::Message> creation_message_;
diff --git a/ppapi/proxy/raw_var_data.cc b/ppapi/proxy/raw_var_data.cc
index 337eaae..91bcfbfd 100644
--- a/ppapi/proxy/raw_var_data.cc
+++ b/ppapi/proxy/raw_var_data.cc
@@ -665,8 +665,10 @@ bool DictionaryRawVarData::Read(PP_VarType type,
}
// ResourceRawVarData ----------------------------------------------------------
-ResourceRawVarData::ResourceRawVarData() {
-}
+ResourceRawVarData::ResourceRawVarData()
+ : pp_resource_(0),
+ pending_renderer_host_id_(0),
+ pending_browser_host_id_(0) {}
ResourceRawVarData::~ResourceRawVarData() {
}
@@ -686,6 +688,8 @@ bool ResourceRawVarData::Init(const PP_Var& var, PP_Instance /*instance*/) {
creation_message_.reset(new IPC::Message(*message));
else
creation_message_.reset();
+ pending_renderer_host_id_ = resource_var->GetPendingRendererHostId();
+ pending_browser_host_id_ = resource_var->GetPendingBrowserHostId();
initialized_ = true;
return true;
}
@@ -708,6 +712,8 @@ void ResourceRawVarData::PopulatePPVar(const PP_Var& var,
void ResourceRawVarData::Write(IPC::Message* m,
const HandleWriter& handle_writer) {
m->WriteInt(static_cast<int>(pp_resource_));
+ m->WriteInt(pending_renderer_host_id_);
+ m->WriteInt(pending_browser_host_id_);
m->WriteBool(creation_message_);
if (creation_message_)
IPC::ParamTraits<IPC::Message>::Write(m, *creation_message_);
@@ -720,6 +726,10 @@ bool ResourceRawVarData::Read(PP_VarType type,
if (!m->ReadInt(iter, &value))
return false;
pp_resource_ = static_cast<PP_Resource>(value);
+ if (!m->ReadInt(iter, &pending_renderer_host_id_))
+ return false;
+ if (!m->ReadInt(iter, &pending_browser_host_id_))
+ return false;
bool has_creation_message;
if (!m->ReadBool(iter, &has_creation_message))
return false;
diff --git a/ppapi/proxy/raw_var_data.h b/ppapi/proxy/raw_var_data.h
index 201da2c..d45ea53 100644
--- a/ppapi/proxy/raw_var_data.h
+++ b/ppapi/proxy/raw_var_data.h
@@ -283,6 +283,12 @@ class ResourceRawVarData : public RawVarData {
// This is a borrowed reference; the resource's refcount is not incremented.
PP_Resource pp_resource_;
+ // Pending resource host ID in the renderer.
+ int pending_renderer_host_id_;
+
+ // Pending resource host ID in the browser.
+ int pending_browser_host_id_;
+
// A message containing information about how to create a plugin-side
// resource. The message type will vary based on the resource type, and will
// usually contain a pending resource host ID, and other required information.
diff --git a/ppapi/shared_impl/resource_var.cc b/ppapi/shared_impl/resource_var.cc
index 3e34c38..1260843 100644
--- a/ppapi/shared_impl/resource_var.cc
+++ b/ppapi/shared_impl/resource_var.cc
@@ -9,6 +9,14 @@
namespace ppapi {
+int ResourceVar::GetPendingRendererHostId() const {
+ return 0;
+}
+
+int ResourceVar::GetPendingBrowserHostId() const {
+ return 0;
+}
+
const IPC::Message* ResourceVar::GetCreationMessage() const {
return NULL;
}
diff --git a/ppapi/shared_impl/resource_var.h b/ppapi/shared_impl/resource_var.h
index 0b8bab2..96d2403 100644
--- a/ppapi/shared_impl/resource_var.h
+++ b/ppapi/shared_impl/resource_var.h
@@ -25,6 +25,12 @@ class PPAPI_SHARED_EXPORT ResourceVar : public Var {
// plugin side. It should be AddRef'd if the resource is passed to the user.
virtual PP_Resource GetPPResource() const = 0;
+ // Gets the pending resource host ID in the renderer.
+ virtual int GetPendingRendererHostId() const;
+
+ // Gets the pending resource host ID in the browser.
+ virtual int GetPendingBrowserHostId() const;
+
// Gets the message for creating a plugin-side resource. Returns NULL if the
// message is empty (which is always true on the plugin side).
virtual const IPC::Message* GetCreationMessage() const;