diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-07 05:33:20 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-07 05:33:20 +0000 |
commit | 7ca87c2179917c73feae2f6183d2536dd6690623 (patch) | |
tree | e4bf36cdd3bb3045f82d1d921f760d70b7dc73d5 /ppapi/cpp | |
parent | 187c54919b3af4cd6dec23d9ea3c1547417fe7be (diff) | |
download | chromium_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/cpp')
-rw-r--r-- | ppapi/cpp/dev/audio_config_dev.cc | 6 | ||||
-rw-r--r-- | ppapi/cpp/dev/audio_config_dev.h | 5 | ||||
-rw-r--r-- | ppapi/cpp/dev/audio_dev.cc | 4 | ||||
-rw-r--r-- | ppapi/cpp/dev/audio_dev.h | 2 | ||||
-rw-r--r-- | ppapi/cpp/graphics_2d.cc | 7 | ||||
-rw-r--r-- | ppapi/cpp/graphics_2d.h | 3 | ||||
-rw-r--r-- | ppapi/cpp/image_data.cc | 5 | ||||
-rw-r--r-- | ppapi/cpp/image_data.h | 4 | ||||
-rw-r--r-- | ppapi/cpp/paint_manager.cc | 2 | ||||
-rw-r--r-- | ppapi/cpp/var.cc | 5 | ||||
-rw-r--r-- | ppapi/cpp/var.h | 12 |
11 files changed, 39 insertions, 16 deletions
diff --git a/ppapi/cpp/dev/audio_config_dev.cc b/ppapi/cpp/dev/audio_config_dev.cc index c8f8f3a..754a78f 100644 --- a/ppapi/cpp/dev/audio_config_dev.cc +++ b/ppapi/cpp/dev/audio_config_dev.cc @@ -4,6 +4,7 @@ #include "ppapi/cpp/dev/audio_config_dev.h" +#include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -22,14 +23,15 @@ AudioConfig_Dev::AudioConfig_Dev() sample_frame_count_(0) { } -AudioConfig_Dev::AudioConfig_Dev(PP_AudioSampleRate_Dev sample_rate, +AudioConfig_Dev::AudioConfig_Dev(Instance* instance, + PP_AudioSampleRate_Dev sample_rate, uint32_t sample_frame_count) : sample_rate_(sample_rate), sample_frame_count_(sample_frame_count) { if (has_interface<PPB_AudioConfig_Dev>()) { PassRefFromConstructor( get_interface<PPB_AudioConfig_Dev>()->CreateStereo16Bit( - Module::Get()->pp_module(), sample_rate, sample_frame_count)); + instance->pp_instance(), sample_rate, sample_frame_count)); } } diff --git a/ppapi/cpp/dev/audio_config_dev.h b/ppapi/cpp/dev/audio_config_dev.h index 1229156..6b0f1f2 100644 --- a/ppapi/cpp/dev/audio_config_dev.h +++ b/ppapi/cpp/dev/audio_config_dev.h @@ -11,6 +11,8 @@ namespace pp { +class Instance; + // Typical usage: // // // Create an audio config with a supported frame count. @@ -34,7 +36,8 @@ class AudioConfig_Dev : public Resource { // semple frame count. // // See PPB_AudioConfigDev.CreateStereo16Bit for more. - AudioConfig_Dev(PP_AudioSampleRate_Dev sample_rate, + AudioConfig_Dev(Instance* instance, + PP_AudioSampleRate_Dev sample_rate, uint32_t sample_frame_count); // Returns a supported frame count for use in the constructor. diff --git a/ppapi/cpp/dev/audio_dev.cc b/ppapi/cpp/dev/audio_dev.cc index 850d4d1..b80d196 100644 --- a/ppapi/cpp/dev/audio_dev.cc +++ b/ppapi/cpp/dev/audio_dev.cc @@ -16,14 +16,14 @@ template <> const char* interface_name<PPB_Audio_Dev>() { } // namespace -Audio_Dev::Audio_Dev(const Instance& instance, +Audio_Dev::Audio_Dev(Instance* instance, const AudioConfig_Dev& config, PPB_Audio_Callback callback, void* user_data) : config_(config) { if (has_interface<PPB_Audio_Dev>()) { PassRefFromConstructor(get_interface<PPB_Audio_Dev>()->Create( - instance.pp_instance(), config.pp_resource(), callback, user_data)); + instance->pp_instance(), config.pp_resource(), callback, user_data)); } } diff --git a/ppapi/cpp/dev/audio_dev.h b/ppapi/cpp/dev/audio_dev.h index 983e53c..a355cb6 100644 --- a/ppapi/cpp/dev/audio_dev.h +++ b/ppapi/cpp/dev/audio_dev.h @@ -17,7 +17,7 @@ namespace pp { class Audio_Dev : public Resource { public: Audio_Dev() {} - Audio_Dev(const Instance& instance, + Audio_Dev(Instance* instance, const AudioConfig_Dev& config, PPB_Audio_Callback callback, void* user_data); diff --git a/ppapi/cpp/graphics_2d.cc b/ppapi/cpp/graphics_2d.cc index edd5c33..0db5862 100644 --- a/ppapi/cpp/graphics_2d.cc +++ b/ppapi/cpp/graphics_2d.cc @@ -9,6 +9,7 @@ #include "ppapi/cpp/common.h" #include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/image_data.h" +#include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" #include "ppapi/cpp/point.h" @@ -32,12 +33,14 @@ Graphics2D::Graphics2D(const Graphics2D& other) size_(other.size_) { } -Graphics2D::Graphics2D(const Size& size, bool is_always_opaque) +Graphics2D::Graphics2D(Instance* instance, + const Size& size, + bool is_always_opaque) : Resource() { if (!has_interface<PPB_Graphics2D>()) return; PassRefFromConstructor(get_interface<PPB_Graphics2D>()->Create( - Module::Get()->pp_module(), + instance->pp_instance(), &size.pp_size(), BoolToPPBool(is_always_opaque))); if (!is_null()) { diff --git a/ppapi/cpp/graphics_2d.h b/ppapi/cpp/graphics_2d.h index 39bcb5e..9d498e1 100644 --- a/ppapi/cpp/graphics_2d.h +++ b/ppapi/cpp/graphics_2d.h @@ -13,6 +13,7 @@ namespace pp { class CompletionCallback; class ImageData; +class Instance; class Point; class Rect; @@ -27,7 +28,7 @@ class Graphics2D : public Resource { // Allocates a new 2D graphics context with the given size in the browser, // resulting object will be is_null() if the allocation failed. - Graphics2D(const Size& size, bool is_always_opaque); + Graphics2D(Instance* instance, const Size& size, bool is_always_opaque); virtual ~Graphics2D(); diff --git a/ppapi/cpp/image_data.cc b/ppapi/cpp/image_data.cc index e43263b..33178a6 100644 --- a/ppapi/cpp/image_data.cc +++ b/ppapi/cpp/image_data.cc @@ -43,7 +43,8 @@ ImageData::ImageData(PassRef, PP_Resource resource) PassRefAndInitData(resource); } -ImageData::ImageData(PP_ImageDataFormat format, +ImageData::ImageData(Instance* instance, + PP_ImageDataFormat format, const Size& size, bool init_to_zero) : data_(NULL) { @@ -53,7 +54,7 @@ ImageData::ImageData(PP_ImageDataFormat format, return; PassRefAndInitData(get_interface<PPB_ImageData>()->Create( - Module::Get()->pp_module(), format, &size.pp_size(), + instance->pp_instance(), format, &size.pp_size(), BoolToPPBool(init_to_zero))); } diff --git a/ppapi/cpp/image_data.h b/ppapi/cpp/image_data.h index 25f9156..673bcfc 100644 --- a/ppapi/cpp/image_data.h +++ b/ppapi/cpp/image_data.h @@ -12,6 +12,7 @@ namespace pp { +class Instance; class Plugin; class ImageData : public Resource { @@ -28,7 +29,8 @@ class ImageData : public Resource { // Allocates a new ImageData in the browser with the given parameters. The // resulting object will be is_null() if the allocation failed. - ImageData(PP_ImageDataFormat format, + ImageData(Instance* instance, + PP_ImageDataFormat format, const Size& size, bool init_to_zero); diff --git a/ppapi/cpp/paint_manager.cc b/ppapi/cpp/paint_manager.cc index a20cd0c..a555c52 100644 --- a/ppapi/cpp/paint_manager.cc +++ b/ppapi/cpp/paint_manager.cc @@ -56,7 +56,7 @@ void PaintManager::SetSize(const Size& new_size) { if (new_size == graphics_.size()) return; - graphics_ = Graphics2D(new_size, is_always_opaque_); + graphics_ = Graphics2D(instance_, new_size, is_always_opaque_); if (graphics_.is_null()) return; instance_->BindGraphics(graphics_); diff --git a/ppapi/cpp/var.cc b/ppapi/cpp/var.cc index 58ff30a..43bc869 100644 --- a/ppapi/cpp/var.cc +++ b/ppapi/cpp/var.cc @@ -12,6 +12,7 @@ #include "ppapi/c/pp_var.h" #include "ppapi/c/dev/ppb_var_deprecated.h" #include "ppapi/cpp/common.h" +#include "ppapi/cpp/instance.h" #include "ppapi/cpp/logging.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -92,10 +93,10 @@ Var::Var(const std::string& utf8_str) { needs_release_ = (var_.type == PP_VARTYPE_STRING); } -Var::Var(ScriptableObject* object) { +Var::Var(Instance* instance, ScriptableObject* object) { if (has_interface<PPB_Var_Deprecated>()) { var_ = get_interface<PPB_Var_Deprecated>()->CreateObject( - Module::Get()->pp_module(), object->GetClass(), object); + instance->pp_instance(), object->GetClass(), object); needs_release_ = true; } else { var_.type = PP_VARTYPE_NULL; diff --git a/ppapi/cpp/var.h b/ppapi/cpp/var.h index 9109fef..0fdd5f5 100644 --- a/ppapi/cpp/var.h +++ b/ppapi/cpp/var.h @@ -8,10 +8,13 @@ #include <string> #include <vector> +#include "ppapi/c/pp_module.h" #include "ppapi/c/pp_var.h" namespace pp { +class Instance; + namespace deprecated { class ScriptableObject; } @@ -49,7 +52,14 @@ class Var { } // Takes ownership of the given pointer. - Var(deprecated::ScriptableObject* object); + Var(Instance* instance, deprecated::ScriptableObject* object); + + // TODO(brettw) erase this! This is a temporary hack to keep the build + // going while we land the nacl side of this change. Calling this function + // will crash rather than break the compile. + Var(deprecated::ScriptableObject* /* object */) { + *(int*)0 = 3; + } Var(const Var& other); |