Commit 4633793c authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

Cleanup: Pass scoped_refptr by value in storage extensions API.

Change-Id: I6af2fa3afea5c0d833f67501a31856511a1d064b
Reviewed-on: https://chromium-review.googlesource.com/c/1266885Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597644}
parent 87e27d9a
......@@ -49,6 +49,7 @@
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
#include "extensions/browser/guest_view/web_view/web_view_permission_helper.h"
#include "extensions/browser/value_store/value_store_factory.h"
#include "google_apis/gaia/gaia_urls.h"
#include "printing/buildflags/buildflags.h"
#include "url/gurl.h"
......
......@@ -235,15 +235,15 @@ void ManagedValueStoreCache::ExtensionTracker::Register(
ManagedValueStoreCache::ManagedValueStoreCache(
BrowserContext* context,
const scoped_refptr<ValueStoreFactory>& factory,
const scoped_refptr<SettingsObserverList>& observers)
scoped_refptr<ValueStoreFactory> factory,
scoped_refptr<SettingsObserverList> observers)
: profile_(Profile::FromBrowserContext(context)),
policy_domain_(GetPolicyDomain(profile_)),
policy_service_(
policy::ProfilePolicyConnectorFactory::GetForBrowserContext(context)
->policy_service()),
storage_factory_(factory),
observers_(observers) {
storage_factory_(std::move(factory)),
observers_(std::move(observers)) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
policy_service_->AddObserver(policy_domain_, this);
......
......@@ -44,8 +44,8 @@ class ManagedValueStoreCache : public ValueStoreCache,
// |observers| is the list of SettingsObservers to notify when a ValueStore
// changes.
ManagedValueStoreCache(content::BrowserContext* context,
const scoped_refptr<ValueStoreFactory>& factory,
const scoped_refptr<SettingsObserverList>& observers);
scoped_refptr<ValueStoreFactory> factory,
scoped_refptr<SettingsObserverList> observers);
~ManagedValueStoreCache() override;
private:
......
......@@ -27,10 +27,10 @@ ValueStore::Status ReadOnlyError() {
PolicyValueStore::PolicyValueStore(
const std::string& extension_id,
const scoped_refptr<SettingsObserverList>& observers,
scoped_refptr<SettingsObserverList> observers,
std::unique_ptr<ValueStore> delegate)
: extension_id_(extension_id),
observers_(observers),
observers_(std::move(observers)),
delegate_(std::move(delegate)) {}
PolicyValueStore::~PolicyValueStore() {}
......
......@@ -31,7 +31,7 @@ namespace extensions {
class PolicyValueStore : public ValueStore {
public:
PolicyValueStore(const std::string& extension_id,
const scoped_refptr<SettingsObserverList>& observers,
scoped_refptr<SettingsObserverList> observers,
std::unique_ptr<ValueStore> delegate);
~PolicyValueStore() override;
......
......@@ -48,14 +48,14 @@ ValueStoreFactory::ModelType ToFactoryModelType(syncer::ModelType sync_type) {
} // namespace
SyncStorageBackend::SyncStorageBackend(
const scoped_refptr<ValueStoreFactory>& storage_factory,
scoped_refptr<ValueStoreFactory> storage_factory,
const SettingsStorageQuotaEnforcer::Limits& quota,
const scoped_refptr<SettingsObserverList>& observers,
scoped_refptr<SettingsObserverList> observers,
syncer::ModelType sync_type,
const syncer::SyncableService::StartSyncFlare& flare)
: storage_factory_(storage_factory),
: storage_factory_(std::move(storage_factory)),
quota_(quota),
observers_(observers),
observers_(std::move(observers)),
sync_type_(sync_type),
flare_(flare) {
DCHECK(IsOnBackendSequence());
......
......@@ -36,9 +36,9 @@ class SyncStorageBackend : public syncer::SyncableService {
public:
// |storage_factory| is use to create leveldb storage areas.
// |observers| is the list of observers to settings changes.
SyncStorageBackend(const scoped_refptr<ValueStoreFactory>& storage_factory,
SyncStorageBackend(scoped_refptr<ValueStoreFactory> storage_factory,
const SettingsStorageQuotaEnforcer::Limits& quota,
const scoped_refptr<SettingsObserverList>& observers,
scoped_refptr<SettingsObserverList> observers,
syncer::ModelType sync_type,
const syncer::SyncableService::StartSyncFlare& flare);
......
......@@ -6,6 +6,8 @@
#include <stddef.h>
#include <utility>
#include "chrome/browser/extensions/api/storage/sync_storage_backend.h"
#include "chrome/browser/sync/glue/sync_start_util.h"
#include "content/public/browser/browser_thread.h"
......@@ -33,8 +35,8 @@ SettingsStorageQuotaEnforcer::Limits GetSyncQuotaLimits() {
} // namespace
SyncValueStoreCache::SyncValueStoreCache(
const scoped_refptr<ValueStoreFactory>& factory,
const scoped_refptr<SettingsObserverList>& observers,
scoped_refptr<ValueStoreFactory> factory,
scoped_refptr<SettingsObserverList> observers,
const base::FilePath& profile_path)
: initialized_(false) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
......@@ -43,9 +45,9 @@ SyncValueStoreCache::SyncValueStoreCache(
// same message loop, and any potential post of a deletion task must come
// after the constructor returns.
GetBackendTaskRunner()->PostTask(
FROM_HERE,
base::BindOnce(&SyncValueStoreCache::InitOnBackend,
base::Unretained(this), factory, observers, profile_path));
FROM_HERE, base::BindOnce(&SyncValueStoreCache::InitOnBackend,
base::Unretained(this), std::move(factory),
std::move(observers), profile_path));
}
SyncValueStoreCache::~SyncValueStoreCache() {
......@@ -85,23 +87,18 @@ void SyncValueStoreCache::DeleteStorageSoon(const std::string& extension_id) {
}
void SyncValueStoreCache::InitOnBackend(
const scoped_refptr<ValueStoreFactory>& factory,
const scoped_refptr<SettingsObserverList>& observers,
scoped_refptr<ValueStoreFactory> factory,
scoped_refptr<SettingsObserverList> observers,
const base::FilePath& profile_path) {
DCHECK(IsOnBackendSequence());
DCHECK(!initialized_);
app_backend_.reset(new SyncStorageBackend(
factory,
GetSyncQuotaLimits(),
observers,
syncer::APP_SETTINGS,
sync_start_util::GetFlareForSyncableService(profile_path)));
extension_backend_.reset(new SyncStorageBackend(
factory,
GetSyncQuotaLimits(),
observers,
app_backend_ = std::make_unique<SyncStorageBackend>(
factory, GetSyncQuotaLimits(), observers, syncer::APP_SETTINGS,
sync_start_util::GetFlareForSyncableService(profile_path));
extension_backend_ = std::make_unique<SyncStorageBackend>(
std::move(factory), GetSyncQuotaLimits(), std::move(observers),
syncer::EXTENSION_SETTINGS,
sync_start_util::GetFlareForSyncableService(profile_path)));
sync_start_util::GetFlareForSyncableService(profile_path));
initialized_ = true;
}
......
......@@ -31,8 +31,8 @@ class ValueStoreFactory;
// another for extensions. Each backend takes care of persistence and syncing.
class SyncValueStoreCache : public ValueStoreCache {
public:
SyncValueStoreCache(const scoped_refptr<ValueStoreFactory>& factory,
const scoped_refptr<SettingsObserverList>& observers,
SyncValueStoreCache(scoped_refptr<ValueStoreFactory> factory,
scoped_refptr<SettingsObserverList> observers,
const base::FilePath& profile_path);
~SyncValueStoreCache() override;
......@@ -45,8 +45,8 @@ class SyncValueStoreCache : public ValueStoreCache {
void DeleteStorageSoon(const std::string& extension_id) override;
private:
void InitOnBackend(const scoped_refptr<ValueStoreFactory>& factory,
const scoped_refptr<SettingsObserverList>& observers,
void InitOnBackend(scoped_refptr<ValueStoreFactory> factory,
scoped_refptr<SettingsObserverList> observers,
const base::FilePath& profile_path);
bool initialized_;
......
......@@ -17,13 +17,12 @@
namespace extensions {
SyncableSettingsStorage::SyncableSettingsStorage(
const scoped_refptr<base::ObserverListThreadSafe<SettingsObserver>>&
observers,
scoped_refptr<base::ObserverListThreadSafe<SettingsObserver>> observers,
const std::string& extension_id,
ValueStore* delegate,
syncer::ModelType sync_type,
const syncer::SyncableService::StartSyncFlare& flare)
: observers_(observers),
: observers_(std::move(observers)),
extension_id_(extension_id),
delegate_(delegate),
sync_type_(sync_type),
......
......@@ -29,13 +29,12 @@ class SettingsSyncProcessor;
// Decorates a ValueStore with sync behaviour.
class SyncableSettingsStorage : public ValueStore {
public:
SyncableSettingsStorage(
const scoped_refptr<SettingsObserverList>& observers,
const std::string& extension_id,
// Ownership taken.
ValueStore* delegate,
syncer::ModelType sync_type,
const syncer::SyncableService::StartSyncFlare& flare);
SyncableSettingsStorage(scoped_refptr<SettingsObserverList> observers,
const std::string& extension_id,
// Ownership taken.
ValueStore* delegate,
syncer::ModelType sync_type,
const syncer::SyncableService::StartSyncFlare& flare);
~SyncableSettingsStorage() override;
......
......@@ -7,6 +7,7 @@
#include <stddef.h>
#include <limits>
#include <utility>
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/api/storage/backend_task_runner.h"
......@@ -34,8 +35,8 @@ SettingsStorageQuotaEnforcer::Limits GetLocalQuotaLimits() {
} // namespace
LocalValueStoreCache::LocalValueStoreCache(
const scoped_refptr<ValueStoreFactory>& factory)
: storage_factory_(factory), quota_(GetLocalQuotaLimits()) {
scoped_refptr<ValueStoreFactory> factory)
: storage_factory_(std::move(factory)), quota_(GetLocalQuotaLimits()) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
......
......@@ -21,8 +21,7 @@ class ValueStoreFactory;
// another for extensions. Each backend takes care of persistence.
class LocalValueStoreCache : public ValueStoreCache {
public:
explicit LocalValueStoreCache(
const scoped_refptr<ValueStoreFactory>& factory);
explicit LocalValueStoreCache(scoped_refptr<ValueStoreFactory> factory);
~LocalValueStoreCache() override;
// ValueStoreCache implementation:
......
......@@ -78,23 +78,23 @@ StorageFrontend* StorageFrontend::Get(BrowserContext* context) {
// static
std::unique_ptr<StorageFrontend> StorageFrontend::CreateForTesting(
const scoped_refptr<ValueStoreFactory>& storage_factory,
scoped_refptr<ValueStoreFactory> storage_factory,
BrowserContext* context) {
return base::WrapUnique(new StorageFrontend(storage_factory, context));
return base::WrapUnique(
new StorageFrontend(std::move(storage_factory), context));
}
StorageFrontend::StorageFrontend(BrowserContext* context)
: StorageFrontend(ExtensionSystem::Get(context)->store_factory(), context) {
}
StorageFrontend::StorageFrontend(
const scoped_refptr<ValueStoreFactory>& factory,
BrowserContext* context)
StorageFrontend::StorageFrontend(scoped_refptr<ValueStoreFactory> factory,
BrowserContext* context)
: browser_context_(context) {
Init(factory);
Init(std::move(factory));
}
void StorageFrontend::Init(const scoped_refptr<ValueStoreFactory>& factory) {
void StorageFrontend::Init(scoped_refptr<ValueStoreFactory> factory) {
TRACE_EVENT0("browser,startup", "StorageFrontend::Init")
SCOPED_UMA_HISTOGRAM_TIMER("Extensions.StorageFrontendInitTime");
......
......@@ -32,7 +32,7 @@ class StorageFrontend : public BrowserContextKeyedAPI {
// Creates with a specific |storage_factory|.
static std::unique_ptr<StorageFrontend> CreateForTesting(
const scoped_refptr<ValueStoreFactory>& storage_factory,
scoped_refptr<ValueStoreFactory> storage_factory,
content::BrowserContext* context);
// Public so tests can create and delete their own instances.
......@@ -75,10 +75,10 @@ class StorageFrontend : public BrowserContextKeyedAPI {
explicit StorageFrontend(content::BrowserContext* context);
// Constructor for tests.
StorageFrontend(const scoped_refptr<ValueStoreFactory>& storage_factory,
StorageFrontend(scoped_refptr<ValueStoreFactory> storage_factory,
content::BrowserContext* context);
void Init(const scoped_refptr<ValueStoreFactory>& storage_factory);
void Init(scoped_refptr<ValueStoreFactory> storage_factory);
// The (non-incognito) browser context this Frontend belongs to.
content::BrowserContext* const browser_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