This source file includes following definitions.
- NewExtensionFunction
#ifndef EXTENSIONS_BROWSER_EXTENSION_FUNCTION_REGISTRY_H_
#define EXTENSIONS_BROWSER_EXTENSION_FUNCTION_REGISTRY_H_
#include <map>
#include <string>
#include <vector>
#include "extensions/browser/extension_function_histogram_value.h"
class ExtensionFunction;
typedef ExtensionFunction* (*ExtensionFunctionFactory)();
template <class T>
ExtensionFunction* NewExtensionFunction() {
return new T();
}
class ExtensionFunctionRegistry {
public:
static ExtensionFunctionRegistry* GetInstance();
explicit ExtensionFunctionRegistry();
virtual ~ExtensionFunctionRegistry();
void GetAllNames(std::vector<std::string>* names);
bool OverrideFunction(const std::string& name,
ExtensionFunctionFactory factory);
ExtensionFunction* NewFunction(const std::string& name);
template <class T>
void RegisterFunction() {
ExtensionFunctionFactory factory = &NewExtensionFunction<T>;
factories_[T::function_name()] =
FactoryEntry(factory, T::histogram_value());
}
struct FactoryEntry {
public:
explicit FactoryEntry();
explicit FactoryEntry(
ExtensionFunctionFactory factory,
extensions::functions::HistogramValue histogram_value);
ExtensionFunctionFactory factory_;
extensions::functions::HistogramValue histogram_value_;
};
typedef std::map<std::string, FactoryEntry> FactoryMap;
FactoryMap factories_;
};
#endif