Skip to content

Commit

Permalink
clang-format drive_integration_service.cc
Browse files Browse the repository at this point in the history
To avoid further diffs because of clang-format.

BUG=b:262647301

Change-Id: Iaba310d48c6fa0939765356eba93a9aa34e97cff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4112969
Reviewed-by: Ben Reich <benreich@chromium.org>
Commit-Queue: François Degros <fdegros@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1084848}
  • Loading branch information
fdegros authored and Chromium LUCI CQ committed Dec 19, 2022
1 parent f6e778d commit 1d5e01b
Showing 1 changed file with 36 additions and 24 deletions.
60 changes: 36 additions & 24 deletions chrome/browser/ash/drive/drive_integration_service.cc
Expand Up @@ -93,9 +93,9 @@ const base::FilePath::CharType kTemporaryFileDirectory[] =

void DeleteDirectoryContents(const base::FilePath& dir) {
base::FileEnumerator content_enumerator(
dir, false, base::FileEnumerator::FILES |
base::FileEnumerator::DIRECTORIES |
base::FileEnumerator::SHOW_SYM_LINKS);
dir, false,
base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES |
base::FileEnumerator::SHOW_SYM_LINKS);
for (base::FilePath path = content_enumerator.Next(); !path.empty();
path = content_enumerator.Next()) {
base::DeletePathRecursively(path);
Expand Down Expand Up @@ -126,8 +126,9 @@ FileError InitializeMetadata(
const base::FilePath& downloads_directory) {
if (!base::DirectoryExists(
cache_root_directory.Append(kTemporaryFileDirectory))) {
if (base::SysInfo::IsRunningOnChromeOS())
if (base::SysInfo::IsRunningOnChromeOS()) {
LOG(ERROR) << "/tmp should have been created as clear.";
}
// Create /tmp directory as encrypted. Cryptohome will re-create /tmp
// direcotry at the next login.
if (!base::CreateDirectory(
Expand All @@ -141,10 +142,9 @@ FileError InitializeMetadata(
// be deleted because it's created by cryptohome in clear and shouldn't be
// re-created as encrypted.
DeleteDirectoryContents(cache_root_directory.Append(kTemporaryFileDirectory));
if (!base::CreateDirectory(cache_root_directory.Append(
kMetadataDirectory)) ||
!base::CreateDirectory(cache_root_directory.Append(
kCacheFileDirectory))) {
if (!base::CreateDirectory(cache_root_directory.Append(kMetadataDirectory)) ||
!base::CreateDirectory(
cache_root_directory.Append(kCacheFileDirectory))) {
LOG(WARNING) << "Failed to create directories.";
return FILE_ERROR_FAILED;
}
Expand All @@ -153,9 +153,8 @@ FileError InitializeMetadata(
// allow archive files in that directory to be mounted by cros-disks.
base::SetPosixFilePermissions(
cache_root_directory.Append(kCacheFileDirectory),
base::FILE_PERMISSION_USER_MASK |
base::FILE_PERMISSION_EXECUTE_BY_GROUP |
base::FILE_PERMISSION_EXECUTE_BY_OTHERS);
base::FILE_PERMISSION_USER_MASK | base::FILE_PERMISSION_EXECUTE_BY_GROUP |
base::FILE_PERMISSION_EXECUTE_BY_OTHERS);

// If attempting to migrate to DriveFS without previous Drive sync data
// present, skip the migration.
Expand Down Expand Up @@ -467,8 +466,9 @@ class DriveIntegrationService::PreferenceWatcher
}

void AddNetworkPortalDetectorObserver() {
if (!ash::NetworkHandler::IsInitialized())
if (!ash::NetworkHandler::IsInitialized()) {
return; // Test environment.
}
ash::NetworkStateHandler* handler =
ash::NetworkHandler::Get()->network_state_handler();
handler->AddObserver(this);
Expand Down Expand Up @@ -499,8 +499,9 @@ class DriveIntegrationService::PreferenceWatcher

// network::NetworkConnectionTracker::NetworkConnectionObserver
void OnConnectionChanged(network::mojom::ConnectionType type) override {
if (!integration_service_->GetDriveFsInterface())
if (!integration_service_->GetDriveFsInterface()) {
return;
}

integration_service_->GetDriveFsInterface()->UpdateNetworkState(
network::NetworkConnectionTracker::IsConnectionCellular(type) &&
Expand Down Expand Up @@ -603,8 +604,9 @@ class DriveIntegrationService::DriveFsHolder

std::unique_ptr<drivefs::DriveFsBootstrapListener> CreateMojoListener()
override {
if (test_drivefs_mojo_listener_factory_)
if (test_drivefs_mojo_listener_factory_) {
return test_drivefs_mojo_listener_factory_.Run();
}
return Delegate::CreateMojoListener();
}

Expand Down Expand Up @@ -709,21 +711,24 @@ void DriveIntegrationService::Shutdown() {

RemoveDriveMountPoint();

for (auto& observer : observers_)
for (auto& observer : observers_) {
observer.OnDriveIntegrationServiceDestroyed();
}
}

void DriveIntegrationService::SetEnabled(bool enabled) {
// If Drive is being disabled, ensure the download destination preference to
// be out of Drive. Do this before "Do nothing if not changed." because we
// want to run the check for the first SetEnabled() called in the constructor,
// which may be a change from false to false.
if (!enabled)
if (!enabled) {
AvoidDriveAsDownloadDirectoryPreference();
}

// Do nothing if not changed.
if (enabled_ == enabled)
if (enabled_ == enabled) {
return;
}

if (enabled) {
enabled_ = true;
Expand Down Expand Up @@ -757,8 +762,9 @@ void DriveIntegrationService::SetEnabled(bool enabled) {
}

bool DriveIntegrationService::IsMounted() const {
if (mount_point_name_.empty())
if (mount_point_name_.empty()) {
return false;
}

// Look up the registered path, and just discard it.
// GetRegisteredPath() returns true if the path is available.
Expand Down Expand Up @@ -934,8 +940,9 @@ bool DriveIntegrationService::AddDriveMountPointAfterMounted() {

if (success) {
logger_->Log(logging::LOG_INFO, "Drive mount point is added");
for (auto& observer : observers_)
for (auto& observer : observers_) {
observer.OnFileSystemMounted();
}
}

if (preference_watcher_) {
Expand Down Expand Up @@ -995,16 +1002,18 @@ void DriveIntegrationService::MaybeRemountFileSystem(
mount_failed_ = true;
logger_->Log(logging::LOG_ERROR,
"DriveFs is too crashy. Leaving it alone.");
for (auto& observer : observers_)
for (auto& observer : observers_) {
observer.OnFileSystemMountFailed();
}
return;
}
if (drivefs_consecutive_failures_count_ > 3) {
mount_failed_ = true;
logger_->Log(logging::LOG_ERROR,
"DriveFs keeps failing at start. Giving up.");
for (auto& observer : observers_)
for (auto& observer : observers_) {
observer.OnFileSystemMountFailed();
}
return;
}
remount_delay =
Expand Down Expand Up @@ -1107,8 +1116,9 @@ void DriveIntegrationService::InitializeAfterMetadataInitialized(
std::vector<std::pair<base::FilePath, std::string>>()));
}
state_ = INITIALIZED;
if (enabled_)
if (enabled_) {
AddDriveMountPoint();
}
}

void DriveIntegrationService::AvoidDriveAsDownloadDirectoryPreference() {
Expand All @@ -1128,8 +1138,9 @@ bool DriveIntegrationService::DownloadDirectoryPreferenceIsInDrive() {
}

void DriveIntegrationService::MigratePinnedFiles() {
if (!metadata_storage_)
if (!metadata_storage_) {
return;
}

blocking_task_runner_->PostTaskAndReplyWithResult(
FROM_HERE,
Expand Down Expand Up @@ -1508,8 +1519,9 @@ DriveIntegrationService* DriveIntegrationServiceFactory::GetForProfile(
// static
DriveIntegrationService* DriveIntegrationServiceFactory::FindForProfile(
Profile* profile) {
if (!profile) // crbug.com/1254581
if (!profile) { // crbug.com/1254581
return nullptr;
}
return static_cast<DriveIntegrationService*>(
GetInstance()->GetServiceForBrowserContext(profile, false));
}
Expand Down

0 comments on commit 1d5e01b

Please sign in to comment.