Commit 47eeb75d authored by Austin Tankiang's avatar Austin Tankiang Committed by Commit Bot

Create PreferenceWatcher in DriveIntegrationService

PreferenceWatcher is private to DriveIntegrationService, so there's no
point having it be passed in.

Bug: 1096355
Change-Id: I753c1c452d6873768f89d25f6737732624cc8b98
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2251268Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarSergei Datsenko <dats@chromium.org>
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779768}
parent 0912eced
......@@ -537,7 +537,6 @@ class DriveIntegrationService::DriveFsHolder
DriveIntegrationService::DriveIntegrationService(
Profile* profile,
PreferenceWatcher* preference_watcher,
const std::string& test_mount_point_name,
const base::FilePath& test_cache_root,
DriveFsMojoListenerFactory test_drivefs_mojo_listener_factory)
......@@ -552,7 +551,6 @@ DriveIntegrationService::DriveIntegrationService(
profile_,
this,
std::move(test_drivefs_mojo_listener_factory))),
preference_watcher_(preference_watcher),
power_manager_observer_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(profile && !profile->IsOffTheRecord());
......@@ -562,8 +560,11 @@ DriveIntegrationService::DriveIntegrationService(
{base::MayBlock(), base::TaskPriority::USER_BLOCKING,
base::WithBaseSyncPrimitives()});
if (preference_watcher_)
preference_watcher->set_integration_service(this);
if (util::IsDriveEnabledForProfile(profile)) {
preference_watcher_ =
std::make_unique<PreferenceWatcher>(profile->GetPrefs());
preference_watcher_->set_integration_service(this);
}
bool migrated_to_drivefs =
profile_->GetPrefs()->GetBoolean(prefs::kDriveFsPinnedMigrated);
......@@ -1162,15 +1163,8 @@ KeyedService* DriveIntegrationServiceFactory::BuildServiceInstanceFor(
DriveIntegrationService* service = nullptr;
if (!factory_for_test_) {
DriveIntegrationService::PreferenceWatcher* preference_watcher = nullptr;
if (util::IsDriveEnabledForProfile(profile)) {
// Drive File System can be enabled.
preference_watcher =
new DriveIntegrationService::PreferenceWatcher(profile->GetPrefs());
}
service = new DriveIntegrationService(profile, preference_watcher,
std::string(), base::FilePath());
service =
new DriveIntegrationService(profile, std::string(), base::FilePath());
} else {
service = factory_for_test_->Run(profile);
}
......
......@@ -100,15 +100,12 @@ class DriveIntegrationService : public KeyedService,
using GetQuickAccessItemsCallback =
base::OnceCallback<void(drive::FileError, std::vector<QuickAccessItem>)>;
// test_drive_service, test_mount_point_name, test_cache_root and
// test_file_system are used by tests to inject customized instances.
// test_mount_point_name, test_cache_root and
// test_drivefs_mojo_listener_factory are used by tests to inject customized
// instances.
// Pass NULL or the empty value when not interested.
// |preference_watcher| observes the drive enable preference, and sets the
// enable state when changed. It can be NULL. The ownership is taken by
// the DriveIntegrationService.
DriveIntegrationService(
Profile* profile,
PreferenceWatcher* preference_watcher,
const std::string& test_mount_point_name,
const base::FilePath& test_cache_root,
DriveFsMojoListenerFactory test_drivefs_mojo_listener_factory = {});
......
......@@ -517,7 +517,7 @@ class DriveFileSystemExtensionApiTest : public FileSystemExtensionApiTestBase {
fake_drivefs_helper_ = std::make_unique<drive::FakeDriveFsHelper>(
profile, drivefs_mount_point.DirName());
return new drive::DriveIntegrationService(
profile, nullptr, "", test_cache_root_.GetPath(),
profile, "", test_cache_root_.GetPath(),
fake_drivefs_helper_->CreateFakeDriveFsListenerFactory());
}
......@@ -615,7 +615,7 @@ class MultiProfileDriveFileSystemExtensionApiTest :
const auto& drivefs_helper = fake_drivefs_helpers_[profile] =
std::make_unique<drive::FakeDriveFsHelper>(profile, drivefs_dir);
return new drive::DriveIntegrationService(
profile, nullptr, std::string(), cache_dir,
profile, std::string(), cache_dir,
drivefs_helper->CreateFakeDriveFsListenerFactory());
}
......@@ -687,7 +687,7 @@ class LocalAndDriveFileSystemExtensionApiTest
fake_drivefs_helper_ = std::make_unique<drive::FakeDriveFsHelper>(
profile, drivefs_mount_point.DirName());
return new drive::DriveIntegrationService(
profile, nullptr, "", test_cache_root_.GetPath(),
profile, "", test_cache_root_.GetPath(),
fake_drivefs_helper_->CreateFakeDriveFsListenerFactory());
}
......
......@@ -1063,7 +1063,7 @@ class DriveFsTestVolume : public TestVolume {
EXPECT_FALSE(integration_service_);
integration_service_ = new drive::DriveIntegrationService(
profile, nullptr, std::string(), root_path().Append("v1"),
profile, std::string(), root_path().Append("v1"),
CreateDriveFsBootstrapListener());
return integration_service_;
......
......@@ -214,7 +214,6 @@ class VolumeManagerTest : public testing::Test {
drive_integration_service_(
std::make_unique<drive::DriveIntegrationService>(
profile_.get(),
nullptr,
std::string(),
base::FilePath())),
volume_manager_(std::make_unique<VolumeManager>(
......
......@@ -165,7 +165,7 @@ class FileSystemApiTestForDrive : public PlatformAppBrowserTest {
SetUpTestFileHierarchy();
integration_service_ = new drive::DriveIntegrationService(
profile, nullptr, "", test_cache_root_.GetPath(),
profile, "", test_cache_root_.GetPath(),
fake_drivefs_helper_->CreateFakeDriveFsListenerFactory());
return integration_service_;
}
......@@ -312,7 +312,7 @@ class FileSystemApiTestForRequestFileSystem : public PlatformAppBrowserTest {
profile, drivefs_root_.GetPath().Append("drive-user"));
return new drive::DriveIntegrationService(
profile, nullptr, "", {},
profile, "", {},
fake_drivefs_helper_->CreateFakeDriveFsListenerFactory());
}
......
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