1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "webkit/plugins/ppapi/ppapi_interface_factory.h"
9 #include "base/logging.h"
14 base::LazyInstance
<PpapiInterfaceFactoryManager
>
15 g_ppapi_interface_factory_manager
= LAZY_INSTANCE_INITIALIZER
;
17 PpapiInterfaceFactoryManager::PpapiInterfaceFactoryManager() {
20 PpapiInterfaceFactoryManager::~PpapiInterfaceFactoryManager() {
23 void PpapiInterfaceFactoryManager::RegisterFactory(InterfaceFactory
* factory
) {
24 DCHECK(std::find(interface_factory_list_
.begin(),
25 interface_factory_list_
.end(), factory
) ==
26 interface_factory_list_
.end());
27 interface_factory_list_
.push_back(factory
);
30 void PpapiInterfaceFactoryManager::UnregisterFactory(
31 InterfaceFactory
* factory
) {
32 FactoryList::iterator index
=
33 std::find(interface_factory_list_
.begin(), interface_factory_list_
.end(),
35 if (index
!= interface_factory_list_
.end())
36 interface_factory_list_
.erase(index
);
39 const void* PpapiInterfaceFactoryManager::GetInterface(
40 const std::string
& interface_name
) {
41 FactoryList::iterator index
;
43 const void* ppapi_interface
= NULL
;
45 for (index
= interface_factory_list_
.begin();
46 index
!= interface_factory_list_
.end();
48 ppapi_interface
= (*index
)(interface_name
);
52 return ppapi_interface
;
56 PpapiInterfaceFactoryManager
* PpapiInterfaceFactoryManager::GetInstance() {
57 return &g_ppapi_interface_factory_manager
.Get();