From 89e9056fca60287437ac1164208a9b1b80556145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Degros?= Date: Mon, 19 Dec 2022 05:29:49 +0000 Subject: [PATCH] Use DriveIntegrationService::GetDriveFsHost() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Commit-Queue: François Degros Cr-Commit-Position: refs/heads/main@{#1084841} --- .../ash/drive/drive_integration_service.cc | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/chrome/browser/ash/drive/drive_integration_service.cc b/chrome/browser/ash/drive/drive_integration_service.cc index 0e5722c8ff2e8..6e6ac3b314eb6 100644 --- a/chrome/browser/ash/drive/drive_integration_service.cc +++ b/chrome/browser/ash/drive/drive_integration_service.cc @@ -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( @@ -866,7 +865,7 @@ DriveIntegrationService::GetDriveFsPinManager() { } drivefs::mojom::DriveFs* DriveIntegrationService::GetDriveFsInterface() const { - return drivefs_holder_->drivefs_host()->GetDriveFsInterface(); + return GetDriveFsHost()->GetDriveFsInterface(); } void DriveIntegrationService::AddBackDriveMountPoint( @@ -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); @@ -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 { @@ -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(); } } @@ -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(); } } @@ -1050,7 +1048,7 @@ void DriveIntegrationService::OnMounted(const base::FilePath& mount_path) { pin_manager_ = std::make_unique( profile_->GetPrefs()->GetBoolean(prefs::kDriveFsBulkPinningEnabled), profile_->GetPath(), GetDriveFsInterface()); - drivefs_holder_->drivefs_host()->AddObserver(pin_manager_.get()); + GetDriveFsHost()->AddObserver(pin_manager_.get()); } } @@ -1145,8 +1143,9 @@ void DriveIntegrationService::MigratePinnedFiles() { void DriveIntegrationService::PinFiles( const std::vector& 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()); @@ -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() {