This source file includes following definitions.
- GetInstance
- Start
- Shutdown
- AllowCaching
- GetExtension
- PutExtension
- GetInstance
- SetForTesting
#include "chrome/browser/extensions/updater/extension_cache.h"
#include "base/memory/singleton.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/extensions/updater/extension_cache_impl.h"
#endif
namespace extensions {
namespace {
#if !defined(OS_CHROMEOS)
class ExtensionCacheNullImpl : public ExtensionCache {
public:
static ExtensionCacheNullImpl* GetInstance() {
return Singleton<ExtensionCacheNullImpl>::get();
}
virtual void Start(const base::Closure& callback) OVERRIDE {
callback.Run();
}
virtual void Shutdown(const base::Closure& callback) OVERRIDE {
callback.Run();
}
virtual void AllowCaching(const std::string& id) OVERRIDE {
}
virtual bool GetExtension(const std::string& id,
base::FilePath* file_path,
std::string* version) OVERRIDE {
return false;
}
virtual void PutExtension(const std::string& id,
const base::FilePath& file_path,
const std::string& version,
const PutExtensionCallback& callback) OVERRIDE {
callback.Run(file_path, true);
}
private:
friend struct DefaultSingletonTraits<ExtensionCacheNullImpl>;
ExtensionCacheNullImpl() {}
virtual ~ExtensionCacheNullImpl() {}
};
#endif
static ExtensionCache* g_extension_cache_override = NULL;
}
ExtensionCache* ExtensionCache::GetInstance() {
if (g_extension_cache_override) {
return g_extension_cache_override;
} else {
#if defined(OS_CHROMEOS)
return ExtensionCacheImpl::GetInstance();
#else
return ExtensionCacheNullImpl::GetInstance();
#endif
}
}
ExtensionCache* ExtensionCache::SetForTesting(ExtensionCache* cache) {
ExtensionCache* temp = g_extension_cache_override;
g_extension_cache_override = cache;
return temp;
}
}