Commit 98ff22ab authored by kustermann's avatar kustermann Committed by Commit bot

Revert "Move ExtensionCache to //extensions"

This reverts commit 1056c8a4.

Reason for revert: Seems to have caused test flakiness with non-empty message
loop. See https://crbug.com/422884.

BUG=422884
TBR=rockot@chromium.org

Review URL: https://codereview.chromium.org/653623002

Cr-Commit-Position: refs/heads/master@{#299294}
parent 02708e2d
...@@ -178,17 +178,10 @@ void DeviceLocalAccountExternalPolicyLoaderTest::SetForceInstallListPolicy() { ...@@ -178,17 +178,10 @@ void DeviceLocalAccountExternalPolicyLoaderTest::SetForceInstallListPolicy() {
store_.NotifyStoreLoaded(); store_.NotifyStoreLoaded();
} }
#if defined(OS_CHROMEOS)
// crbug.com/422884
#define MAYBE_CacheNotStarted DISABLED_CacheNotStarted
#else
#define MAYBE_CacheNotStarted CacheNotStarted
#endif
// Verifies that when the cache is not explicitly started, the loader does not // Verifies that when the cache is not explicitly started, the loader does not
// serve any extensions, even if the force-install list policy is set or a load // serve any extensions, even if the force-install list policy is set or a load
// is manually requested. // is manually requested.
TEST_F(DeviceLocalAccountExternalPolicyLoaderTest, MAYBE_CacheNotStarted) { TEST_F(DeviceLocalAccountExternalPolicyLoaderTest, CacheNotStarted) {
// Set the force-install list policy. // Set the force-install list policy.
SetForceInstallListPolicy(); SetForceInstallListPolicy();
......
...@@ -394,14 +394,7 @@ TEST_F(AutoEnrollmentClientTest, NetworkChangeRetryAfterErrors) { ...@@ -394,14 +394,7 @@ TEST_F(AutoEnrollmentClientTest, NetworkChangeRetryAfterErrors) {
EXPECT_TRUE(HasCachedDecision()); EXPECT_TRUE(HasCachedDecision());
} }
#if defined(OS_CHROMEOS) TEST_F(AutoEnrollmentClientTest, CancelAndDeleteSoonWithPendingRequest) {
// crbug.com/422884
#define MAYBE_CancelAndDeleteSoonWithPendingRequest DISABLED_CancelAndDeleteSoonWithPendingRequest
#else
#define MAYBE_CancelAndDeleteSoonWithPendingRequest CancelAndDeleteSoonWithPendingRequest
#endif
TEST_F(AutoEnrollmentClientTest, MAYBE_CancelAndDeleteSoonWithPendingRequest) {
MockDeviceManagementJob* job = NULL; MockDeviceManagementJob* job = NULL;
ServerWillReplyAsync(&job); ServerWillReplyAsync(&job);
EXPECT_FALSE(job); EXPECT_FALSE(job);
...@@ -422,14 +415,7 @@ TEST_F(AutoEnrollmentClientTest, MAYBE_CancelAndDeleteSoonWithPendingRequest) { ...@@ -422,14 +415,7 @@ TEST_F(AutoEnrollmentClientTest, MAYBE_CancelAndDeleteSoonWithPendingRequest) {
EXPECT_EQ(AUTO_ENROLLMENT_STATE_PENDING, state_); EXPECT_EQ(AUTO_ENROLLMENT_STATE_PENDING, state_);
} }
#if defined(OS_CHROMEOS) TEST_F(AutoEnrollmentClientTest, NetworkChangedAfterCancelAndDeleteSoon) {
// crbug.com/422884
#define MAYBE_NetworkChangedAfterCancelAndDeleteSoon DISABLED_NetworkChangedAfterCancelAndDeleteSoon
#else
#define MAYBE_NetworkChangedAfterCancelAndDeleteSoon
#endif
TEST_F(AutoEnrollmentClientTest, MAYBE_NetworkChangedAfterCancelAndDeleteSoon) {
MockDeviceManagementJob* job = NULL; MockDeviceManagementJob* job = NULL;
ServerWillReplyAsync(&job); ServerWillReplyAsync(&job);
EXPECT_FALSE(job); EXPECT_FALSE(job);
...@@ -459,14 +445,7 @@ TEST_F(AutoEnrollmentClientTest, MAYBE_NetworkChangedAfterCancelAndDeleteSoon) { ...@@ -459,14 +445,7 @@ TEST_F(AutoEnrollmentClientTest, MAYBE_NetworkChangedAfterCancelAndDeleteSoon) {
EXPECT_EQ(AUTO_ENROLLMENT_STATE_PENDING, state_); EXPECT_EQ(AUTO_ENROLLMENT_STATE_PENDING, state_);
} }
#if defined(OS_CHROMEOS) TEST_F(AutoEnrollmentClientTest, CancelAndDeleteSoonAfterCompletion) {
// crbug.com/422884
#define MAYBE_CancelAndDeleteSoonAfterCompletion DISABLED_CancelAndDeleteSoonAfterCompletion
#else
#define MAYBE_CancelAndDeleteSoonAfterCompletion CancelAndDeleteSoonAfterCompletion
#endif
TEST_F(AutoEnrollmentClientTest, MAYBE_CancelAndDeleteSoonAfterCompletion) {
ServerWillReply(-1, true, true); ServerWillReply(-1, true, true);
ServerWillSendState( ServerWillSendState(
"example.com", "example.com",
...@@ -481,14 +460,7 @@ TEST_F(AutoEnrollmentClientTest, MAYBE_CancelAndDeleteSoonAfterCompletion) { ...@@ -481,14 +460,7 @@ TEST_F(AutoEnrollmentClientTest, MAYBE_CancelAndDeleteSoonAfterCompletion) {
EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting()); EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
} }
#if defined(OS_CHROMEOS) TEST_F(AutoEnrollmentClientTest, CancelAndDeleteSoonAfterNetworkFailure) {
// crbug.com/422884
#define MAYBE_CancelAndDeleteSoonAfterNetworkFailure DISABLED_CancelAndDeleteSoonAfterNetworkFailure
#else
#define MAYBE_CancelAndDeleteSoonAfterNetworkFailure CancelAndDeleteSoonAfterNetworkFailure
#endif
TEST_F(AutoEnrollmentClientTest, MAYBE_CancelAndDeleteSoonAfterNetworkFailure) {
ServerWillFail(DM_STATUS_TEMPORARY_UNAVAILABLE); ServerWillFail(DM_STATUS_TEMPORARY_UNAVAILABLE);
client_->Start(); client_->Start();
EXPECT_EQ(AUTO_ENROLLMENT_STATE_SERVER_ERROR, state_); EXPECT_EQ(AUTO_ENROLLMENT_STATE_SERVER_ERROR, state_);
......
...@@ -40,10 +40,7 @@ ...@@ -40,10 +40,7 @@
#include "extensions/browser/url_request_util.h" #include "extensions/browser/url_request_util.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/extensions/updater/extension_cache_impl.h"
#include "chromeos/chromeos_switches.h" #include "chromeos/chromeos_switches.h"
#else
#include "extensions/browser/updater/null_extension_cache.h"
#endif #endif
namespace extensions { namespace extensions {
...@@ -54,12 +51,6 @@ ChromeExtensionsBrowserClient::ChromeExtensionsBrowserClient() { ...@@ -54,12 +51,6 @@ ChromeExtensionsBrowserClient::ChromeExtensionsBrowserClient() {
// Only set if it hasn't already been set (e.g. by a test). // Only set if it hasn't already been set (e.g. by a test).
if (GetCurrentChannel() == GetDefaultChannel()) if (GetCurrentChannel() == GetDefaultChannel())
SetCurrentChannel(chrome::VersionInfo::GetChannel()); SetCurrentChannel(chrome::VersionInfo::GetChannel());
#if defined(OS_CHROMEOS)
extension_cache_.reset(new ExtensionCacheImpl());
#else
extension_cache_.reset(new NullExtensionCache());
#endif
} }
ChromeExtensionsBrowserClient::~ChromeExtensionsBrowserClient() {} ChromeExtensionsBrowserClient::~ChromeExtensionsBrowserClient() {}
...@@ -251,13 +242,6 @@ void ChromeExtensionsBrowserClient::RegisterExtensionFunctions( ...@@ -251,13 +242,6 @@ void ChromeExtensionsBrowserClient::RegisterExtensionFunctions(
extensions::api::GeneratedFunctionRegistry::RegisterAll(registry); extensions::api::GeneratedFunctionRegistry::RegisterAll(registry);
} }
scoped_ptr<extensions::RuntimeAPIDelegate>
ChromeExtensionsBrowserClient::CreateRuntimeAPIDelegate(
content::BrowserContext* context) const {
return scoped_ptr<extensions::RuntimeAPIDelegate>(
new ChromeRuntimeAPIDelegate(context));
}
ComponentExtensionResourceManager* ComponentExtensionResourceManager*
ChromeExtensionsBrowserClient::GetComponentExtensionResourceManager() { ChromeExtensionsBrowserClient::GetComponentExtensionResourceManager() {
if (!resource_manager_) if (!resource_manager_)
...@@ -276,8 +260,11 @@ net::NetLog* ChromeExtensionsBrowserClient::GetNetLog() { ...@@ -276,8 +260,11 @@ net::NetLog* ChromeExtensionsBrowserClient::GetNetLog() {
return g_browser_process->net_log(); return g_browser_process->net_log();
} }
ExtensionCache* ChromeExtensionsBrowserClient::GetExtensionCache() { scoped_ptr<extensions::RuntimeAPIDelegate>
return extension_cache_.get(); ChromeExtensionsBrowserClient::CreateRuntimeAPIDelegate(
content::BrowserContext* context) const {
return scoped_ptr<extensions::RuntimeAPIDelegate>(
new ChromeRuntimeAPIDelegate(context));
} }
} // namespace extensions } // namespace extensions
...@@ -96,7 +96,6 @@ class ChromeExtensionsBrowserClient : public ExtensionsBrowserClient { ...@@ -96,7 +96,6 @@ class ChromeExtensionsBrowserClient : public ExtensionsBrowserClient {
const std::string& event_name, const std::string& event_name,
scoped_ptr<base::ListValue> args) override; scoped_ptr<base::ListValue> args) override;
virtual net::NetLog* GetNetLog() override; virtual net::NetLog* GetNetLog() override;
virtual ExtensionCache* GetExtensionCache() override;
private: private:
friend struct base::DefaultLazyInstanceTraits<ChromeExtensionsBrowserClient>; friend struct base::DefaultLazyInstanceTraits<ChromeExtensionsBrowserClient>;
...@@ -112,8 +111,6 @@ class ChromeExtensionsBrowserClient : public ExtensionsBrowserClient { ...@@ -112,8 +111,6 @@ class ChromeExtensionsBrowserClient : public ExtensionsBrowserClient {
scoped_ptr<ChromeComponentExtensionResourceManager> resource_manager_; scoped_ptr<ChromeComponentExtensionResourceManager> resource_manager_;
scoped_ptr<ExtensionCache> extension_cache_;
DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsBrowserClient); DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsBrowserClient);
}; };
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/unpacked_installer.h" #include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/extensions/updater/extension_cache_fake.h" #include "chrome/browser/extensions/updater/extension_cache_fake.h"
#include "chrome/browser/extensions/updater/extension_updater.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -133,10 +132,6 @@ void ExtensionBrowserTest::SetUpCommandLine(CommandLine* command_line) { ...@@ -133,10 +132,6 @@ void ExtensionBrowserTest::SetUpCommandLine(CommandLine* command_line) {
void ExtensionBrowserTest::SetUpOnMainThread() { void ExtensionBrowserTest::SetUpOnMainThread() {
InProcessBrowserTest::SetUpOnMainThread(); InProcessBrowserTest::SetUpOnMainThread();
observer_.reset(new ExtensionTestNotificationObserver(browser())); observer_.reset(new ExtensionTestNotificationObserver(browser()));
if (extension_service()->updater()) {
extension_service()->updater()->SetExtensionCacheForTesting(
test_extension_cache_.get());
}
} }
const Extension* ExtensionBrowserTest::LoadExtension( const Extension* ExtensionBrowserTest::LoadExtension(
......
...@@ -41,7 +41,6 @@ class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest { ...@@ -41,7 +41,6 @@ class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest {
} }
virtual void SetUpOnMainThread() override { virtual void SetUpOnMainThread() override {
ExtensionBrowserTest::SetUpOnMainThread();
EXPECT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); EXPECT_TRUE(scoped_temp_dir_.CreateUniqueTempDir());
service_ = extensions::ExtensionSystem::Get( service_ = extensions::ExtensionSystem::Get(
browser()->profile())->extension_service(); browser()->profile())->extension_service();
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "chrome/browser/extensions/shared_module_service.h" #include "chrome/browser/extensions/shared_module_service.h"
#include "chrome/browser/extensions/unpacked_installer.h" #include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/extensions/updater/chrome_extension_downloader_factory.h" #include "chrome/browser/extensions/updater/chrome_extension_downloader_factory.h"
#include "chrome/browser/extensions/updater/extension_cache.h"
#include "chrome/browser/extensions/updater/extension_downloader.h" #include "chrome/browser/extensions/updater/extension_downloader.h"
#include "chrome/browser/extensions/updater/extension_updater.h" #include "chrome/browser/extensions/updater/extension_updater.h"
#include "chrome/browser/google/google_brand.h" #include "chrome/browser/google/google_brand.h"
...@@ -67,12 +68,10 @@ ...@@ -67,12 +68,10 @@
#include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/install_flag.h" #include "extensions/browser/install_flag.h"
#include "extensions/browser/runtime_data.h" #include "extensions/browser/runtime_data.h"
#include "extensions/browser/uninstall_reason.h" #include "extensions/browser/uninstall_reason.h"
#include "extensions/browser/update_observer.h" #include "extensions/browser/update_observer.h"
#include "extensions/browser/updater/extension_cache.h"
#include "extensions/common/extension_messages.h" #include "extensions/common/extension_messages.h"
#include "extensions/common/extension_urls.h" #include "extensions/common/extension_urls.h"
#include "extensions/common/feature_switch.h" #include "extensions/common/feature_switch.h"
...@@ -186,8 +185,7 @@ bool ExtensionService::OnExternalExtensionUpdateUrlFound( ...@@ -186,8 +185,7 @@ bool ExtensionService::OnExternalExtensionUpdateUrlFound(
if (Manifest::IsExternalLocation(location)) { if (Manifest::IsExternalLocation(location)) {
// All extensions that are not user specific can be cached. // All extensions that are not user specific can be cached.
extensions::ExtensionsBrowserClient::Get()->GetExtensionCache() extensions::ExtensionCache::GetInstance()->AllowCaching(id);
->AllowCaching(id);
} }
const Extension* extension = GetExtensionById(id, true); const Extension* extension = GetExtensionById(id, true);
...@@ -309,7 +307,7 @@ ExtensionService::ExtensionService(Profile* profile, ...@@ -309,7 +307,7 @@ ExtensionService::ExtensionService(Profile* profile,
profile->GetPrefs(), profile->GetPrefs(),
profile, profile,
update_frequency, update_frequency,
extensions::ExtensionsBrowserClient::Get()->GetExtensionCache(), extensions::ExtensionCache::GetInstance(),
base::Bind(ChromeExtensionDownloaderFactory::CreateForProfile, base::Bind(ChromeExtensionDownloaderFactory::CreateForProfile,
profile))); profile)));
} }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_service_test_base.h" #include "chrome/browser/extensions/extension_service_test_base.h"
#include "chrome/browser/extensions/updater/extension_cache_fake.h" #include "chrome/browser/extensions/updater/extension_cache_fake.h"
#include "chrome/browser/extensions/updater/extension_updater.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_constants.h"
...@@ -63,9 +62,6 @@ class ExternalProviderImplTest : public ExtensionServiceTestBase { ...@@ -63,9 +62,6 @@ class ExternalProviderImplTest : public ExtensionServiceTestBase {
#endif #endif
InitializeExtensionServiceWithUpdater(); InitializeExtensionServiceWithUpdater();
service()->updater()->SetExtensionCacheForTesting(
test_extension_cache_.get());
// Don't install default apps. Some of the default apps are downloaded from // Don't install default apps. Some of the default apps are downloaded from
// the webstore, ignoring the url we pass to kAppsGalleryUpdateURL, which // the webstore, ignoring the url we pass to kAppsGalleryUpdateURL, which
// would cause the external updates to never finish install. // would cause the external updates to never finish install.
......
// Copyright 2014 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 "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 // OS_CHROMEOS
namespace extensions {
namespace {
#if !defined(OS_CHROMEOS)
// Implementation of ExtensionCache that doesn't cache anything.
// Real cache is used only on Chrome OS other OSes use this null implementation.
class ExtensionCacheNullImpl : public ExtensionCache {
public:
static ExtensionCacheNullImpl* GetInstance() {
return Singleton<ExtensionCacheNullImpl>::get();
}
// Implementation of ExtensionCache.
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 // !OS_CHROMEOS
static ExtensionCache* g_extension_cache_override = NULL;
} // namespace
// static
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
}
}
// static
ExtensionCache* ExtensionCache::SetForTesting(ExtensionCache* cache) {
ExtensionCache* temp = g_extension_cache_override;
g_extension_cache_override = cache;
return temp;
}
} // namespace extensions
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef EXTENSIONS_BROWSER_UPDATER_EXTENSION_CACHE_H_ #ifndef CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_CACHE_H_
#define EXTENSIONS_BROWSER_UPDATER_EXTENSION_CACHE_H_ #define CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_CACHE_H_
#include <string> #include <string>
...@@ -16,13 +16,13 @@ namespace extensions { ...@@ -16,13 +16,13 @@ namespace extensions {
// between multiple users and profiles on the machine. // between multiple users and profiles on the machine.
class ExtensionCache { class ExtensionCache {
public: public:
// Return global singleton instance of ExtensionCache.
static ExtensionCache* GetInstance();
// Callback that is invoked when the file placed when PutExtension done. // Callback that is invoked when the file placed when PutExtension done.
typedef base::Callback<void(const base::FilePath& file_path, typedef base::Callback<void(const base::FilePath& file_path,
bool file_ownership_passed)> PutExtensionCallback; bool file_ownership_passed)> PutExtensionCallback;
ExtensionCache() {}
virtual ~ExtensionCache() {}
// Initialize cache in background. The |callback| is called when cache ready. // Initialize cache in background. The |callback| is called when cache ready.
// Can be called multiple times. The |callback| can be called immediately if // Can be called multiple times. The |callback| can be called immediately if
// cache is ready. // cache is ready.
...@@ -54,10 +54,14 @@ class ExtensionCache { ...@@ -54,10 +54,14 @@ class ExtensionCache {
const std::string& version, const std::string& version,
const PutExtensionCallback& callback) = 0; const PutExtensionCallback& callback) = 0;
private: protected:
DISALLOW_COPY_AND_ASSIGN(ExtensionCache); virtual ~ExtensionCache() {}
// Sets the singleton to the given |cache|. Returns the previous value of
// the singleton. Ownership is not transferred.
static ExtensionCache* SetForTesting(ExtensionCache* cache);
}; };
} // namespace extensions } // namespace extensions
#endif // EXTENSIONS_BROWSER_UPDATER_EXTENSION_CACHE_H_ #endif // CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_CACHE_H_
...@@ -11,9 +11,11 @@ ...@@ -11,9 +11,11 @@
namespace extensions { namespace extensions {
ExtensionCacheFake::ExtensionCacheFake() { ExtensionCacheFake::ExtensionCacheFake() {
ExtensionCache::SetForTesting(this);
} }
ExtensionCacheFake::~ExtensionCacheFake() { ExtensionCacheFake::~ExtensionCacheFake() {
ExtensionCache::SetForTesting(NULL);
} }
void ExtensionCacheFake::Start(const base::Closure& callback) { void ExtensionCacheFake::Start(const base::Closure& callback) {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <set> #include <set>
#include <string> #include <string>
#include "extensions/browser/updater/extension_cache.h" #include "chrome/browser/extensions/updater/extension_cache.h"
namespace extensions { namespace extensions {
......
...@@ -35,6 +35,11 @@ const int kMaxCacheAgeDays = 30; ...@@ -35,6 +35,11 @@ const int kMaxCacheAgeDays = 30;
} // namespace } // namespace
// static
ExtensionCacheImpl* ExtensionCacheImpl::GetInstance() {
return Singleton<ExtensionCacheImpl>::get();
}
ExtensionCacheImpl::ExtensionCacheImpl() ExtensionCacheImpl::ExtensionCacheImpl()
: cache_(new LocalExtensionCache(base::FilePath(kLocalCacheDir), : cache_(new LocalExtensionCache(base::FilePath(kLocalCacheDir),
kMaxCacheSize, kMaxCacheSize,
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "chrome/browser/extensions/updater/extension_cache.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
#include "extensions/browser/updater/extension_cache.h"
template <typename T> struct DefaultSingletonTraits; template <typename T> struct DefaultSingletonTraits;
...@@ -28,8 +28,7 @@ class LocalExtensionCache; ...@@ -28,8 +28,7 @@ class LocalExtensionCache;
class ExtensionCacheImpl : public ExtensionCache, class ExtensionCacheImpl : public ExtensionCache,
public content::NotificationObserver { public content::NotificationObserver {
public: public:
ExtensionCacheImpl(); static ExtensionCacheImpl* GetInstance();
virtual ~ExtensionCacheImpl();
// Implementation of ExtensionCache. // Implementation of ExtensionCache.
virtual void Start(const base::Closure& callback) override; virtual void Start(const base::Closure& callback) override;
...@@ -49,6 +48,11 @@ class ExtensionCacheImpl : public ExtensionCache, ...@@ -49,6 +48,11 @@ class ExtensionCacheImpl : public ExtensionCache,
const content::NotificationDetails& details) override; const content::NotificationDetails& details) override;
private: private:
friend struct DefaultSingletonTraits<ExtensionCacheImpl>;
ExtensionCacheImpl();
virtual ~ExtensionCacheImpl();
// Callback that is called when local cache is ready. // Callback that is called when local cache is ready.
void OnCacheInitialized(); void OnCacheInitialized();
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "base/version.h" #include "base/version.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/updater/extension_cache.h"
#include "chrome/browser/extensions/updater/request_queue_impl.h" #include "chrome/browser/extensions/updater/request_queue_impl.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h" #include "chrome/common/chrome_version_info.h"
...@@ -28,7 +29,6 @@ ...@@ -28,7 +29,6 @@
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h" #include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "extensions/browser/updater/extension_cache.h"
#include "extensions/browser/updater/safe_manifest_parser.h" #include "extensions/browser/updater/safe_manifest_parser.h"
#include "extensions/common/extension_urls.h" #include "extensions/common/extension_urls.h"
#include "google_apis/gaia/identity_provider.h" #include "google_apis/gaia/identity_provider.h"
......
...@@ -395,11 +395,6 @@ bool ExtensionUpdater::WillCheckSoon() const { ...@@ -395,11 +395,6 @@ bool ExtensionUpdater::WillCheckSoon() const {
return will_check_soon_; return will_check_soon_;
} }
void ExtensionUpdater::SetExtensionCacheForTesting(
ExtensionCache* extension_cache) {
extension_cache_ = extension_cache;
}
void ExtensionUpdater::DoCheckSoon() { void ExtensionUpdater::DoCheckSoon() {
DCHECK(will_check_soon_); DCHECK(will_check_soon_);
CheckNow(default_params_); CheckNow(default_params_);
......
...@@ -125,9 +125,6 @@ class ExtensionUpdater : public ExtensionDownloaderDelegate, ...@@ -125,9 +125,6 @@ class ExtensionUpdater : public ExtensionDownloaderDelegate,
default_params_ = params; default_params_ = params;
} }
// Overrides the extension cache with |extension_cache| for testing.
void SetExtensionCacheForTesting(ExtensionCache* extension_cache);
private: private:
friend class ExtensionUpdaterTest; friend class ExtensionUpdaterTest;
friend class ExtensionUpdaterFileHandler; friend class ExtensionUpdaterFileHandler;
......
...@@ -611,10 +611,6 @@ class PolicyTest : public InProcessBrowserTest { ...@@ -611,10 +611,6 @@ class PolicyTest : public InProcessBrowserTest {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
base::Bind(chrome_browser_net::SetUrlRequestMocksEnabled, true)); base::Bind(chrome_browser_net::SetUrlRequestMocksEnabled, true));
if (extension_service()->updater()) {
extension_service()->updater()->SetExtensionCacheForTesting(
test_extension_cache_.get());
}
} }
// Makes URLRequestMockHTTPJobs serve data from content::DIR_TEST_DATA // Makes URLRequestMockHTTPJobs serve data from content::DIR_TEST_DATA
......
...@@ -783,6 +783,8 @@ ...@@ -783,6 +783,8 @@
'browser/extensions/unpacked_installer.h', 'browser/extensions/unpacked_installer.h',
'browser/extensions/updater/chrome_extension_downloader_factory.cc', 'browser/extensions/updater/chrome_extension_downloader_factory.cc',
'browser/extensions/updater/chrome_extension_downloader_factory.h', 'browser/extensions/updater/chrome_extension_downloader_factory.h',
'browser/extensions/updater/extension_cache.cc',
'browser/extensions/updater/extension_cache.h',
'browser/extensions/updater/extension_downloader.cc', 'browser/extensions/updater/extension_downloader.cc',
'browser/extensions/updater/extension_downloader.h', 'browser/extensions/updater/extension_downloader.h',
'browser/extensions/updater/extension_downloader_delegate.cc', 'browser/extensions/updater/extension_downloader_delegate.cc',
......
...@@ -426,11 +426,8 @@ source_set("browser") { ...@@ -426,11 +426,8 @@ source_set("browser") {
"suggest_permission_util.h", "suggest_permission_util.h",
"uninstall_reason.h", "uninstall_reason.h",
"update_observer.h", "update_observer.h",
"updater/extension_cache.h",
"updater/manifest_fetch_data.cc", "updater/manifest_fetch_data.cc",
"updater/manifest_fetch_data.h", "updater/manifest_fetch_data.h",
"updater/null_extension_cache.cc",
"updater/null_extension_cache.h",
"updater/safe_manifest_parser.cc", "updater/safe_manifest_parser.cc",
"updater/safe_manifest_parser.h", "updater/safe_manifest_parser.h",
"url_request_util.cc", "url_request_util.cc",
......
...@@ -38,7 +38,6 @@ class ApiActivityMonitor; ...@@ -38,7 +38,6 @@ class ApiActivityMonitor;
class AppSorting; class AppSorting;
class ComponentExtensionResourceManager; class ComponentExtensionResourceManager;
class Extension; class Extension;
class ExtensionCache;
class ExtensionHostDelegate; class ExtensionHostDelegate;
class ExtensionPrefsObserver; class ExtensionPrefsObserver;
class ExtensionSystem; class ExtensionSystem;
...@@ -188,9 +187,6 @@ class ExtensionsBrowserClient { ...@@ -188,9 +187,6 @@ class ExtensionsBrowserClient {
// Returns the embedder's net::NetLog. // Returns the embedder's net::NetLog.
virtual net::NetLog* GetNetLog() = 0; virtual net::NetLog* GetNetLog() = 0;
// Gets the single ExtensionCache instance shared across the browser process.
virtual ExtensionCache* GetExtensionCache() = 0;
// Returns the single instance of |this|. // Returns the single instance of |this|.
static ExtensionsBrowserClient* Get(); static ExtensionsBrowserClient* Get();
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "extensions/browser/app_sorting.h" #include "extensions/browser/app_sorting.h"
#include "extensions/browser/extension_host_delegate.h" #include "extensions/browser/extension_host_delegate.h"
#include "extensions/browser/test_runtime_api_delegate.h" #include "extensions/browser/test_runtime_api_delegate.h"
#include "extensions/browser/updater/null_extension_cache.h"
using content::BrowserContext; using content::BrowserContext;
...@@ -19,8 +18,7 @@ TestExtensionsBrowserClient::TestExtensionsBrowserClient( ...@@ -19,8 +18,7 @@ TestExtensionsBrowserClient::TestExtensionsBrowserClient(
: main_context_(main_context), : main_context_(main_context),
incognito_context_(NULL), incognito_context_(NULL),
process_manager_delegate_(NULL), process_manager_delegate_(NULL),
extension_system_factory_(NULL), extension_system_factory_(NULL) {
extension_cache_(new NullExtensionCache) {
DCHECK(main_context_); DCHECK(main_context_);
DCHECK(!main_context_->IsOffTheRecord()); DCHECK(!main_context_->IsOffTheRecord());
} }
...@@ -173,8 +171,4 @@ net::NetLog* TestExtensionsBrowserClient::GetNetLog() { ...@@ -173,8 +171,4 @@ net::NetLog* TestExtensionsBrowserClient::GetNetLog() {
return NULL; return NULL;
} }
ExtensionCache* TestExtensionsBrowserClient::GetExtensionCache() {
return extension_cache_.get();
}
} // namespace extensions } // namespace extensions
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "extensions/browser/extensions_browser_client.h" #include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/updater/extension_cache.h"
namespace extensions { namespace extensions {
...@@ -26,9 +25,6 @@ class TestExtensionsBrowserClient : public ExtensionsBrowserClient { ...@@ -26,9 +25,6 @@ class TestExtensionsBrowserClient : public ExtensionsBrowserClient {
void set_extension_system_factory(ExtensionSystemProvider* factory) { void set_extension_system_factory(ExtensionSystemProvider* factory) {
extension_system_factory_ = factory; extension_system_factory_ = factory;
} }
void set_extension_cache(scoped_ptr<ExtensionCache> extension_cache) {
extension_cache_ = extension_cache.Pass();
}
// Associates an incognito context with |main_context_|. // Associates an incognito context with |main_context_|.
void SetIncognitoContext(content::BrowserContext* incognito_context); void SetIncognitoContext(content::BrowserContext* incognito_context);
...@@ -89,7 +85,6 @@ class TestExtensionsBrowserClient : public ExtensionsBrowserClient { ...@@ -89,7 +85,6 @@ class TestExtensionsBrowserClient : public ExtensionsBrowserClient {
const std::string& event_name, const std::string& event_name,
scoped_ptr<base::ListValue> args) override; scoped_ptr<base::ListValue> args) override;
virtual net::NetLog* GetNetLog() override; virtual net::NetLog* GetNetLog() override;
virtual ExtensionCache* GetExtensionCache() override;
private: private:
content::BrowserContext* main_context_; // Not owned. content::BrowserContext* main_context_; // Not owned.
...@@ -101,8 +96,6 @@ class TestExtensionsBrowserClient : public ExtensionsBrowserClient { ...@@ -101,8 +96,6 @@ class TestExtensionsBrowserClient : public ExtensionsBrowserClient {
// Not owned, defaults to NULL. // Not owned, defaults to NULL.
ExtensionSystemProvider* extension_system_factory_; ExtensionSystemProvider* extension_system_factory_;
scoped_ptr<ExtensionCache> extension_cache_;
DISALLOW_COPY_AND_ASSIGN(TestExtensionsBrowserClient); DISALLOW_COPY_AND_ASSIGN(TestExtensionsBrowserClient);
}; };
......
// Copyright 2014 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 "extensions/browser/updater/null_extension_cache.h"
#include "base/callback.h"
namespace extensions {
NullExtensionCache::NullExtensionCache() {
}
NullExtensionCache::~NullExtensionCache() {
}
void NullExtensionCache::Start(const base::Closure& callback) {
callback.Run();
}
void NullExtensionCache::Shutdown(const base::Closure& callback) {
callback.Run();
}
void NullExtensionCache::AllowCaching(const std::string& id) {
}
bool NullExtensionCache::GetExtension(const std::string& id,
base::FilePath* file_path,
std::string* version) {
return false;
}
void NullExtensionCache::PutExtension(const std::string& id,
const base::FilePath& file_path,
const std::string& version,
const PutExtensionCallback& callback) {
callback.Run(file_path, true);
}
} // namespace extensions
// Copyright 2014 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 EXTENSIONS_BROWSER_UPDATER_NULL_EXTENSION_CACHE_H_
#define EXTENSIONS_BROWSER_UPDATER_NULL_EXTENSION_CACHE_H_
#include "extensions/browser/updater/extension_cache.h"
namespace extensions {
// Implements a pass-thru (i.e. do-nothing) ExtensionCache.
class NullExtensionCache : public ExtensionCache {
public:
NullExtensionCache();
virtual ~NullExtensionCache();
// ExtensionCache implementation.
virtual void Start(const base::Closure& callback) override;
virtual void Shutdown(const base::Closure& callback) override;
virtual void AllowCaching(const std::string& id) override;
virtual bool GetExtension(const std::string& id,
base::FilePath* file_path,
std::string* version) override;
virtual void PutExtension(const std::string& id,
const base::FilePath& file_path,
const std::string& version,
const PutExtensionCallback& callback) override;
private:
DISALLOW_COPY_AND_ASSIGN(NullExtensionCache);
};
} // namespace extensions
#endif // EXTENSIONS_BROWSER_UPDATER_NULL_EXTENSION_CACHE_H_
...@@ -714,11 +714,8 @@ ...@@ -714,11 +714,8 @@
'browser/suggest_permission_util.h', 'browser/suggest_permission_util.h',
'browser/uninstall_reason.h', 'browser/uninstall_reason.h',
'browser/update_observer.h', 'browser/update_observer.h',
'browser/updater/extension_cache.h',
'browser/updater/manifest_fetch_data.cc', 'browser/updater/manifest_fetch_data.cc',
'browser/updater/manifest_fetch_data.h', 'browser/updater/manifest_fetch_data.h',
'browser/updater/null_extension_cache.cc',
'browser/updater/null_extension_cache.h',
'browser/updater/safe_manifest_parser.cc', 'browser/updater/safe_manifest_parser.cc',
'browser/updater/safe_manifest_parser.h', 'browser/updater/safe_manifest_parser.h',
'browser/url_request_util.cc', 'browser/url_request_util.cc',
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "extensions/browser/extension_function_registry.h" #include "extensions/browser/extension_function_registry.h"
#include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_prefs.h"
#include "extensions/browser/null_app_sorting.h" #include "extensions/browser/null_app_sorting.h"
#include "extensions/browser/updater/null_extension_cache.h"
#include "extensions/browser/url_request_util.h" #include "extensions/browser/url_request_util.h"
#include "extensions/shell/browser/shell_extension_host_delegate.h" #include "extensions/shell/browser/shell_extension_host_delegate.h"
#include "extensions/shell/browser/shell_extension_system_factory.h" #include "extensions/shell/browser/shell_extension_system_factory.h"
...@@ -38,9 +37,7 @@ void RegisterPrefs(user_prefs::PrefRegistrySyncable* registry) { ...@@ -38,9 +37,7 @@ void RegisterPrefs(user_prefs::PrefRegistrySyncable* registry) {
ShellExtensionsBrowserClient::ShellExtensionsBrowserClient( ShellExtensionsBrowserClient::ShellExtensionsBrowserClient(
BrowserContext* context) BrowserContext* context)
: browser_context_(context), : browser_context_(context), api_client_(new ExtensionsAPIClient) {
api_client_(new ExtensionsAPIClient),
extension_cache_(new NullExtensionCache()) {
// Set up the preferences service. // Set up the preferences service.
base::PrefServiceFactory factory; base::PrefServiceFactory factory;
factory.set_user_prefs(new TestingPrefStore); factory.set_user_prefs(new TestingPrefStore);
...@@ -222,8 +219,4 @@ net::NetLog* ShellExtensionsBrowserClient::GetNetLog() { ...@@ -222,8 +219,4 @@ net::NetLog* ShellExtensionsBrowserClient::GetNetLog() {
return NULL; return NULL;
} }
ExtensionCache* ShellExtensionsBrowserClient::GetExtensionCache() {
return extension_cache_.get();
}
} // namespace extensions } // namespace extensions
...@@ -78,7 +78,6 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient { ...@@ -78,7 +78,6 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient {
const std::string& event_name, const std::string& event_name,
scoped_ptr<base::ListValue> args) override; scoped_ptr<base::ListValue> args) override;
virtual net::NetLog* GetNetLog() override; virtual net::NetLog* GetNetLog() override;
virtual ExtensionCache* GetExtensionCache() override;
private: private:
// The single BrowserContext for app_shell. Not owned. // The single BrowserContext for app_shell. Not owned.
...@@ -90,9 +89,6 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient { ...@@ -90,9 +89,6 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient {
// The PrefService for |browser_context_|. // The PrefService for |browser_context_|.
scoped_ptr<PrefService> prefs_; scoped_ptr<PrefService> prefs_;
// The extension cache used for download and installation.
scoped_ptr<ExtensionCache> extension_cache_;
DISALLOW_COPY_AND_ASSIGN(ShellExtensionsBrowserClient); DISALLOW_COPY_AND_ASSIGN(ShellExtensionsBrowserClient);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment