summaryrefslogtreecommitdiffstats
path: root/ppapi/example
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-07 05:33:20 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-07 05:33:20 +0000
commit7ca87c2179917c73feae2f6183d2536dd6690623 (patch)
treee4bf36cdd3bb3045f82d1d921f760d70b7dc73d5 /ppapi/example
parent187c54919b3af4cd6dec23d9ea3c1547417fe7be (diff)
downloadchromium_src-7ca87c2179917c73feae2f6183d2536dd6690623.zip
chromium_src-7ca87c2179917c73feae2f6183d2536dd6690623.tar.gz
chromium_src-7ca87c2179917c73feae2f6183d2536dd6690623.tar.bz2
Add an instance parameter to var objects, audio, and the 2D API. This replaces the module in most cases.
This will be used in the proxy to multiplex one plugin across multiple renderer processes. We need the instance in the proxy to know which process to send it to. I added a deprecated var object creation function for native client, which depends on the module and this is very difficult to change. Because it doesn't have the multiplexing requirements, this is fine for now. TEST=ppapi ui tests BUG=none Review URL: http://codereview.chromium.org/6085009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70721 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/example')
-rw-r--r--ppapi/example/example.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/ppapi/example/example.cc b/ppapi/example/example.cc
index ab5a248..e875a4b 100644
--- a/ppapi/example/example.cc
+++ b/ppapi/example/example.cc
@@ -44,6 +44,8 @@ void FillRect(pp::ImageData* image, int left, int top, int width, int height,
class MyScriptableObject : public pp::deprecated::ScriptableObject {
public:
+ explicit MyScriptableObject(pp::Instance* instance) : instance_(instance) {}
+
virtual bool HasMethod(const pp::Var& method, pp::Var* exception) {
return method.AsString() == "toString";
}
@@ -56,7 +58,7 @@ class MyScriptableObject : public pp::deprecated::ScriptableObject {
virtual pp::Var GetProperty(const pp::Var& name, pp::Var* exception) {
if (name.is_string() && name.AsString() == "blah")
- return new MyScriptableObject();
+ return pp::Var(instance_, new MyScriptableObject(instance_));
return pp::Var();
}
@@ -72,6 +74,9 @@ class MyScriptableObject : public pp::deprecated::ScriptableObject {
return pp::Var("hello world");
return pp::Var();
}
+
+ private:
+ pp::Instance* instance_;
};
class MyFetcherClient {
@@ -191,11 +196,11 @@ class MyInstance : public pp::Instance, public MyFetcherClient {
}
virtual pp::Var GetInstanceObject() {
- return new MyScriptableObject();
+ return pp::Var(this, new MyScriptableObject(this));
}
pp::ImageData PaintImage(int width, int height) {
- pp::ImageData image(PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::ImageData image(this, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
pp::Size(width, height), false);
if (image.is_null()) {
printf("Couldn't allocate the image data\n");
@@ -240,7 +245,7 @@ class MyInstance : public pp::Instance, public MyFetcherClient {
width_ = position.size().width();
height_ = position.size().height();
- device_context_ = pp::Graphics2D(pp::Size(width_, height_), false);
+ device_context_ = pp::Graphics2D(this, pp::Size(width_, height_), false);
if (!BindGraphics(device_context_)) {
printf("Couldn't bind the device context\n");
return;
@@ -348,7 +353,7 @@ class MyInstance : public pp::Instance, public MyFetcherClient {
pp::Var doc = window.GetProperty("document");
pp::Var body = doc.GetProperty("body");
- pp::Var obj(new MyScriptableObject());
+ pp::Var obj(this, new MyScriptableObject(this));
// Our object should have its toString method called.
Log("Testing MyScriptableObject::toString():");