diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-15 03:44:13 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-15 03:44:13 +0000 |
commit | 859a7f3a9264b3a2174e9625d6cfa20412ac6081 (patch) | |
tree | b9911798925fbff065346fa6c085b254d7fb2e55 /ppapi/cpp | |
parent | f615770cd0412b2524b8b4451e6518608af9abed (diff) | |
download | chromium_src-859a7f3a9264b3a2174e9625d6cfa20412ac6081.zip chromium_src-859a7f3a9264b3a2174e9625d6cfa20412ac6081.tar.gz chromium_src-859a7f3a9264b3a2174e9625d6cfa20412ac6081.tar.bz2 |
Make PP_Resources associated with the Instance rather than the module. This
adds PP_Instance to the necessary places in the API to make this possible.
String and Object vars used to be PP_Resources. But it is not practical to
assocaited strings with an instance since then we can't have implicit var
constructors and have to litter every string with an instance. So this changes
vars to use their own tracking system associated with the module (i.e. keeping
the current semantics) and making it no longer a resource. I made the internal
Var IDs 32 bits since Neb is about to land his 64->32 change.
Now it force-deletes resources associated with an instance when that instance
goes away. I added some additional code and tracking in ResourceTracker to do
this. I could then remove the Instance::Observer class since the resource can
use the (now renamed) StoppedTracking to know that it's being deleted in
response to the instance being destroyed.
TEST=ppapi ui tests
BUG=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71544 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp')
-rw-r--r-- | ppapi/cpp/dev/buffer_dev.cc | 6 | ||||
-rw-r--r-- | ppapi/cpp/dev/buffer_dev.h | 4 | ||||
-rw-r--r-- | ppapi/cpp/dev/file_io_dev.cc | 6 | ||||
-rw-r--r-- | ppapi/cpp/dev/file_io_dev.h | 4 | ||||
-rw-r--r-- | ppapi/cpp/dev/font_dev.cc | 6 | ||||
-rw-r--r-- | ppapi/cpp/dev/font_dev.h | 2 | ||||
-rw-r--r-- | ppapi/cpp/dev/transport_dev.cc | 5 | ||||
-rw-r--r-- | ppapi/cpp/dev/transport_dev.h | 5 | ||||
-rw-r--r-- | ppapi/cpp/url_loader.cc | 8 | ||||
-rw-r--r-- | ppapi/cpp/url_loader.h | 8 | ||||
-rw-r--r-- | ppapi/cpp/url_request_info.cc | 5 | ||||
-rw-r--r-- | ppapi/cpp/url_request_info.h | 6 |
12 files changed, 48 insertions, 17 deletions
diff --git a/ppapi/cpp/dev/buffer_dev.cc b/ppapi/cpp/dev/buffer_dev.cc index 678211a..8a41ab4 100644 --- a/ppapi/cpp/dev/buffer_dev.cc +++ b/ppapi/cpp/dev/buffer_dev.cc @@ -28,12 +28,14 @@ Buffer_Dev::Buffer_Dev(const Buffer_Dev& other) size_(other.size_) { } -Buffer_Dev::Buffer_Dev(uint32_t size) : data_(NULL), size_(0) { +Buffer_Dev::Buffer_Dev(Instance* instance, uint32_t size) + : data_(NULL), + size_(0) { if (!has_interface<PPB_Buffer_Dev>()) return; PassRefFromConstructor(get_interface<PPB_Buffer_Dev>()->Create( - Module::Get()->pp_module(), size)); + instance->pp_instance(), size)); if (!get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_) || !(data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()))) *this = Buffer_Dev(); diff --git a/ppapi/cpp/dev/buffer_dev.h b/ppapi/cpp/dev/buffer_dev.h index e5f7325..83c265c2 100644 --- a/ppapi/cpp/dev/buffer_dev.h +++ b/ppapi/cpp/dev/buffer_dev.h @@ -9,6 +9,8 @@ namespace pp { +class Instance; + class Buffer_Dev : public Resource { public: // Creates an is_null() Buffer object. @@ -18,7 +20,7 @@ class Buffer_Dev : public Resource { // Allocates a new Buffer in the browser with the given size. The // resulting object will be is_null() if the allocation failed. - explicit Buffer_Dev(uint32_t size); + Buffer_Dev(Instance* instance, uint32_t size); uint32_t size() const { return size_; } void* data() const { return data_; } diff --git a/ppapi/cpp/dev/file_io_dev.cc b/ppapi/cpp/dev/file_io_dev.cc index 5dae1d3..1fc273b 100644 --- a/ppapi/cpp/dev/file_io_dev.cc +++ b/ppapi/cpp/dev/file_io_dev.cc @@ -9,6 +9,7 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/dev/file_ref_dev.h" +#include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -23,10 +24,13 @@ template <> const char* interface_name<PPB_FileIO_Dev>() { } // namespace FileIO_Dev::FileIO_Dev() { +} + +FileIO_Dev::FileIO_Dev(Instance* instance) { if (!has_interface<PPB_FileIO_Dev>()) return; PassRefFromConstructor(get_interface<PPB_FileIO_Dev>()->Create( - Module::Get()->pp_module())); + instance->pp_instance())); } FileIO_Dev::FileIO_Dev(const FileIO_Dev& other) diff --git a/ppapi/cpp/dev/file_io_dev.h b/ppapi/cpp/dev/file_io_dev.h index 1da3652..532f76a 100644 --- a/ppapi/cpp/dev/file_io_dev.h +++ b/ppapi/cpp/dev/file_io_dev.h @@ -14,10 +14,14 @@ namespace pp { class CompletionCallback; class FileRef_Dev; +class Instance; class FileIO_Dev : public Resource { public: + // Constructs an is_null resource. FileIO_Dev(); + + FileIO_Dev(Instance* instance); FileIO_Dev(const FileIO_Dev& other); // PPB_FileIO methods: diff --git a/ppapi/cpp/dev/font_dev.cc b/ppapi/cpp/dev/font_dev.cc index 6394b81..4ca85b0 100644 --- a/ppapi/cpp/dev/font_dev.cc +++ b/ppapi/cpp/dev/font_dev.cc @@ -8,7 +8,7 @@ #include "ppapi/cpp/common.h" #include "ppapi/cpp/image_data.h" -#include "ppapi/cpp/module.h" +#include "ppapi/cpp/instance.h" #include "ppapi/cpp/point.h" #include "ppapi/cpp/rect.h" #include "ppapi/cpp/module_impl.h" @@ -103,11 +103,11 @@ Font_Dev::Font_Dev() : Resource() { Font_Dev::Font_Dev(PP_Resource resource) : Resource(resource) { } -Font_Dev::Font_Dev(const FontDescription_Dev& description) { +Font_Dev::Font_Dev(Instance* instance, const FontDescription_Dev& description) { if (!has_interface<PPB_Font_Dev>()) return; PassRefFromConstructor(get_interface<PPB_Font_Dev>()->Create( - Module::Get()->pp_module(), &description.pp_font_description())); + instance->pp_instance(), &description.pp_font_description())); } Font_Dev::Font_Dev(const Font_Dev& other) : Resource(other) { diff --git a/ppapi/cpp/dev/font_dev.h b/ppapi/cpp/dev/font_dev.h index 137258c..fb31311 100644 --- a/ppapi/cpp/dev/font_dev.h +++ b/ppapi/cpp/dev/font_dev.h @@ -105,7 +105,7 @@ class Font_Dev : public Resource { Font_Dev(); explicit Font_Dev(PP_Resource resource); - explicit Font_Dev(const FontDescription_Dev& description); + explicit Font_Dev(Instance* instance, const FontDescription_Dev& description); Font_Dev(const Font_Dev& other); Font_Dev& operator=(const Font_Dev& other); diff --git a/ppapi/cpp/dev/transport_dev.cc b/ppapi/cpp/dev/transport_dev.cc index 0ea4a34..241c3bd 100644 --- a/ppapi/cpp/dev/transport_dev.cc +++ b/ppapi/cpp/dev/transport_dev.cc @@ -19,11 +19,12 @@ template <> const char* interface_name<PPB_Transport_Dev>() { } // namespace -Transport_Dev::Transport_Dev(const char* name, +Transport_Dev::Transport_Dev(Instance* instance, + const char* name, const char* proto) { if (has_interface<PPB_Transport_Dev>()) PassRefFromConstructor(get_interface<PPB_Transport_Dev>()->CreateTransport( - Module::Get()->pp_module(), name, proto)); + instance->pp_instance(), name, proto)); } } // namespace pp diff --git a/ppapi/cpp/dev/transport_dev.h b/ppapi/cpp/dev/transport_dev.h index a9b73c2..a03b232 100644 --- a/ppapi/cpp/dev/transport_dev.h +++ b/ppapi/cpp/dev/transport_dev.h @@ -6,15 +6,16 @@ #define PPAPI_CPP_DEV_TRANSPORT_DEV_H_ #include "ppapi/c/dev/ppb_transport_dev.h" -#include "ppapi/cpp/instance.h" #include "ppapi/cpp/resource.h" namespace pp { +class Instance; + class Transport_Dev : public Resource { public: Transport_Dev() {} - Transport_Dev(const char* name, const char* proto); + Transport_Dev(Instance* instance, const char* name, const char* proto); }; } // namespace pp diff --git a/ppapi/cpp/url_loader.cc b/ppapi/cpp/url_loader.cc index 8ef6087..81bcdfd 100644 --- a/ppapi/cpp/url_loader.cc +++ b/ppapi/cpp/url_loader.cc @@ -28,6 +28,7 @@ template <> const char* interface_name<PPB_URLLoader>() { URLLoader::URLLoader(PP_Resource resource) : Resource(resource) { } +// TODO(brettw) remove this when NaCl is updated. URLLoader::URLLoader(const Instance& instance) { if (!has_interface<PPB_URLLoader>()) return; @@ -35,6 +36,13 @@ URLLoader::URLLoader(const Instance& instance) { instance.pp_instance())); } +URLLoader::URLLoader(Instance* instance) { + if (!has_interface<PPB_URLLoader>()) + return; + PassRefFromConstructor(get_interface<PPB_URLLoader>()->Create( + instance->pp_instance())); +} + URLLoader::URLLoader(const URLLoader& other) : Resource(other) { } diff --git a/ppapi/cpp/url_loader.h b/ppapi/cpp/url_loader.h index 15f81fa..387d1dc2 100644 --- a/ppapi/cpp/url_loader.h +++ b/ppapi/cpp/url_loader.h @@ -21,7 +21,7 @@ class URLResponseInfo; // // class MyHandler { // public: -// MyHandler(const Instance& instance) +// MyHandler(Instance* instance) // : factory_(this), // loader_(instance), // did_open_(false) { @@ -80,8 +80,12 @@ class URLLoader : public Resource { // Creates an is_null() URLLoader object. URLLoader() {} - explicit URLLoader(PP_Resource resource); + // TODO(brettw) remove this when NaCl is updated to use the new version + // that takes a pointer. explicit URLLoader(const Instance& instance); + + explicit URLLoader(PP_Resource resource); + explicit URLLoader(Instance* instance); URLLoader(const URLLoader& other); // PPB_URLLoader methods: diff --git a/ppapi/cpp/url_request_info.cc b/ppapi/cpp/url_request_info.cc index 30f339b..76cf832 100644 --- a/ppapi/cpp/url_request_info.cc +++ b/ppapi/cpp/url_request_info.cc @@ -6,6 +6,7 @@ #include "ppapi/cpp/common.h" #include "ppapi/cpp/dev/file_ref_dev.h" +#include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -19,11 +20,11 @@ template <> const char* interface_name<PPB_URLRequestInfo>() { } // namespace -URLRequestInfo::URLRequestInfo() { +URLRequestInfo::URLRequestInfo(Instance* instance) { if (!has_interface<PPB_URLRequestInfo>()) return; PassRefFromConstructor( - get_interface<PPB_URLRequestInfo>()->Create(Module::Get()->pp_module())); + get_interface<PPB_URLRequestInfo>()->Create(instance->pp_instance())); } URLRequestInfo::URLRequestInfo(const URLRequestInfo& other) diff --git a/ppapi/cpp/url_request_info.h b/ppapi/cpp/url_request_info.h index 10defc1..3c7c47d 100644 --- a/ppapi/cpp/url_request_info.h +++ b/ppapi/cpp/url_request_info.h @@ -12,10 +12,14 @@ namespace pp { class FileRef_Dev; +class Instance; class URLRequestInfo : public Resource { public: - URLRequestInfo(); + // Creates an is_null resource. + URLRequestInfo() {} + + explicit URLRequestInfo(Instance* instance); URLRequestInfo(const URLRequestInfo& other); // PPB_URLRequestInfo methods: |