Commit 1e53068d authored by Istiaque Ahmed's avatar Istiaque Ahmed Committed by Commit Bot

Remove ExtensionCacheDelegate class.

ExtensionCacheDelegate has only one concrete chromeos specific
implementation: ChromeOSExtensionCacheDelegate. Pull all methods
into that class and delete ExtensionCacheDelegate.

Bug: None
Change-Id: Ibdcfad8d45d7c84039ddf0244312ccdd5b047a64
Reviewed-on: https://chromium-review.googlesource.com/c/1257900
Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596399}
parent 65590351
......@@ -952,8 +952,6 @@ jumbo_static_library("extensions") {
"chrome_kiosk_delegate_chromeos.cc",
"updater/chromeos_extension_cache_delegate.cc",
"updater/chromeos_extension_cache_delegate.h",
"updater/extension_cache_delegate.cc",
"updater/extension_cache_delegate.h",
"updater/extension_cache_impl.cc",
"updater/extension_cache_impl.h",
"updater/local_extension_cache.cc",
......
......@@ -27,8 +27,17 @@ const base::FilePath& ChromeOSExtensionCacheDelegate::GetCacheDir() const {
return cache_dir_;
}
size_t ChromeOSExtensionCacheDelegate::GetMinimumCacheSize() const {
// Default minimum size of local cache on disk, in bytes.
static constexpr int kDefaultMinimumCacheSize = 1024 * 1024;
return kDefaultMinimumCacheSize;
}
size_t ChromeOSExtensionCacheDelegate::GetMaximumCacheSize() const {
size_t max_size = ExtensionCacheDelegate::GetMaximumCacheSize();
// Default maximum size of local cache on disk, in bytes.
static constexpr size_t kDefaultCacheSizeLimit = 256 * 1024 * 1024;
size_t max_size = kDefaultCacheSizeLimit;
int policy_size = 0;
if (chromeos::CrosSettings::Get()->GetInteger(chromeos::kExtensionCacheSize,
&policy_size) &&
......@@ -38,4 +47,10 @@ size_t ChromeOSExtensionCacheDelegate::GetMaximumCacheSize() const {
return max_size;
}
base::TimeDelta ChromeOSExtensionCacheDelegate::GetMaximumCacheAge() const {
// Maximum age of unused extensions in the cache.
static constexpr base::TimeDelta kMaxCacheAge = base::TimeDelta::FromDays(30);
return kMaxCacheAge;
}
} // namespace extensions
......@@ -9,19 +9,21 @@
#include "base/files/file_path.h"
#include "base/macros.h"
#include "chrome/browser/extensions/updater/extension_cache_delegate.h"
#include "base/time/time.h"
namespace extensions {
// Chrome OS-specific implementation, which has a pre-defined extension cache
// path and a policy-configurable maximum cache size.
class ChromeOSExtensionCacheDelegate : public ExtensionCacheDelegate {
class ChromeOSExtensionCacheDelegate {
public:
ChromeOSExtensionCacheDelegate();
explicit ChromeOSExtensionCacheDelegate(const base::FilePath& cache_dir);
const base::FilePath& GetCacheDir() const override;
size_t GetMaximumCacheSize() const override;
const base::FilePath& GetCacheDir() const;
size_t GetMinimumCacheSize() const;
size_t GetMaximumCacheSize() const;
base::TimeDelta GetMaximumCacheAge() const;
private:
base::FilePath cache_dir_;
......
// Copyright 2015 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_delegate.h"
namespace extensions {
ExtensionCacheDelegate::~ExtensionCacheDelegate() {
}
size_t ExtensionCacheDelegate::GetMinimumCacheSize() const {
// Default minimum size of local cache on disk, in bytes.
static constexpr int kDefaultMinimumCacheSize = 1024 * 1024;
return kDefaultMinimumCacheSize;
}
size_t ExtensionCacheDelegate::GetMaximumCacheSize() const {
// Default maximum size of local cache on disk, in bytes.
static constexpr size_t kDefaultCacheSizeLimit = 256 * 1024 * 1024;
return kDefaultCacheSizeLimit;
}
base::TimeDelta ExtensionCacheDelegate::GetMaximumCacheAge() const {
// Maximum age of unused extensions in the cache.
static constexpr base::TimeDelta kMaxCacheAge = base::TimeDelta::FromDays(30);
return kMaxCacheAge;
}
} // namespace extensions
// Copyright 2015 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 CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_CACHE_DELEGATE_H_
#define CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_CACHE_DELEGATE_H_
#include <stddef.h>
#include "base/macros.h"
#include "base/time/time.h"
namespace base {
class FilePath;
} // namespace base
namespace extensions {
// This class is used to pass ExtensionCacheImpl's initialization parameters.
// Every function of this class is called only once during ExtensionCacheImpl
// construction.
class ExtensionCacheDelegate {
public:
virtual ~ExtensionCacheDelegate();
virtual const base::FilePath& GetCacheDir() const = 0;
virtual size_t GetMinimumCacheSize() const;
virtual size_t GetMaximumCacheSize() const;
virtual base::TimeDelta GetMaximumCacheAge() const;
private:
DISALLOW_ASSIGN(ExtensionCacheDelegate);
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_CACHE_DELEGATE_H_
......@@ -15,7 +15,7 @@
#include "base/task/post_task.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/updater/extension_cache_delegate.h"
#include "chrome/browser/extensions/updater/chromeos_extension_cache_delegate.h"
#include "chrome/browser/extensions/updater/local_extension_cache.h"
#include "chrome/common/extensions/extension_constants.h"
#include "content/public/browser/notification_details.h"
......@@ -27,7 +27,7 @@
namespace extensions {
ExtensionCacheImpl::ExtensionCacheImpl(
std::unique_ptr<ExtensionCacheDelegate> delegate)
std::unique_ptr<ChromeOSExtensionCacheDelegate> delegate)
: cache_(new LocalExtensionCache(
delegate->GetCacheDir(),
delegate->GetMaximumCacheSize(),
......
......@@ -24,7 +24,7 @@ template <typename T> struct DefaultSingletonTraits;
namespace extensions {
class ExtensionCacheDelegate;
class ChromeOSExtensionCacheDelegate;
class LocalExtensionCache;
// Singleton call that caches extensions .crx files to share them between
......@@ -32,7 +32,8 @@ class LocalExtensionCache;
class ExtensionCacheImpl : public ExtensionCache,
public content::NotificationObserver {
public:
explicit ExtensionCacheImpl(std::unique_ptr<ExtensionCacheDelegate> delegate);
explicit ExtensionCacheImpl(
std::unique_ptr<ChromeOSExtensionCacheDelegate> delegate);
~ExtensionCacheImpl() override;
// Implementation of ExtensionCache.
......
......@@ -27,7 +27,7 @@ TestExtensionsBrowserClient::TestExtensionsBrowserClient(
lock_screen_context_(nullptr),
process_manager_delegate_(nullptr),
extension_system_factory_(nullptr),
extension_cache_(new NullExtensionCache) {
extension_cache_(std::make_unique<NullExtensionCache>()) {
if (main_context)
SetMainContext(main_context);
}
......
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