summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-20 22:51:01 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-20 22:51:01 +0000
commit2f59e3827f5bf5dc1cad0a0a393feef965abc6bc (patch)
tree156a9acb7570a78e31256f03726bd0b8984c8f3e
parent7969c78bba2a31c8b50f4e19e497bf81694f6388 (diff)
downloadchromium_src-2f59e3827f5bf5dc1cad0a0a393feef965abc6bc.zip
chromium_src-2f59e3827f5bf5dc1cad0a0a393feef965abc6bc.tar.gz
chromium_src-2f59e3827f5bf5dc1cad0a0a393feef965abc6bc.tar.bz2
Remove TrackerBase.
Fold the methods it provided into the PpapiGlobals base class. Move the instance and module tracking in the webkit/plugins/ppapi dir out of the HostResourceTracker (since it has nothing to do with resources) and into the HostGlobals object (which provides general global object tracking). TEST=none BUG=none Review URL: http://codereview.chromium.org/8335001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106612 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/renderer/chrome_ppb_pdf_impl.cc24
-rw-r--r--ppapi/ppapi_shared.gypi2
-rw-r--r--ppapi/proxy/plugin_dispatcher.cc2
-rw-r--r--ppapi/proxy/plugin_globals.cc15
-rw-r--r--ppapi/proxy/plugin_globals.h3
-rw-r--r--ppapi/proxy/plugin_resource_tracker.cc27
-rw-r--r--ppapi/proxy/plugin_resource_tracker.h11
-rw-r--r--ppapi/shared_impl/file_ref_impl.cc6
-rw-r--r--ppapi/shared_impl/input_event_impl.cc4
-rw-r--r--ppapi/shared_impl/ppapi_globals.h14
-rw-r--r--ppapi/shared_impl/resource_tracker_unittest.cc24
-rw-r--r--ppapi/shared_impl/test_globals.cc9
-rw-r--r--ppapi/shared_impl/test_globals.h3
-rw-r--r--ppapi/shared_impl/tracker_base.cc23
-rw-r--r--ppapi/shared_impl/tracker_base.h54
-rw-r--r--ppapi/shared_impl/url_util_impl.cc1
-rw-r--r--ppapi/thunk/enter.h3
-rw-r--r--webkit/plugins/ppapi/host_globals.cc157
-rw-r--r--webkit/plugins/ppapi/host_globals.h50
-rw-r--r--webkit/plugins/ppapi/host_resource_tracker.cc174
-rw-r--r--webkit/plugins/ppapi/host_resource_tracker.h90
-rw-r--r--webkit/plugins/ppapi/host_var_tracker.h1
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc4
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc10
-rw-r--r--webkit/plugins/ppapi/ppb_audio_impl.cc1
-rw-r--r--webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc7
-rw-r--r--webkit/plugins/ppapi/ppb_flash_file_impl.cc19
-rw-r--r--webkit/plugins/ppapi/ppb_flash_impl.cc13
-rw-r--r--webkit/plugins/ppapi/ppb_proxy_impl.cc16
-rw-r--r--webkit/plugins/ppapi/ppb_var_impl.cc10
-rw-r--r--webkit/plugins/ppapi/quota_file_io.cc4
-rw-r--r--webkit/plugins/ppapi/resource_helper.cc4
32 files changed, 299 insertions, 486 deletions
diff --git a/chrome/renderer/chrome_ppb_pdf_impl.cc b/chrome/renderer/chrome_ppb_pdf_impl.cc
index cba3ac8..21e3a3e 100644
--- a/chrome/renderer/chrome_ppb_pdf_impl.cc
+++ b/chrome/renderer/chrome_ppb_pdf_impl.cc
@@ -17,7 +17,6 @@
#include "ppapi/c/private/ppb_pdf.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/shared_impl/resource_tracker.h"
-#include "ppapi/shared_impl/tracker_base.h"
#include "ppapi/shared_impl/var.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
@@ -38,6 +37,7 @@
using ppapi::PpapiGlobals;
using webkit::ppapi::HostGlobals;
+using webkit::ppapi::PluginInstance;
using WebKit::WebView;
using content::RenderThread;
@@ -125,8 +125,7 @@ static const ResourceImageInfo kResourceImageMap[] = {
PP_Var GetLocalizedString(PP_Instance instance_id,
PP_ResourceString string_id) {
- webkit::ppapi::PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
if (!instance)
return PP_MakeUndefined();
@@ -162,7 +161,7 @@ PP_Resource GetResourceImage(PP_Instance instance_id,
ResourceBundle::GetSharedInstance().GetBitmapNamed(res_id);
// Validate the instance.
- if (!HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id))
+ if (!HostGlobals::Get()->GetInstance(instance_id))
return 0;
scoped_refptr<webkit::ppapi::PPB_ImageData_Impl> image_data(
new webkit::ppapi::PPB_ImageData_Impl(instance_id));
@@ -190,7 +189,7 @@ PP_Resource GetFontFileWithFallback(
PP_PrivateFontCharset charset) {
#if defined(OS_LINUX)
// Validate the instance before using it below.
- if (!HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id))
+ if (!HostGlobals::Get()->GetInstance(instance_id))
return 0;
scoped_refptr<ppapi::StringVar> face_name(ppapi::StringVar::FromPPVar(
@@ -284,24 +283,21 @@ void SearchString(PP_Instance instance,
}
void DidStartLoading(PP_Instance instance_id) {
- webkit::ppapi::PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
if (!instance)
return;
instance->delegate()->DidStartLoading();
}
void DidStopLoading(PP_Instance instance_id) {
- webkit::ppapi::PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
if (!instance)
return;
instance->delegate()->DidStopLoading();
}
void SetContentRestriction(PP_Instance instance_id, int restrictions) {
- webkit::ppapi::PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
if (!instance)
return;
instance->delegate()->SetContentRestriction(restrictions);
@@ -319,8 +315,7 @@ void UserMetricsRecordAction(PP_Var action) {
}
void HasUnsupportedFeature(PP_Instance instance_id) {
- webkit::ppapi::PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
if (!instance)
return;
@@ -335,8 +330,7 @@ void HasUnsupportedFeature(PP_Instance instance_id) {
}
void SaveAs(PP_Instance instance_id) {
- webkit::ppapi::PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
if (!instance)
return;
instance->delegate()->SaveURLAs(instance->plugin_url());
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index 80055ae..1b5572e 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -72,8 +72,6 @@
'shared_impl/scoped_pp_resource.h',
'shared_impl/time_conversion.cc',
'shared_impl/time_conversion.h',
- 'shared_impl/tracker_base.cc',
- 'shared_impl/tracker_base.h',
'shared_impl/url_request_info_impl.cc',
'shared_impl/url_request_info_impl.h',
'shared_impl/url_util_impl.cc',
diff --git a/ppapi/proxy/plugin_dispatcher.cc b/ppapi/proxy/plugin_dispatcher.cc
index 2bed859..c036c01 100644
--- a/ppapi/proxy/plugin_dispatcher.cc
+++ b/ppapi/proxy/plugin_dispatcher.cc
@@ -25,7 +25,6 @@
#include "ppapi/proxy/ppp_class_proxy.h"
#include "ppapi/proxy/resource_creation_proxy.h"
#include "ppapi/shared_impl/resource.h"
-#include "ppapi/shared_impl/tracker_base.h"
#if defined(OS_POSIX)
#include "base/eintr_wrapper.h"
@@ -54,7 +53,6 @@ PluginDispatcher::PluginDispatcher(base::ProcessHandle remote_process_handle,
received_preferences_(false),
plugin_dispatcher_id_(0) {
SetSerializationRules(new PluginVarSerializationRules);
- TrackerBase::Init(&PluginResourceTracker::GetTrackerBaseInstance);
}
PluginDispatcher::~PluginDispatcher() {
diff --git a/ppapi/proxy/plugin_globals.cc b/ppapi/proxy/plugin_globals.cc
index 888c3bd..9aa5278 100644
--- a/ppapi/proxy/plugin_globals.cc
+++ b/ppapi/proxy/plugin_globals.cc
@@ -4,6 +4,8 @@
#include "ppapi/proxy/plugin_globals.h"
+#include "ppapi/proxy/plugin_dispatcher.h"
+
namespace ppapi {
namespace proxy {
@@ -27,5 +29,18 @@ VarTracker* PluginGlobals::GetVarTracker() {
return &plugin_var_tracker_;
}
+FunctionGroupBase* PluginGlobals::GetFunctionAPI(PP_Instance inst,
+ proxy::InterfaceID id) {
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(inst);
+ if (dispatcher)
+ return dispatcher->GetFunctionAPI(id);
+ return NULL;
+}
+
+PP_Module PluginGlobals::GetModuleForInstance(PP_Instance instance) {
+ // Currently proxied plugins don't use the PP_Module for anything useful.
+ return 0;
+}
+
} // namespace proxy
} // namespace ppapi
diff --git a/ppapi/proxy/plugin_globals.h b/ppapi/proxy/plugin_globals.h
index 70dea89..ee4fac4 100644
--- a/ppapi/proxy/plugin_globals.h
+++ b/ppapi/proxy/plugin_globals.h
@@ -27,6 +27,9 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals {
// PpapiGlobals implementation.
virtual ResourceTracker* GetResourceTracker() OVERRIDE;
virtual VarTracker* GetVarTracker() OVERRIDE;
+ virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst,
+ proxy::InterfaceID id) OVERRIDE;
+ virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE;
// Getters for the plugin-specific versions.
PluginResourceTracker* plugin_resource_tracker() {
diff --git a/ppapi/proxy/plugin_resource_tracker.cc b/ppapi/proxy/plugin_resource_tracker.cc
index 67e2d69..e91b35f 100644
--- a/ppapi/proxy/plugin_resource_tracker.cc
+++ b/ppapi/proxy/plugin_resource_tracker.cc
@@ -12,20 +12,11 @@
#include "ppapi/proxy/serialized_var.h"
#include "ppapi/shared_impl/proxy_lock.h"
#include "ppapi/shared_impl/resource.h"
-#include "ppapi/shared_impl/tracker_base.h"
#include "ppapi/shared_impl/var.h"
namespace ppapi {
namespace proxy {
-namespace {
-
-TrackerBase* GetTrackerBase() {
- return PluginGlobals::Get()->plugin_resource_tracker();
-}
-
-} // namespace
-
PluginResourceTracker::PluginResourceTracker() {
#ifdef ENABLE_PEPPER_THREADING
// Set the global proxy lock, since the plugin-side of the proxy needs to be
@@ -40,11 +31,6 @@ PluginResourceTracker::~PluginResourceTracker() {
#endif
}
-// static
-TrackerBase* PluginResourceTracker::GetTrackerBaseInstance() {
- return GetTrackerBase();
-}
-
PP_Resource PluginResourceTracker::PluginResourceForHostResource(
const HostResource& resource) const {
HostResourceMap::const_iterator found = host_resource_map_.find(resource);
@@ -53,19 +39,6 @@ PP_Resource PluginResourceTracker::PluginResourceForHostResource(
return found->second;
}
-FunctionGroupBase* PluginResourceTracker::GetFunctionAPI(PP_Instance inst,
- InterfaceID id) {
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(inst);
- if (dispatcher)
- return dispatcher->GetFunctionAPI(id);
- return NULL;
-}
-
-PP_Module PluginResourceTracker::GetModuleForInstance(PP_Instance instance) {
- // Currently proxied plugins don't use the PP_Module for anything useful.
- return 0;
-}
-
PP_Resource PluginResourceTracker::AddResource(Resource* object) {
PP_Resource ret = ResourceTracker::AddResource(object);
diff --git a/ppapi/proxy/plugin_resource_tracker.h b/ppapi/proxy/plugin_resource_tracker.h
index cf87787..b87c6f8 100644
--- a/ppapi/proxy/plugin_resource_tracker.h
+++ b/ppapi/proxy/plugin_resource_tracker.h
@@ -18,7 +18,6 @@
#include "ppapi/proxy/ppapi_proxy_export.h"
#include "ppapi/shared_impl/host_resource.h"
#include "ppapi/shared_impl/resource_tracker.h"
-#include "ppapi/shared_impl/tracker_base.h"
template<typename T> struct DefaultSingletonTraits;
@@ -30,24 +29,16 @@ namespace proxy {
class PluginDispatcher;
-class PPAPI_PROXY_EXPORT PluginResourceTracker : public TrackerBase,
- public ResourceTracker {
+class PPAPI_PROXY_EXPORT PluginResourceTracker : public ResourceTracker {
public:
PluginResourceTracker();
virtual ~PluginResourceTracker();
- static TrackerBase* GetTrackerBaseInstance();
-
// Given a host resource, maps it to an existing plugin resource ID if it
// exists, or returns 0 on failure.
PP_Resource PluginResourceForHostResource(
const HostResource& resource) const;
- // TrackerBase.
- virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst,
- InterfaceID id) OVERRIDE;
- virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE;
-
protected:
// ResourceTracker overrides.
virtual PP_Resource AddResource(Resource* object) OVERRIDE;
diff --git a/ppapi/shared_impl/file_ref_impl.cc b/ppapi/shared_impl/file_ref_impl.cc
index 1eae27b..274d944 100644
--- a/ppapi/shared_impl/file_ref_impl.cc
+++ b/ppapi/shared_impl/file_ref_impl.cc
@@ -5,7 +5,7 @@
#include "ppapi/shared_impl/file_ref_impl.h"
#include "base/logging.h"
-#include "ppapi/shared_impl/tracker_base.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/var.h"
namespace ppapi {
@@ -41,7 +41,7 @@ PP_FileSystemType FileRefImpl::GetFileSystemType() const {
PP_Var FileRefImpl::GetName() const {
if (!name_var_.get()) {
name_var_ = new StringVar(
- TrackerBase::Get()->GetModuleForInstance(pp_instance()),
+ PpapiGlobals::Get()->GetModuleForInstance(pp_instance()),
create_info_.name);
}
return name_var_->GetPPVar();
@@ -52,7 +52,7 @@ PP_Var FileRefImpl::GetPath() const {
return PP_MakeUndefined();
if (!path_var_.get()) {
path_var_ = new StringVar(
- TrackerBase::Get()->GetModuleForInstance(pp_instance()),
+ PpapiGlobals::Get()->GetModuleForInstance(pp_instance()),
create_info_.path);
}
return path_var_->GetPPVar();
diff --git a/ppapi/shared_impl/input_event_impl.cc b/ppapi/shared_impl/input_event_impl.cc
index d0ca57c..d502a62 100644
--- a/ppapi/shared_impl/input_event_impl.cc
+++ b/ppapi/shared_impl/input_event_impl.cc
@@ -4,7 +4,7 @@
#include "ppapi/shared_impl/input_event_impl.h"
-#include "ppapi/shared_impl/tracker_base.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/var.h"
using ppapi::thunk::PPB_InputEvent_API;
@@ -101,7 +101,7 @@ uint32_t InputEventImpl::GetKeyCode() {
PP_Var InputEventImpl::GetCharacterText() {
return StringVar::StringToPPVar(
- TrackerBase::Get()->GetModuleForInstance(pp_instance()),
+ PpapiGlobals::Get()->GetModuleForInstance(pp_instance()),
data_.character_text);
}
diff --git a/ppapi/shared_impl/ppapi_globals.h b/ppapi/shared_impl/ppapi_globals.h
index d0936ee..db91f72 100644
--- a/ppapi/shared_impl/ppapi_globals.h
+++ b/ppapi/shared_impl/ppapi_globals.h
@@ -6,10 +6,14 @@
#define PPAPI_SHARED_IMPL_PPAPI_GLOBALS_H_
#include "base/basictypes.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_module.h"
+#include "ppapi/proxy/interface_id.h"
#include "ppapi/shared_impl/ppapi_shared_export.h"
namespace ppapi {
+class FunctionGroupBase;
class ResourceTracker;
class VarTracker;
@@ -22,9 +26,19 @@ class PPAPI_SHARED_EXPORT PpapiGlobals {
// Getter for the global singleton.
inline static PpapiGlobals* Get() { return ppapi_globals_; }
+ // Retrieves the corresponding tracker.
virtual ResourceTracker* GetResourceTracker() = 0;
virtual VarTracker* GetVarTracker() = 0;
+ // Returns the function object corresponding to the given ID, or NULL if
+ // there isn't one.
+ virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst,
+ proxy::InterfaceID id) = 0;
+
+ // Returns the PP_Module associated with the given PP_Instance, or 0 on
+ // failure.
+ virtual PP_Module GetModuleForInstance(PP_Instance instance) = 0;
+
private:
static PpapiGlobals* ppapi_globals_;
diff --git a/ppapi/shared_impl/resource_tracker_unittest.cc b/ppapi/shared_impl/resource_tracker_unittest.cc
index 2e22d6a..a77dc78 100644
--- a/ppapi/shared_impl/resource_tracker_unittest.cc
+++ b/ppapi/shared_impl/resource_tracker_unittest.cc
@@ -8,7 +8,6 @@
#include "ppapi/shared_impl/resource.h"
#include "ppapi/shared_impl/resource_tracker.h"
#include "ppapi/shared_impl/test_globals.h"
-#include "ppapi/shared_impl/tracker_base.h"
namespace ppapi {
@@ -37,40 +36,19 @@ class MyMockResource : public Resource {
}
};
-// Global singleton used by the TrackerBase.
-TrackerBase* my_tracker_base = NULL;
-TrackerBase* GetMyTrackerBase() {
- return my_tracker_base;
-}
-
} // namespace
-class ResourceTrackerTest : public testing::Test, public TrackerBase {
+class ResourceTrackerTest : public testing::Test {
public:
ResourceTrackerTest() {}
// Test implementation.
virtual void SetUp() OVERRIDE {
- my_tracker_base = this;
- TrackerBase::Init(&GetMyTrackerBase);
-
ASSERT_EQ(0, mock_resource_alive_count);
last_plugin_ref_was_deleted_count = 0;
instance_was_deleted_count = 0;
}
virtual void TearDown() OVERRIDE {
- my_tracker_base = NULL;
- TrackerBase::Init(NULL);
- }
-
- // TrackerBase implementation.
- virtual FunctionGroupBase* GetFunctionAPI(
- PP_Instance inst,
- ppapi::proxy::InterfaceID id) OVERRIDE {
- return NULL;
- }
- virtual PP_Module GetModuleForInstance(PP_Instance /* instance */) OVERRIDE {
- return 0;
}
ResourceTracker& resource_tracker() { return *globals_.GetResourceTracker(); }
diff --git a/ppapi/shared_impl/test_globals.cc b/ppapi/shared_impl/test_globals.cc
index 17ac224..8813748 100644
--- a/ppapi/shared_impl/test_globals.cc
+++ b/ppapi/shared_impl/test_globals.cc
@@ -20,4 +20,13 @@ VarTracker* TestGlobals::GetVarTracker() {
return &var_tracker_;
}
+FunctionGroupBase* TestGlobals::GetFunctionAPI(PP_Instance inst,
+ proxy::InterfaceID id) {
+ return NULL;
+}
+
+PP_Module TestGlobals::GetModuleForInstance(PP_Instance instance) {
+ return 0;
+}
+
} // namespace ppapi
diff --git a/ppapi/shared_impl/test_globals.h b/ppapi/shared_impl/test_globals.h
index c2062b7..d475363 100644
--- a/ppapi/shared_impl/test_globals.h
+++ b/ppapi/shared_impl/test_globals.h
@@ -22,6 +22,9 @@ class TestGlobals : public PpapiGlobals {
// PpapiGlobals implementation.
virtual ResourceTracker* GetResourceTracker() OVERRIDE;
virtual VarTracker* GetVarTracker() OVERRIDE;
+ virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst,
+ proxy::InterfaceID id) OVERRIDE;
+ virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE;
private:
ResourceTracker resource_tracker_;
diff --git a/ppapi/shared_impl/tracker_base.cc b/ppapi/shared_impl/tracker_base.cc
deleted file mode 100644
index 291bc18..0000000
--- a/ppapi/shared_impl/tracker_base.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ppapi/shared_impl/tracker_base.h"
-
-#include "base/logging.h"
-
-namespace ppapi {
-
-static TrackerBase* (*g_global_getter)() = NULL;
-
-// static
-void TrackerBase::Init(TrackerBase* (*getter)()) {
- g_global_getter = getter;
-}
-
-// static
-TrackerBase* TrackerBase::Get() {
- return g_global_getter();
-}
-
-} // namespace ppapi
diff --git a/ppapi/shared_impl/tracker_base.h b/ppapi/shared_impl/tracker_base.h
deleted file mode 100644
index 940cef4..0000000
--- a/ppapi/shared_impl/tracker_base.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef PPAPI_SHARED_IMPL_TRACKER_BASE_H_
-#define PPAPI_SHARED_IMPL_TRACKER_BASE_H_
-
-#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
-#include "ppapi/c/pp_instance.h"
-#include "ppapi/c/pp_module.h"
-#include "ppapi/c/pp_resource.h"
-#include "ppapi/proxy/interface_id.h"
-#include "ppapi/shared_impl/ppapi_shared_export.h"
-
-namespace ppapi {
-
-class FunctionGroupBase;
-class ResourceTracker;
-class VarTracker;
-
-// Tracks resource and function APIs, providing a mapping between ID and
-// object.
-// TODO(brettw) Eventually this should be one object with global tracking and
-// called "Tracker", and this would be used in both the plugin side of the
-// proxy as well as the implementation in the renderer. Currently, all this
-// does is forward to the process-type-specific tracker to get the information.
-// TODO(fischman/vrk): When brettw fixes the TODO above, fix the ugliness in
-// VideoDecoderImpl accordingly.
-class PPAPI_SHARED_EXPORT TrackerBase {
- public:
- // Must be called before any other function that uses the TrackerBase.
- // This sets the getter that returns the global implmenetation of
- // TrackerBase. It will be different for in the renderer and in the plugin
- // process.
- static void Init(TrackerBase*(*getter)());
-
- // Retrieves the global tracker. This will be NULL if you haven't called
- // Init() first (it should be unnecessary to NULL-check this).
- static TrackerBase* Get();
-
- // Returns the function object corresponding to the given ID, or NULL if
- // there isn't one.
- virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst,
- proxy::InterfaceID id) = 0;
-
- // Returns the PP_Module associated with the given PP_Instance, or 0 on
- // failure.
- virtual PP_Module GetModuleForInstance(PP_Instance instance) = 0;
-};
-
-} // namespace ppapi
-
-#endif // PPAPI_SHARED_IMPL_TRACKER_BASE_H_
diff --git a/ppapi/shared_impl/url_util_impl.cc b/ppapi/shared_impl/url_util_impl.cc
index d295fd7..fdccdb6 100644
--- a/ppapi/shared_impl/url_util_impl.cc
+++ b/ppapi/shared_impl/url_util_impl.cc
@@ -6,7 +6,6 @@
#include "googleurl/src/gurl.h"
#include "ppapi/shared_impl/ppapi_globals.h"
-#include "ppapi/shared_impl/tracker_base.h"
#include "ppapi/shared_impl/var.h"
#include "ppapi/shared_impl/var_tracker.h"
diff --git a/ppapi/thunk/enter.h b/ppapi/thunk/enter.h
index faa556d..5504f68 100644
--- a/ppapi/thunk/enter.h
+++ b/ppapi/thunk/enter.h
@@ -13,7 +13,6 @@
#include "ppapi/shared_impl/proxy_lock.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/shared_impl/resource_tracker.h"
-#include "ppapi/shared_impl/tracker_base.h"
#include "ppapi/thunk/ppapi_thunk_export.h"
#include "ppapi/thunk/ppb_instance_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -75,7 +74,7 @@ class EnterFunction : subtle::LockOnEntry<lock_on_entry> {
public:
EnterFunction(PP_Instance instance, bool report_error)
: functions_(NULL) {
- FunctionGroupBase* base = TrackerBase::Get()->GetFunctionAPI(
+ FunctionGroupBase* base = PpapiGlobals::Get()->GetFunctionAPI(
instance, FunctionsT::interface_id);
if (base)
functions_ = base->GetAs<FunctionsT>();
diff --git a/webkit/plugins/ppapi/host_globals.cc b/webkit/plugins/ppapi/host_globals.cc
index 3a3626f..b2048aa 100644
--- a/webkit/plugins/ppapi/host_globals.cc
+++ b/webkit/plugins/ppapi/host_globals.cc
@@ -4,9 +4,39 @@
#include "webkit/plugins/ppapi/host_globals.h"
+#include <limits>
+
+#include "base/logging.h"
+#include "base/rand_util.h"
+#include "ppapi/proxy/interface_id.h"
+#include "ppapi/shared_impl/function_group_base.h"
+#include "ppapi/shared_impl/id_assignment.h"
+#include "webkit/plugins/ppapi/plugin_module.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+#include "webkit/plugins/ppapi/ppb_cursor_control_impl.h"
+#include "webkit/plugins/ppapi/ppb_font_impl.h"
+#include "webkit/plugins/ppapi/ppb_text_input_impl.h"
+#include "webkit/plugins/ppapi/resource_creation_impl.h"
+
+using ppapi::CheckIdType;
+using ppapi::MakeTypedId;
+using ppapi::PPIdType;
+
namespace webkit {
namespace ppapi {
+struct HostGlobals::InstanceData {
+ InstanceData() : instance(0) {}
+
+ // Non-owning pointer to the instance object. When a PluginInstance is
+ // destroyed, it will notify us and we'll delete all associated data.
+ PluginInstance* instance;
+
+ // Lazily allocated function proxies for the different interfaces.
+ scoped_ptr< ::ppapi::FunctionGroupBase >
+ function_proxies[::ppapi::proxy::INTERFACE_ID_COUNT];
+};
+
HostGlobals* HostGlobals::host_globals_ = NULL;
HostGlobals::HostGlobals() : ::ppapi::PpapiGlobals() {
@@ -27,5 +57,132 @@ HostGlobals::~HostGlobals() {
return &host_var_tracker_;
}
+::ppapi::FunctionGroupBase* HostGlobals::GetFunctionAPI(
+ PP_Instance pp_instance,
+ ::ppapi::proxy::InterfaceID id) {
+ // Get the instance object. This also ensures that the instance data is in
+ // the map, since we need it below.
+ PluginInstance* instance = GetInstance(pp_instance);
+ if (!instance)
+ return NULL;
+
+ // The instance one is special, since it's just implemented by the instance
+ // object.
+ if (id == ::ppapi::proxy::INTERFACE_ID_PPB_INSTANCE)
+ return instance;
+
+ scoped_ptr< ::ppapi::FunctionGroupBase >& proxy =
+ instance_map_[pp_instance]->function_proxies[id];
+ if (proxy.get())
+ return proxy.get();
+
+ switch (id) {
+ case ::ppapi::proxy::INTERFACE_ID_PPB_CURSORCONTROL:
+ proxy.reset(new PPB_CursorControl_Impl(instance));
+ break;
+ case ::ppapi::proxy::INTERFACE_ID_PPB_FONT:
+ proxy.reset(new PPB_Font_FunctionImpl(instance));
+ break;
+ case ::ppapi::proxy::INTERFACE_ID_PPB_TEXT_INPUT:
+ proxy.reset(new PPB_TextInput_Impl(instance));
+ break;
+ case ::ppapi::proxy::INTERFACE_ID_RESOURCE_CREATION:
+ proxy.reset(new ResourceCreationImpl(instance));
+ break;
+ default:
+ NOTREACHED();
+ }
+
+ return proxy.get();
+}
+
+PP_Module HostGlobals::GetModuleForInstance(PP_Instance instance) {
+ PluginInstance* inst = GetInstance(instance);
+ if (!inst)
+ return 0;
+ return inst->module()->pp_module();
+}
+
+PP_Module HostGlobals::AddModule(PluginModule* module) {
+#ifndef NDEBUG
+ // Make sure we're not adding one more than once.
+ for (ModuleMap::const_iterator i = module_map_.begin();
+ i != module_map_.end(); ++i)
+ DCHECK(i->second != module);
+#endif
+
+ // See AddInstance.
+ PP_Module new_module;
+ do {
+ new_module = MakeTypedId(static_cast<PP_Module>(base::RandUint64()),
+ ::ppapi::PP_ID_TYPE_MODULE);
+ } while (!new_module ||
+ module_map_.find(new_module) != module_map_.end());
+ module_map_[new_module] = module;
+ return new_module;
+}
+
+void HostGlobals::ModuleDeleted(PP_Module module) {
+ DLOG_IF(ERROR, !CheckIdType(module, ::ppapi::PP_ID_TYPE_MODULE))
+ << module << " is not a PP_Module.";
+ ModuleMap::iterator found = module_map_.find(module);
+ if (found == module_map_.end()) {
+ NOTREACHED();
+ return;
+ }
+ module_map_.erase(found);
+}
+
+PluginModule* HostGlobals::GetModule(PP_Module module) {
+ DLOG_IF(ERROR, !CheckIdType(module, ::ppapi::PP_ID_TYPE_MODULE))
+ << module << " is not a PP_Module.";
+ ModuleMap::iterator found = module_map_.find(module);
+ if (found == module_map_.end())
+ return NULL;
+ return found->second;
+}
+
+PP_Instance HostGlobals::AddInstance(PluginInstance* instance) {
+ DCHECK(instance_map_.find(instance->pp_instance()) == instance_map_.end());
+
+ // Use a random number for the instance ID. This helps prevent some
+ // accidents. See also AddModule below.
+ //
+ // Need to make sure the random number isn't a duplicate or 0.
+ PP_Instance new_instance;
+ do {
+ new_instance = MakeTypedId(static_cast<PP_Instance>(base::RandUint64()),
+ ::ppapi::PP_ID_TYPE_INSTANCE);
+ } while (!new_instance ||
+ instance_map_.find(new_instance) != instance_map_.end() ||
+ !instance->module()->ReserveInstanceID(new_instance));
+
+ instance_map_[new_instance] = linked_ptr<InstanceData>(new InstanceData);
+ instance_map_[new_instance]->instance = instance;
+
+ host_resource_tracker_.DidCreateInstance(new_instance);
+ return new_instance;
+}
+
+void HostGlobals::InstanceDeleted(PP_Instance instance) {
+ host_resource_tracker_.DidDeleteInstance(instance);
+ host_var_tracker_.ForceFreeNPObjectsForInstance(instance);
+ instance_map_.erase(instance);
+}
+
+void HostGlobals::InstanceCrashed(PP_Instance instance) {
+ host_resource_tracker_.DidDeleteInstance(instance);
+ host_var_tracker_.ForceFreeNPObjectsForInstance(instance);
+}
+
+PluginInstance* HostGlobals::GetInstance(PP_Instance instance) {
+ DLOG_IF(ERROR, !CheckIdType(instance, ::ppapi::PP_ID_TYPE_INSTANCE))
+ << instance << " is not a PP_Instance.";
+ InstanceMap::iterator found = instance_map_.find(instance);
+ if (found == instance_map_.end())
+ return NULL;
+ return found->second->instance;
+}
+
} // namespace ppapi
} // namespace webkit
diff --git a/webkit/plugins/ppapi/host_globals.h b/webkit/plugins/ppapi/host_globals.h
index a213d68..580ff5d 100644
--- a/webkit/plugins/ppapi/host_globals.h
+++ b/webkit/plugins/ppapi/host_globals.h
@@ -14,6 +14,9 @@
namespace webkit {
namespace ppapi {
+class PluginInstance;
+class PluginModule;
+
class HostGlobals : public ::ppapi::PpapiGlobals {
public:
HostGlobals();
@@ -27,6 +30,10 @@ class HostGlobals : public ::ppapi::PpapiGlobals {
// PpapiGlobals implementation.
virtual ::ppapi::ResourceTracker* GetResourceTracker() OVERRIDE;
virtual ::ppapi::VarTracker* GetVarTracker() OVERRIDE;
+ virtual ::ppapi::FunctionGroupBase* GetFunctionAPI(
+ PP_Instance inst,
+ ::ppapi::proxy::InterfaceID id) OVERRIDE;
+ virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE;
HostResourceTracker* host_resource_tracker() {
return &host_resource_tracker_;
@@ -35,12 +42,55 @@ class HostGlobals : public ::ppapi::PpapiGlobals {
return &host_var_tracker_;
}
+ // PP_Modules ----------------------------------------------------------------
+
+ // Adds a new plugin module to the list of tracked module, and returns a new
+ // module handle to identify it.
+ PP_Module AddModule(PluginModule* module);
+
+ // Called when a plugin modulde was deleted and should no longer be tracked.
+ // The given handle should be one generated by AddModule.
+ void ModuleDeleted(PP_Module module);
+
+ // Returns a pointer to the plugin modulde object associated with the given
+ // modulde handle. The return value will be NULL if the handle is invalid.
+ PluginModule* GetModule(PP_Module module);
+
+ // PP_Instances --------------------------------------------------------------
+
+ // Adds a new plugin instance to the list of tracked instances, and returns a
+ // new instance handle to identify it.
+ PP_Instance AddInstance(PluginInstance* instance);
+
+ // Called when a plugin instance was deleted and should no longer be tracked.
+ // The given handle should be one generated by AddInstance.
+ void InstanceDeleted(PP_Instance instance);
+
+ void InstanceCrashed(PP_Instance instance);
+
+ // Returns a pointer to the plugin instance object associated with the given
+ // instance handle. The return value will be NULL if the handle is invalid or
+ // if the instance has crashed.
+ PluginInstance* GetInstance(PP_Instance instance);
+
private:
+ // Per-instance data we track.
+ struct InstanceData;
+
static HostGlobals* host_globals_;
HostResourceTracker host_resource_tracker_;
HostVarTracker host_var_tracker_;
+ // Tracks all live instances and their associated data.
+ typedef std::map<PP_Instance, linked_ptr<InstanceData> > InstanceMap;
+ InstanceMap instance_map_;
+
+ // Tracks all live modules. The pointers are non-owning, the PluginModule
+ // destructor will notify us when the module is deleted.
+ typedef std::map<PP_Module, PluginModule*> ModuleMap;
+ ModuleMap module_map_;
+
DISALLOW_COPY_AND_ASSIGN(HostGlobals);
};
diff --git a/webkit/plugins/ppapi/host_resource_tracker.cc b/webkit/plugins/ppapi/host_resource_tracker.cc
index 69119e49..70b5157 100644
--- a/webkit/plugins/ppapi/host_resource_tracker.cc
+++ b/webkit/plugins/ppapi/host_resource_tracker.cc
@@ -4,109 +4,20 @@
#include "webkit/plugins/ppapi/host_resource_tracker.h"
-#include <limits>
-#include <set>
-
-#include "base/logging.h"
-#include "base/rand_util.h"
-#include "ppapi/c/pp_resource.h"
-#include "ppapi/c/pp_var.h"
-#include "ppapi/shared_impl/function_group_base.h"
-#include "ppapi/shared_impl/id_assignment.h"
-#include "ppapi/shared_impl/tracker_base.h"
+#include "ppapi/shared_impl/resource.h"
#include "webkit/plugins/ppapi/callbacks.h"
-#include "webkit/plugins/ppapi/host_globals.h"
-#include "webkit/plugins/ppapi/npobject_var.h"
#include "webkit/plugins/ppapi/plugin_module.h"
-#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-#include "webkit/plugins/ppapi/ppb_cursor_control_impl.h"
-#include "webkit/plugins/ppapi/ppb_font_impl.h"
-#include "webkit/plugins/ppapi/ppb_text_input_impl.h"
-#include "webkit/plugins/ppapi/resource_creation_impl.h"
#include "webkit/plugins/ppapi/resource_helper.h"
-using ppapi::CheckIdType;
-using ppapi::MakeTypedId;
-using ppapi::NPObjectVar;
-using ppapi::PPIdType;
-
namespace webkit {
namespace ppapi {
-namespace {
-
-::ppapi::TrackerBase* GetTrackerBase() {
- return HostGlobals::Get()->host_resource_tracker();
-}
-
-} // namespace
-
-struct HostResourceTracker::InstanceData {
- InstanceData() : instance(0) {}
-
- // Non-owning pointer to the instance object. When a PluginInstance is
- // destroyed, it will notify us and we'll delete all associated data.
- PluginInstance* instance;
-
- // Lazily allocated function proxies for the different interfaces.
- scoped_ptr< ::ppapi::FunctionGroupBase >
- function_proxies[::ppapi::proxy::INTERFACE_ID_COUNT];
-};
-
HostResourceTracker::HostResourceTracker() {
- // Wire up the new shared resource tracker base to use our implementation.
- ::ppapi::TrackerBase::Init(&GetTrackerBase);
}
HostResourceTracker::~HostResourceTracker() {
}
-::ppapi::FunctionGroupBase* HostResourceTracker::GetFunctionAPI(
- PP_Instance pp_instance,
- ::ppapi::proxy::InterfaceID id) {
- // Get the instance object. This also ensures that the instance data is in
- // the map, since we need it below.
- PluginInstance* instance = GetInstance(pp_instance);
- if (!instance)
- return NULL;
-
- // The instance one is special, since it's just implemented by the instance
- // object.
- if (id == ::ppapi::proxy::INTERFACE_ID_PPB_INSTANCE)
- return instance;
-
- scoped_ptr< ::ppapi::FunctionGroupBase >& proxy =
- instance_map_[pp_instance]->function_proxies[id];
- if (proxy.get())
- return proxy.get();
-
- switch (id) {
- case ::ppapi::proxy::INTERFACE_ID_PPB_CURSORCONTROL:
- proxy.reset(new PPB_CursorControl_Impl(instance));
- break;
- case ::ppapi::proxy::INTERFACE_ID_PPB_FONT:
- proxy.reset(new PPB_Font_FunctionImpl(instance));
- break;
- case ::ppapi::proxy::INTERFACE_ID_PPB_TEXT_INPUT:
- proxy.reset(new PPB_TextInput_Impl(instance));
- break;
- case ::ppapi::proxy::INTERFACE_ID_RESOURCE_CREATION:
- proxy.reset(new ResourceCreationImpl(instance));
- break;
- default:
- NOTREACHED();
- }
-
- return proxy.get();
-}
-
-PP_Module HostResourceTracker::GetModuleForInstance(PP_Instance instance) {
- PluginInstance* inst = GetInstance(instance);
- if (!inst)
- return 0;
- return inst->module()->pp_module();
-}
-
void HostResourceTracker::LastPluginRefWasDeleted(::ppapi::Resource* object) {
::ppapi::ResourceTracker::LastPluginRefWasDeleted(object);
@@ -121,88 +32,5 @@ void HostResourceTracker::LastPluginRefWasDeleted(::ppapi::Resource* object) {
}
}
-PP_Instance HostResourceTracker::AddInstance(PluginInstance* instance) {
- DCHECK(instance_map_.find(instance->pp_instance()) == instance_map_.end());
-
- // Use a random number for the instance ID. This helps prevent some
- // accidents. See also AddModule below.
- //
- // Need to make sure the random number isn't a duplicate or 0.
- PP_Instance new_instance;
- do {
- new_instance = MakeTypedId(static_cast<PP_Instance>(base::RandUint64()),
- ::ppapi::PP_ID_TYPE_INSTANCE);
- } while (!new_instance ||
- instance_map_.find(new_instance) != instance_map_.end() ||
- !instance->module()->ReserveInstanceID(new_instance));
-
- instance_map_[new_instance] = linked_ptr<InstanceData>(new InstanceData);
- instance_map_[new_instance]->instance = instance;
-
- DidCreateInstance(new_instance);
- return new_instance;
-}
-
-void HostResourceTracker::InstanceDeleted(PP_Instance instance) {
- DidDeleteInstance(instance);
- HostGlobals::Get()->host_var_tracker()->ForceFreeNPObjectsForInstance(
- instance);
- instance_map_.erase(instance);
-}
-
-void HostResourceTracker::InstanceCrashed(PP_Instance instance) {
- DidDeleteInstance(instance);
- HostGlobals::Get()->host_var_tracker()->ForceFreeNPObjectsForInstance(
- instance);
-}
-
-PluginInstance* HostResourceTracker::GetInstance(PP_Instance instance) {
- DLOG_IF(ERROR, !CheckIdType(instance, ::ppapi::PP_ID_TYPE_INSTANCE))
- << instance << " is not a PP_Instance.";
- InstanceMap::iterator found = instance_map_.find(instance);
- if (found == instance_map_.end())
- return NULL;
- return found->second->instance;
-}
-
-PP_Module HostResourceTracker::AddModule(PluginModule* module) {
-#ifndef NDEBUG
- // Make sure we're not adding one more than once.
- for (ModuleMap::const_iterator i = module_map_.begin();
- i != module_map_.end(); ++i)
- DCHECK(i->second != module);
-#endif
-
- // See AddInstance above.
- PP_Module new_module;
- do {
- new_module = MakeTypedId(static_cast<PP_Module>(base::RandUint64()),
- ::ppapi::PP_ID_TYPE_MODULE);
- } while (!new_module ||
- module_map_.find(new_module) != module_map_.end());
- module_map_[new_module] = module;
- return new_module;
-}
-
-void HostResourceTracker::ModuleDeleted(PP_Module module) {
- DLOG_IF(ERROR, !CheckIdType(module, ::ppapi::PP_ID_TYPE_MODULE))
- << module << " is not a PP_Module.";
- ModuleMap::iterator found = module_map_.find(module);
- if (found == module_map_.end()) {
- NOTREACHED();
- return;
- }
- module_map_.erase(found);
-}
-
-PluginModule* HostResourceTracker::GetModule(PP_Module module) {
- DLOG_IF(ERROR, !CheckIdType(module, ::ppapi::PP_ID_TYPE_MODULE))
- << module << " is not a PP_Module.";
- ModuleMap::iterator found = module_map_.find(module);
- if (found == module_map_.end())
- return NULL;
- return found->second;
-}
-
} // namespace ppapi
} // namespace webkit
diff --git a/webkit/plugins/ppapi/host_resource_tracker.h b/webkit/plugins/ppapi/host_resource_tracker.h
index 0c1e56f..503b9ee 100644
--- a/webkit/plugins/ppapi/host_resource_tracker.h
+++ b/webkit/plugins/ppapi/host_resource_tracker.h
@@ -5,108 +5,22 @@
#ifndef WEBKIT_PLUGINS_PPAPI_HOST_RESOURCE_TRACKER_H_
#define WEBKIT_PLUGINS_PPAPI_HOST_RESOURCE_TRACKER_H_
-#include <map>
-#include <set>
-#include <utility>
-
#include "base/basictypes.h"
-#include "base/gtest_prod_util.h"
-#include "base/hash_tables.h"
-#include "base/memory/linked_ptr.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "ppapi/c/pp_instance.h"
-#include "ppapi/c/pp_module.h"
-#include "ppapi/c/pp_resource.h"
-#include "ppapi/proxy/interface_id.h"
-#include "ppapi/shared_impl/function_group_base.h"
+#include "base/compiler_specific.h"
#include "ppapi/shared_impl/resource_tracker.h"
-#include "ppapi/shared_impl/tracker_base.h"
-#include "ppapi/shared_impl/var_tracker.h"
-
-typedef struct NPObject NPObject;
-
-namespace ppapi {
-class NPObjectVar;
-class Var;
-}
namespace webkit {
namespace ppapi {
-class PluginInstance;
-class PluginModule;
-class HostResourceTrackerTest;
-
-// This class maintains a global list of all live pepper resources. It allows
-// us to check resource ID validity and to map them to a specific module.
-//
-// This object is NOT threadsafe.
-class HostResourceTracker : public ::ppapi::TrackerBase,
- public ::ppapi::ResourceTracker {
+class HostResourceTracker : public ::ppapi::ResourceTracker {
public:
HostResourceTracker();
virtual ~HostResourceTracker();
- // PP_Resources --------------------------------------------------------------
-
- // TrackerBase.
- virtual ::ppapi::FunctionGroupBase* GetFunctionAPI(
- PP_Instance pp_instance,
- ::ppapi::proxy::InterfaceID id) OVERRIDE;
- virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE;
-
// ppapi::ResourceTracker overrides.
virtual void LastPluginRefWasDeleted(::ppapi::Resource* object) OVERRIDE;
- // PP_Modules ----------------------------------------------------------------
-
- // Adds a new plugin module to the list of tracked module, and returns a new
- // module handle to identify it.
- PP_Module AddModule(PluginModule* module);
-
- // Called when a plugin modulde was deleted and should no longer be tracked.
- // The given handle should be one generated by AddModule.
- void ModuleDeleted(PP_Module module);
-
- // Returns a pointer to the plugin modulde object associated with the given
- // modulde handle. The return value will be NULL if the handle is invalid.
- PluginModule* GetModule(PP_Module module);
-
- // PP_Instances --------------------------------------------------------------
-
- // Adds a new plugin instance to the list of tracked instances, and returns a
- // new instance handle to identify it.
- PP_Instance AddInstance(PluginInstance* instance);
-
- // Called when a plugin instance was deleted and should no longer be tracked.
- // The given handle should be one generated by AddInstance.
- void InstanceDeleted(PP_Instance instance);
-
- void InstanceCrashed(PP_Instance instance);
-
- // Returns a pointer to the plugin instance object associated with the given
- // instance handle. The return value will be NULL if the handle is invalid or
- // if the instance has crashed.
- PluginInstance* GetInstance(PP_Instance instance);
-
private:
- friend class HostResourceTrackerTest;
-
- typedef std::set<PP_Resource> ResourceSet;
-
- // Per-instance data we track.
- struct InstanceData;
-
- // Tracks all live instances and their associated data.
- typedef std::map<PP_Instance, linked_ptr<InstanceData> > InstanceMap;
- InstanceMap instance_map_;
-
- // Tracks all live modules. The pointers are non-owning, the PluginModule
- // destructor will notify us when the module is deleted.
- typedef std::map<PP_Module, PluginModule*> ModuleMap;
- ModuleMap module_map_;
-
DISALLOW_COPY_AND_ASSIGN(HostResourceTracker);
};
diff --git a/webkit/plugins/ppapi/host_var_tracker.h b/webkit/plugins/ppapi/host_var_tracker.h
index dcb96c8..578c29b 100644
--- a/webkit/plugins/ppapi/host_var_tracker.h
+++ b/webkit/plugins/ppapi/host_var_tracker.h
@@ -19,7 +19,6 @@
#include "ppapi/proxy/interface_id.h"
#include "ppapi/shared_impl/function_group_base.h"
#include "ppapi/shared_impl/resource_tracker.h"
-#include "ppapi/shared_impl/tracker_base.h"
#include "ppapi/shared_impl/var_tracker.h"
typedef struct NPObject NPObject;
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 33861ef..e25b4b0 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -386,7 +386,7 @@ PluginModule::PluginModule(const std::string& name,
host_globals = new HostGlobals;
memset(&entry_points_, 0, sizeof(entry_points_));
- pp_module_ = HostGlobals::Get()->host_resource_tracker()->AddModule(this);
+ pp_module_ = HostGlobals::Get()->AddModule(this);
GetMainThreadMessageLoop(); // Initialize the main thread message loop.
GetLivePluginSet()->insert(this);
}
@@ -412,7 +412,7 @@ PluginModule::~PluginModule() {
base::UnloadNativeLibrary(library_);
// Notifications that we've been deleted should be last.
- HostGlobals::Get()->host_resource_tracker()->ModuleDeleted(pp_module_);
+ HostGlobals::Get()->ModuleDeleted(pp_module_);
if (!is_crashed_) {
// When the plugin crashes, we immediately tell the lifetime delegate that
// we're gone, so we don't want to tell it again.
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 5c912ee..6d6034f 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -62,7 +62,6 @@
#include "webkit/plugins/ppapi/event_conversion.h"
#include "webkit/plugins/ppapi/fullscreen_container.h"
#include "webkit/plugins/ppapi/host_globals.h"
-#include "webkit/plugins/ppapi/host_resource_tracker.h"
#include "webkit/plugins/ppapi/message_channel.h"
#include "webkit/plugins/ppapi/npapi_glue.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
@@ -243,8 +242,7 @@ void RectToPPRect(const gfx::Rect& input, PP_Rect* output) {
// unchanged.
bool SecurityOriginForInstance(PP_Instance instance_id,
WebKit::WebSecurityOrigin* security_origin) {
- PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
if (!instance)
return false;
@@ -307,7 +305,7 @@ PluginInstance::PluginInstance(
text_input_caret_bounds_(0, 0, 0, 0),
text_input_caret_set_(false),
lock_mouse_callback_(PP_BlockUntilComplete()) {
- pp_instance_ = HostGlobals::Get()->host_resource_tracker()->AddInstance(this);
+ pp_instance_ = HostGlobals::Get()->AddInstance(this);
memset(&current_print_settings_, 0, sizeof(current_print_settings_));
DCHECK(delegate);
@@ -336,7 +334,7 @@ PluginInstance::~PluginInstance() {
delegate_->InstanceDeleted(this);
module_->InstanceDeleted(this);
- HostGlobals::Get()->host_resource_tracker()->InstanceDeleted(pp_instance_);
+ HostGlobals::Get()->InstanceDeleted(pp_instance_);
}
// NOTE: Any of these methods that calls into the plugin needs to take into
@@ -424,7 +422,7 @@ void PluginInstance::CommitBackingTexture() {
void PluginInstance::InstanceCrashed() {
// Force free all resources and vars.
- HostGlobals::Get()->host_resource_tracker()->InstanceCrashed(pp_instance());
+ HostGlobals::Get()->InstanceCrashed(pp_instance());
// Free any associated graphics.
SetFullscreen(false, false);
diff --git a/webkit/plugins/ppapi/ppb_audio_impl.cc b/webkit/plugins/ppapi/ppb_audio_impl.cc
index ea73f38..6cc1cd0 100644
--- a/webkit/plugins/ppapi/ppb_audio_impl.cc
+++ b/webkit/plugins/ppapi/ppb_audio_impl.cc
@@ -10,7 +10,6 @@
#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/c/trusted/ppb_audio_trusted.h"
#include "ppapi/shared_impl/resource_tracker.h"
-#include "ppapi/shared_impl/tracker_base.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_audio_config_api.h"
#include "ppapi/thunk/thunk.h"
diff --git a/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc b/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc
index 85b2936..9153ae7 100644
--- a/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc
@@ -19,7 +19,6 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/host_globals.h"
-#include "webkit/plugins/ppapi/host_resource_tracker.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
@@ -65,8 +64,7 @@ PP_Bool IsFormatAvailable(PP_Instance instance_id,
PP_Flash_Clipboard_Type clipboard_type,
PP_Flash_Clipboard_Format format) {
// If you don't give us an instance, we don't give you anything.
- PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
if (!instance)
return PP_FALSE;
@@ -84,8 +82,7 @@ PP_Bool IsFormatAvailable(PP_Instance instance_id,
PP_Var ReadPlainText(PP_Instance instance_id,
PP_Flash_Clipboard_Type clipboard_type) {
- PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
if (!instance)
return PP_MakeNull();
diff --git a/webkit/plugins/ppapi/ppb_flash_file_impl.cc b/webkit/plugins/ppapi/ppb_flash_file_impl.cc
index 73339e9..97eb649 100644
--- a/webkit/plugins/ppapi/ppb_flash_file_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_file_impl.cc
@@ -17,7 +17,6 @@
#include "webkit/plugins/ppapi/file_path.h"
#include "webkit/plugins/ppapi/file_type_conversions.h"
#include "webkit/plugins/ppapi/host_globals.h"
-#include "webkit/plugins/ppapi/host_resource_tracker.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
@@ -67,8 +66,7 @@ int32_t OpenModuleLocalFile(PP_Instance pp_instance,
if (!path || !PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || !file)
return PP_ERROR_BADARGUMENT;
- PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance);
if (!instance)
return PP_ERROR_FAILED;
@@ -87,8 +85,7 @@ int32_t RenameModuleLocalFile(PP_Instance pp_instance,
if (!from_path || !to_path)
return PP_ERROR_BADARGUMENT;
- PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance);
if (!instance)
return PP_ERROR_FAILED;
@@ -104,8 +101,7 @@ int32_t DeleteModuleLocalFileOrDir(PP_Instance pp_instance,
if (!path)
return PP_ERROR_BADARGUMENT;
- PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance);
if (!instance)
return PP_ERROR_FAILED;
@@ -119,8 +115,7 @@ int32_t CreateModuleLocalDir(PP_Instance pp_instance, const char* path) {
if (!path)
return PP_ERROR_BADARGUMENT;
- PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance);
if (!instance)
return PP_ERROR_FAILED;
@@ -135,8 +130,7 @@ int32_t QueryModuleLocalFile(PP_Instance pp_instance,
if (!path || !info)
return PP_ERROR_BADARGUMENT;
- PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance);
if (!instance)
return PP_ERROR_FAILED;
@@ -163,8 +157,7 @@ int32_t GetModuleLocalDirContents(PP_Instance pp_instance,
PP_DirContents_Dev** contents) {
if (!path || !contents)
return PP_ERROR_BADARGUMENT;
- PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance);
if (!instance)
return PP_ERROR_FAILED;
diff --git a/webkit/plugins/ppapi/ppb_flash_impl.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc
index b155d35..6d75d15 100644
--- a/webkit/plugins/ppapi/ppb_flash_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_impl.cc
@@ -15,7 +15,6 @@
#include "ppapi/thunk/enter.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/host_globals.h"
-#include "webkit/plugins/ppapi/host_resource_tracker.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
@@ -33,16 +32,14 @@ namespace ppapi {
namespace {
void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) {
- PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance);
if (!instance)
return;
instance->set_always_on_top(PPBoolToBool(on_top));
}
PP_Var GetProxyForURL(PP_Instance pp_instance, const char* url) {
- PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance);
if (!instance)
return PP_MakeUndefined();
@@ -86,8 +83,7 @@ void QuitMessageLoop(PP_Instance instance) {
}
double GetLocalTimeZoneOffset(PP_Instance pp_instance, PP_Time t) {
- PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance);
if (!instance)
return 0.0;
@@ -105,8 +101,7 @@ double GetLocalTimeZoneOffset(PP_Instance pp_instance, PP_Time t) {
}
PP_Var GetCommandLineArgs(PP_Module pp_module) {
- PluginModule* module =
- HostGlobals::Get()->host_resource_tracker()->GetModule(pp_module);
+ PluginModule* module = HostGlobals::Get()->GetModule(pp_module);
if (!module)
return PP_MakeUndefined();
diff --git a/webkit/plugins/ppapi/ppb_proxy_impl.cc b/webkit/plugins/ppapi/ppb_proxy_impl.cc
index be765d9..070aa7a 100644
--- a/webkit/plugins/ppapi/ppb_proxy_impl.cc
+++ b/webkit/plugins/ppapi/ppb_proxy_impl.cc
@@ -8,7 +8,6 @@
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_image_data_api.h"
#include "webkit/plugins/ppapi/host_globals.h"
-#include "webkit/plugins/ppapi/host_resource_tracker.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
@@ -23,8 +22,7 @@ namespace ppapi {
namespace {
void PluginCrashed(PP_Module module) {
- PluginModule* plugin_module =
- HostGlobals::Get()->host_resource_tracker()->GetModule(module);
+ PluginModule* plugin_module = HostGlobals::Get()->GetModule(module);
if (plugin_module)
plugin_module->PluginCrashed();
}
@@ -39,8 +37,7 @@ PP_Instance GetInstanceForResource(PP_Resource resource) {
void SetReserveInstanceIDCallback(PP_Module module,
PP_Bool (*reserve)(PP_Module, PP_Instance)) {
- PluginModule* plugin_module =
- HostGlobals::Get()->host_resource_tracker()->GetModule(module);
+ PluginModule* plugin_module = HostGlobals::Get()->GetModule(module);
if (plugin_module)
plugin_module->SetReserveInstanceIDCallback(reserve);
}
@@ -53,22 +50,19 @@ int32_t GetURLLoaderBufferedBytes(PP_Resource url_loader) {
}
void AddRefModule(PP_Module module) {
- PluginModule* plugin_module =
- HostGlobals::Get()->host_resource_tracker()->GetModule(module);
+ PluginModule* plugin_module = HostGlobals::Get()->GetModule(module);
if (plugin_module)
plugin_module->AddRef();
}
void ReleaseModule(PP_Module module) {
- PluginModule* plugin_module =
- HostGlobals::Get()->host_resource_tracker()->GetModule(module);
+ PluginModule* plugin_module = HostGlobals::Get()->GetModule(module);
if (plugin_module)
plugin_module->Release();
}
PP_Bool IsInModuleDestructor(PP_Module module) {
- PluginModule* plugin_module =
- HostGlobals::Get()->host_resource_tracker()->GetModule(module);
+ PluginModule* plugin_module = HostGlobals::Get()->GetModule(module);
if (plugin_module)
return PP_FromBool(plugin_module->is_in_destructor());
return PP_FALSE;
diff --git a/webkit/plugins/ppapi/ppb_var_impl.cc b/webkit/plugins/ppapi/ppb_var_impl.cc
index 0769e82..d76864e 100644
--- a/webkit/plugins/ppapi/ppb_var_impl.cc
+++ b/webkit/plugins/ppapi/ppb_var_impl.cc
@@ -12,7 +12,6 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/host_globals.h"
-#include "webkit/plugins/ppapi/host_resource_tracker.h"
#include "webkit/plugins/ppapi/npapi_glue.h"
#include "webkit/plugins/ppapi/npobject_var.h"
#include "webkit/plugins/ppapi/plugin_module.h"
@@ -126,8 +125,7 @@ class ObjectAccessorTryCatch : public TryCatch {
NPObjectVar* object() { return object_.get(); }
PluginInstance* GetPluginInstance() {
- return HostGlobals::Get()->host_resource_tracker()->GetInstance(
- object()->pp_instance());
+ return HostGlobals::Get()->GetInstance(object()->pp_instance());
}
protected:
@@ -410,8 +408,7 @@ bool IsInstanceOfDeprecated(PP_Var var,
PP_Var CreateObjectDeprecated(PP_Instance pp_instance,
const PPP_Class_Deprecated* ppp_class,
void* ppp_class_data) {
- PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance);
if (!instance) {
DLOG(ERROR) << "Create object passed an invalid instance.";
return PP_MakeNull();
@@ -422,8 +419,7 @@ PP_Var CreateObjectDeprecated(PP_Instance pp_instance,
PP_Var CreateObjectWithModuleDeprecated(PP_Module pp_module,
const PPP_Class_Deprecated* ppp_class,
void* ppp_class_data) {
- PluginModule* module =
- HostGlobals::Get()->host_resource_tracker()->GetModule(pp_module);
+ PluginModule* module = HostGlobals::Get()->GetModule(pp_module);
if (!module)
return PP_MakeNull();
return PluginObject::Create(module->GetSomeInstance(),
diff --git a/webkit/plugins/ppapi/quota_file_io.cc b/webkit/plugins/ppapi/quota_file_io.cc
index 3a0630f..a8ae4d2 100644
--- a/webkit/plugins/ppapi/quota_file_io.cc
+++ b/webkit/plugins/ppapi/quota_file_io.cc
@@ -13,7 +13,6 @@
#include "base/stl_util.h"
#include "base/task.h"
#include "webkit/plugins/ppapi/host_globals.h"
-#include "webkit/plugins/ppapi/host_resource_tracker.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/resource_helper.h"
@@ -271,8 +270,7 @@ bool QuotaFileIO::WillSetLength(int64_t length,
}
PluginDelegate* QuotaFileIO::GetPluginDelegate() const {
- PluginInstance* instance =
- HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance_);
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance_);
if (instance)
return instance->delegate();
return NULL;
diff --git a/webkit/plugins/ppapi/resource_helper.cc b/webkit/plugins/ppapi/resource_helper.cc
index fd0321a..1959961 100644
--- a/webkit/plugins/ppapi/resource_helper.cc
+++ b/webkit/plugins/ppapi/resource_helper.cc
@@ -10,7 +10,6 @@
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-#include "webkit/plugins/ppapi/host_resource_tracker.h"
namespace webkit {
namespace ppapi {
@@ -18,8 +17,7 @@ namespace ppapi {
// static
PluginInstance* ResourceHelper::GetPluginInstance(
const ::ppapi::Resource* resource) {
- return HostGlobals::Get()->host_resource_tracker()->GetInstance(
- resource->pp_instance());
+ return HostGlobals::Get()->GetInstance(resource->pp_instance());
}
PluginModule* ResourceHelper::GetPluginModule(