Skip to content

Commit

Permalink
Use DriveIntegrationService::GetDriveFsHost()
Browse files Browse the repository at this point in the history
Where it makes sense, to keep the code short.

No functional change.

BUG=b:262647301

Change-Id: I4d2700ad6e86484b386befd85b2754f8286766d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4112124
Reviewed-by: Alex Danilo <adanilo@chromium.org>
Commit-Queue: François Degros <fdegros@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1084841}
  • Loading branch information
fdegros authored and Chromium LUCI CQ committed Dec 19, 2022
1 parent 6a1e41a commit 89e9056
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions chrome/browser/ash/drive/drive_integration_service.cc
Expand Up @@ -770,12 +770,11 @@ bool DriveIntegrationService::IsMounted() const {
}

base::FilePath DriveIntegrationService::GetMountPointPath() const {
return drivefs_holder_->drivefs_host()->GetMountPath();
return GetDriveFsHost()->GetMountPath();
}

base::FilePath DriveIntegrationService::GetDriveFsLogPath() const {
return drivefs_holder_->drivefs_host()->GetDataPath().Append(
"Logs/drivefs.txt");
return GetDriveFsHost()->GetDataPath().Append("Logs/drivefs.txt");
}

bool DriveIntegrationService::GetRelativeDrivePath(
Expand Down Expand Up @@ -866,7 +865,7 @@ DriveIntegrationService::GetDriveFsPinManager() {
}

drivefs::mojom::DriveFs* DriveIntegrationService::GetDriveFsInterface() const {
return drivefs_holder_->drivefs_host()->GetDriveFsInterface();
return GetDriveFsHost()->GetDriveFsInterface();
}

void DriveIntegrationService::AddBackDriveMountPoint(
Expand Down Expand Up @@ -894,7 +893,7 @@ void DriveIntegrationService::AddDriveMountPoint() {

weak_ptr_factory_.InvalidateWeakPtrs();

if (!drivefs_holder_->drivefs_host()->IsMounted()) {
if (!GetDriveFsHost()->IsMounted()) {
PrefService* prefs = profile_->GetPrefs();
bool was_ever_mounted =
prefs->GetBoolean(prefs::kDriveFsWasLaunchedAtLeastOnce);
Expand All @@ -903,8 +902,7 @@ void DriveIntegrationService::AddDriveMountPoint() {
}
blocking_task_runner_->PostTaskAndReplyWithResult(
FROM_HERE,
base::BindOnce(&EnsureDirectoryExists,
drivefs_holder_->drivefs_host()->GetDataPath()),
base::BindOnce(&EnsureDirectoryExists, GetDriveFsHost()->GetDataPath()),
base::BindOnce(&DriveIntegrationService::MaybeMountDrive,
weak_ptr_factory_.GetWeakPtr()));
} else {
Expand All @@ -916,7 +914,7 @@ void DriveIntegrationService::MaybeMountDrive(bool data_directory_exists) {
if (!data_directory_exists) {
LOG(ERROR) << "Could not create DriveFS data directory";
} else {
drivefs_holder_->drivefs_host()->Mount();
GetDriveFsHost()->Mount();
}
}

Expand Down Expand Up @@ -965,11 +963,11 @@ void DriveIntegrationService::RemoveDriveMountPoint() {
logger_->Log(logging::LOG_INFO, "Drive mount point is removed");
}
}
drivefs_holder_->drivefs_host()->Unmount();
GetDriveFsHost()->Unmount();

if (ash::features::IsDriveFsBulkPinningEnabled() && pin_manager_) {
pin_manager_->Stop();
drivefs_holder_->drivefs_host()->RemoveObserver(pin_manager_.get());
GetDriveFsHost()->RemoveObserver(pin_manager_.get());
pin_manager_.reset();
}
}
Expand Down Expand Up @@ -1050,7 +1048,7 @@ void DriveIntegrationService::OnMounted(const base::FilePath& mount_path) {
pin_manager_ = std::make_unique<drivefs::pinning::DriveFsPinManager>(
profile_->GetPrefs()->GetBoolean(prefs::kDriveFsBulkPinningEnabled),
profile_->GetPath(), GetDriveFsInterface());
drivefs_holder_->drivefs_host()->AddObserver(pin_manager_.get());
GetDriveFsHost()->AddObserver(pin_manager_.get());
}
}

Expand Down Expand Up @@ -1145,8 +1143,9 @@ void DriveIntegrationService::MigratePinnedFiles() {

void DriveIntegrationService::PinFiles(
const std::vector<base::FilePath>& files_to_pin) {
if (!drivefs_holder_->drivefs_host()->IsMounted())
if (!GetDriveFsHost()->IsMounted()) {
return;
}

for (const auto& path : files_to_pin) {
GetDriveFsInterface()->SetPinned(path, true, base::DoNothing());
Expand Down Expand Up @@ -1444,7 +1443,7 @@ void DriveIntegrationService::GetSyncingPaths(

drivefs::SyncStatusAndProgress DriveIntegrationService::GetSyncStatusForPath(
const base::FilePath& drive_path) {
return drivefs_holder_->drivefs_host()->GetSyncStatusForPath(drive_path);
return GetDriveFsHost()->GetSyncStatusForPath(drive_path);
}

void DriveIntegrationService::PollHostedFilePinStates() {
Expand Down

0 comments on commit 89e9056

Please sign in to comment.