summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-01 00:23:13 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-01 00:23:13 +0000
commitfdbb38da528f6a931d9785cffb15ea9489bd0b35 (patch)
treea9fa40829ed6cf37c2f0e8492fd7bf1fd2c1c09d
parent6ae89017a6df00a382d2712d0ef85f188b3ecf12 (diff)
downloadchromium_src-fdbb38da528f6a931d9785cffb15ea9489bd0b35.zip
chromium_src-fdbb38da528f6a931d9785cffb15ea9489bd0b35.tar.gz
chromium_src-fdbb38da528f6a931d9785cffb15ea9489bd0b35.tar.bz2
Revert 87396 - Added a facility in PPAPI to register interface factories which can watch GetInterface calls and
return custom interfaces. Added a basic unit test to validate that the custom factory does get called. This would eventually be used to register custom interfaces for plugins like NACL which rely on chrome\renderer provided functionality via the webkit_glue namespace. This will help in eventually building src\content as a dll. BUG=82454 TEST=covered by test shell tests. Review URL: http://codereview.chromium.org/6976035 make -k -j4 -r BUILDTYPE=Debug ACTION Extracting last change to /mnt/data/b/build/slave/Linux_Clang__ChromiumOS_dbg_/build/src/out/Debug/obj/gen/build/LASTCHANGE out/Debug/obj/gen/build/LASTCHANGE.always CXX(target) out/Debug/obj.target/glue/webkit/plugins/ppapi/plugin_module.o CXX(target) out/Debug/obj.target/glue/webkit/plugins/ppapi/ppapi_interface_factory.o In file included from webkit/plugins/ppapi/ppapi_interface_factory.cc:5: ./webkit/plugins/ppapi/ppapi_interface_factory.h:40:3: error: [chromium-style] Complex constructor has an inlined body. PpapiInterfaceFactoryManager() {} ^ ./webkit/plugins/ppapi/ppapi_interface_factory.h:41:3: error: [chromium-style] Complex destructor has an inline body. ~PpapiInterfaceFactoryManager() {} ^ 2 errors generated. In file included from webkit/plugins/ppapi/plugin_module.cc:75: ./webkit/plugins/ppapi/ppapi_interface_factory.h:40:3: error: [chromium-style] Complex constructor has an inlined body. PpapiInterfaceFactoryManager() {} ^ ./webkit/plugins/ppapi/ppapi_interface_factory.h:41:3: error: [chromium-style] Complex destructor has an inline body. ~PpapiInterfaceFactoryManager() {} ^ make: *** [out/Debug/obj.target/glue/webkit/plugins/ppapi/ppapi_interface_factory.o] Error 1 2 errors generated. make: *** [out/Debug/obj.target/glue/webkit/plugins/ppapi/plugin_module.o] Error 1 make: Target `all' not remade because of errors. http://build.chromium.org/p/chromium/builders/Linux%20Clang%20%28ChromiumOS%20dbg%29/builds/5023 TBR=ananta@chromium.org Review URL: http://codereview.chromium.org/7020014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87398 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/glue/webkit_glue.gypi2
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc8
-rw-r--r--webkit/plugins/ppapi/ppapi_interface_factory.cc56
-rw-r--r--webkit/plugins/ppapi/ppapi_interface_factory.h55
-rw-r--r--webkit/plugins/ppapi/ppapi_unittest.cc47
5 files changed, 0 insertions, 168 deletions
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index 73dae78..9b0e2f4 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -226,8 +226,6 @@
'../plugins/ppapi/plugin_module.h',
'../plugins/ppapi/plugin_object.cc',
'../plugins/ppapi/plugin_object.h',
- '../plugins/ppapi/ppapi_interface_factory.cc',
- '../plugins/ppapi/ppapi_interface_factory.h',
'../plugins/ppapi/ppapi_plugin_instance.cc',
'../plugins/ppapi/ppapi_plugin_instance.h',
'../plugins/ppapi/ppapi_webplugin_impl.cc',
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 7d5bb74..a0f0339 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -72,7 +72,6 @@
#include "ppapi/thunk/thunk.h"
#include "webkit/plugins/ppapi/callbacks.h"
#include "webkit/plugins/ppapi/common.h"
-#include "webkit/plugins/ppapi/ppapi_interface_factory.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_console_impl.h"
#include "webkit/plugins/ppapi/ppb_crypto_impl.h"
@@ -240,13 +239,6 @@ const void* GetInterface(const char* name) {
DCHECK(IsMainThread());
std::string name_prefix(GetInterfacePrefix(name));
-
- // Allow custom interface factories first stab at the GetInterface call.
- const void* custom_interface =
- PpapiInterfaceFactoryManager::GetInstance()->GetInterface(name);
- if (custom_interface)
- return custom_interface;
-
// Please keep alphabetized by interface macro name with "special" stuff at
// the bottom.
if (strcmp(name, PPB_AUDIO_CONFIG_INTERFACE) == 0)
diff --git a/webkit/plugins/ppapi/ppapi_interface_factory.cc b/webkit/plugins/ppapi/ppapi_interface_factory.cc
deleted file mode 100644
index bf4a75a..0000000
--- a/webkit/plugins/ppapi/ppapi_interface_factory.cc
+++ /dev/null
@@ -1,56 +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 "webkit/plugins/ppapi/ppapi_interface_factory.h"
-
-#include <algorithm>
-
-#include "base/logging.h"
-
-namespace webkit {
-namespace ppapi {
-
-base::LazyInstance<PpapiInterfaceFactoryManager>
- g_ppapi_interface_factory_manager(base::LINKER_INITIALIZED);
-
-void PpapiInterfaceFactoryManager::RegisterFactory(InterfaceFactory* factory) {
- DCHECK(std::find(interface_factory_list_.begin(),
- interface_factory_list_.end(), factory) ==
- interface_factory_list_.end());
- interface_factory_list_.push_back(factory);
-}
-
-void PpapiInterfaceFactoryManager::UnregisterFactory(
- InterfaceFactory* factory) {
- FactoryList::iterator index =
- std::find(interface_factory_list_.begin(), interface_factory_list_.end(),
- factory);
- DCHECK(index != interface_factory_list_.end());
- interface_factory_list_.erase(index);
-}
-
-void* PpapiInterfaceFactoryManager::GetInterface(
- const std::string& interface_name) {
- FactoryList::iterator index;
-
- void* ppapi_interface = NULL;
-
- for (index = interface_factory_list_.begin();
- index != interface_factory_list_.end();
- ++index) {
- ppapi_interface = (*index)(interface_name);
- if (ppapi_interface)
- break;
- }
- return ppapi_interface;
-}
-
-// static
-PpapiInterfaceFactoryManager* PpapiInterfaceFactoryManager::GetInstance() {
- return &g_ppapi_interface_factory_manager.Get();
-}
-
-} // namespace ppapi
-} // namespace webkit
-
diff --git a/webkit/plugins/ppapi/ppapi_interface_factory.h b/webkit/plugins/ppapi/ppapi_interface_factory.h
deleted file mode 100644
index 71416a7..0000000
--- a/webkit/plugins/ppapi/ppapi_interface_factory.h
+++ /dev/null
@@ -1,55 +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 WEBKIT_PLUGINS_PPAPI_PLUGIN_INTERFACE_FACTORY_H_
-#define WEBKIT_PLUGINS_PPAPI_PLUGIN_INTERFACE_FACTORY_H_
-
-#include <string>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/lazy_instance.h"
-
-namespace webkit {
-namespace ppapi {
-
-// This class provides functionality to manage custom PPAPI interface
-// factories.
-class PpapiInterfaceFactoryManager {
- public:
- typedef void* (InterfaceFactory)(const std::string& interface_name);
-
- // Registers a custom PPAPI interface factory.
- void RegisterFactory(InterfaceFactory* factory);
-
- // Unregisters the custom PPAPI interface factory passed in.
- void UnregisterFactory(InterfaceFactory* factory);
-
- // Returns a pointer to the interface identified by the name passed in.
- // Returns NULL if no factory handles this interface.
- void* GetInterface(const std::string& interface_name);
-
- // Returns a pointer to the global instance of the
- // PpapiInterfaceFactoryManager class.
- static PpapiInterfaceFactoryManager* GetInstance();
-
- private:
- friend struct base::DefaultLazyInstanceTraits<PpapiInterfaceFactoryManager>;
-
- PpapiInterfaceFactoryManager() {}
- ~PpapiInterfaceFactoryManager() {}
-
- typedef std::vector<InterfaceFactory*> FactoryList;
-
- // List of registered factories.
- FactoryList interface_factory_list_;
-
- DISALLOW_COPY_AND_ASSIGN(PpapiInterfaceFactoryManager);
-};
-
-} // namespace ppapi
-} // namespace webkit
-
-#endif // WEBKIT_PLUGINS_PPAPI_PLUGIN_INTERFACE_FACTORY_H_
-
diff --git a/webkit/plugins/ppapi/ppapi_unittest.cc b/webkit/plugins/ppapi/ppapi_unittest.cc
index 025cb56..7dc70d3 100644
--- a/webkit/plugins/ppapi/ppapi_unittest.cc
+++ b/webkit/plugins/ppapi/ppapi_unittest.cc
@@ -8,7 +8,6 @@
#include "ppapi/c/ppp_instance.h"
#include "webkit/plugins/ppapi/mock_plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
-#include "webkit/plugins/ppapi/ppapi_interface_factory.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
namespace webkit {
@@ -117,51 +116,5 @@ void PpapiUnittest::PluginModuleDead(PluginModule* /* dead_module */) {
// Nothing needed (this is necessary to make the module compile).
}
-// Tests whether custom PPAPI interface factories are called when PPAPI
-// interfaces are requested.
-class PpapiCustomInterfaceFactoryTest
- : public testing::Test,
- public webkit::ppapi::PluginDelegate::ModuleLifetime {
- public:
- PpapiCustomInterfaceFactoryTest() {}
- virtual ~PpapiCustomInterfaceFactoryTest() {}
-
- bool result() {
- return result_;
- }
-
- void reset_result() {
- result_ = false;
- }
-
- static void* InterfaceFactory(const std::string& interface_name) {
- result_ = true;
- return NULL;
- }
-
- private:
- static bool result_;
- // ModuleLifetime implementation.
- virtual void PluginModuleDead(PluginModule* dead_module) {}
-};
-
-bool PpapiCustomInterfaceFactoryTest::result_ = false;
-
-// This test validates whether custom PPAPI interface factories are invoked in
-// response to PluginModule::GetPluginInterface calls.
-TEST_F(PpapiCustomInterfaceFactoryTest, BasicFactoryTest) {
- PpapiInterfaceFactoryManager::GetInstance()->RegisterFactory(
- PpapiCustomInterfaceFactoryTest::InterfaceFactory);
- (*PluginModule::GetLocalGetInterfaceFunc())("DummyInterface");
- EXPECT_TRUE(result());
-
- reset_result();
- PpapiInterfaceFactoryManager::GetInstance()->UnregisterFactory(
- PpapiCustomInterfaceFactoryTest::InterfaceFactory);
-
- (*PluginModule::GetLocalGetInterfaceFunc())("DummyInterface");
- EXPECT_FALSE(result());
-}
-
} // namespace ppapi
} // namespace webkit