summaryrefslogtreecommitdiffstats
path: root/ppapi/thunk
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-18 15:41:01 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-18 15:41:01 +0000
commit7f8b26b5f223689de7af4803bc07e1e953ff5953 (patch)
treed6f3e574d97c6253b8b202264fe23dea1b489dc2 /ppapi/thunk
parentd8886526085a42874663be638be1421e78f6172c (diff)
downloadchromium_src-7f8b26b5f223689de7af4803bc07e1e953ff5953.zip
chromium_src-7f8b26b5f223689de7af4803bc07e1e953ff5953.tar.gz
chromium_src-7f8b26b5f223689de7af4803bc07e1e953ff5953.tar.bz2
Add a unified resource tracker shared between the proxy and the impl.
This renames the old ResourceObjectBase to Resource and removes the old PluginResource. It moves the resource tracker from the impl to the shared_impl, and makes the proxy use it. Some things become a little less neat because there's no proxy resource base class. In particular GetDispatcher() is now gone. I considered whether to add a helper base class that provides this function, but decided against it and had individual resource classes implement this when their implementation would find it useful. This is because ultimately I want more of this functionality to move into the shared_impl, and it's easier to do that if there are fewer proxy-specific things in the resources. This changes the way that plugins are added to the tracker. Previously they would only be in the tracker if the plugin had a reference to them, although they could be alive if the impl had a scoped_ptr referencing an object. This actually has the bug that if we then give the resource back to the plugin, it wouldn't be refcounted properly and everything would get confused. Now the tracker tracks all live resource objects whether or not the plugin has a ref. This works basically like the var tracker (it would be nice if the var and resource trackers shared more code, but that would further complicate this already overcomplicated patch). The resource tracker takes an extra ref whenever the plugin has one or more, and otherwise just tracks live resources. Review URL: http://codereview.chromium.org/7629017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97314 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk')
-rw-r--r--ppapi/thunk/enter.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/ppapi/thunk/enter.h b/ppapi/thunk/enter.h
index ea2fc82..e7f0d0f 100644
--- a/ppapi/thunk/enter.h
+++ b/ppapi/thunk/enter.h
@@ -9,8 +9,9 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/proxy/interface_id.h"
#include "ppapi/shared_impl/function_group_base.h"
-#include "ppapi/shared_impl/resource_object_base.h"
+#include "ppapi/shared_impl/resource.h"
#include "ppapi/shared_impl/tracker_base.h"
+#include "ppapi/shared_impl/resource_tracker.h"
namespace ppapi {
namespace thunk {
@@ -77,9 +78,15 @@ template<typename FunctionsT>
class EnterFunctionGivenResource : public EnterFunction<FunctionsT> {
public:
EnterFunctionGivenResource(PP_Resource resource, bool report_error)
- : EnterFunction<FunctionsT>(
- TrackerBase::Get()->GetInstanceForResource(resource),
- report_error) {
+ : EnterFunction<FunctionsT>(GetInstanceForResource(resource),
+ report_error) {
+ }
+
+ private:
+ static PP_Instance GetInstanceForResource(PP_Resource resource) {
+ Resource* object =
+ TrackerBase::Get()->GetResourceTracker()->GetResource(resource);
+ return object ? object->pp_instance() : 0;
}
};
@@ -90,7 +97,8 @@ class EnterResource {
public:
EnterResource(PP_Resource resource, bool report_error)
: object_(NULL) {
- ResourceObjectBase* base = TrackerBase::Get()->GetResourceAPI(resource);
+ Resource* base =
+ TrackerBase::Get()->GetResourceTracker()->GetResource(resource);
if (base)
object_ = base->GetAs<ResourceT>();
// TODO(brettw) check error and if report_error is set, do something.