Commit 291214df authored by Sergei Datsenko's avatar Sergei Datsenko Committed by Commit Bot

Ensure data directory for drivefs is created.

Bug: 1115963
Change-Id: I240b2132ee9285f9b2cc88478394b32c383744ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2355232
Commit-Queue: Sergei Datsenko <dats@chromium.org>
Reviewed-by: default avatarAustin Tankiang <austinct@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799140}
parent 38c016db
...@@ -289,6 +289,10 @@ DriveMountStatus ConvertMountFailure( ...@@ -289,6 +289,10 @@ DriveMountStatus ConvertMountFailure(
NOTREACHED(); NOTREACHED();
} }
bool EnsureDirectoryExists(const base::FilePath& path) {
return base::DirectoryExists(path) || base::CreateDirectory(path);
}
void UmaEmitMountStatus(DriveMountStatus status) { void UmaEmitMountStatus(DriveMountStatus status) {
UMA_HISTOGRAM_ENUMERATION("DriveCommon.Lifecycle.Mount", status); UMA_HISTOGRAM_ENUMERATION("DriveCommon.Lifecycle.Mount", status);
} }
...@@ -464,6 +468,9 @@ class DriveIntegrationService::DriveFsHolder ...@@ -464,6 +468,9 @@ class DriveIntegrationService::DriveFsHolder
} }
std::string GetObfuscatedAccountId() override { std::string GetObfuscatedAccountId() override {
if (!GetAccountId().HasAccountIdKey()) {
return "";
}
return base::MD5String(GetProfileSalt() + "-" + return base::MD5String(GetProfileSalt() + "-" +
GetAccountId().GetAccountIdKey()); GetAccountId().GetAccountIdKey());
} }
...@@ -790,12 +797,25 @@ void DriveIntegrationService::AddDriveMountPoint() { ...@@ -790,12 +797,25 @@ void DriveIntegrationService::AddDriveMountPoint() {
if (mount_start_.is_null() || was_ever_mounted) { if (mount_start_.is_null() || was_ever_mounted) {
mount_start_ = base::TimeTicks::Now(); mount_start_ = base::TimeTicks::Now();
} }
drivefs_holder_->drivefs_host()->Mount(); base::PostTaskAndReplyWithResult(
blocking_task_runner_.get(), FROM_HERE,
base::BindOnce(&EnsureDirectoryExists,
drivefs_holder_->drivefs_host()->GetDataPath()),
base::BindOnce(&DriveIntegrationService::MaybeMountDrive,
weak_ptr_factory_.GetWeakPtr()));
} else { } else {
AddDriveMountPointAfterMounted(); AddDriveMountPointAfterMounted();
} }
} }
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();
}
}
bool DriveIntegrationService::AddDriveMountPointAfterMounted() { bool DriveIntegrationService::AddDriveMountPointAfterMounted() {
const base::FilePath& drive_mount_point = GetMountPointPath(); const base::FilePath& drive_mount_point = GetMountPointPath();
if (mount_point_name_.empty()) { if (mount_point_name_.empty()) {
......
...@@ -219,6 +219,9 @@ class DriveIntegrationService : public KeyedService, ...@@ -219,6 +219,9 @@ class DriveIntegrationService : public KeyedService,
// complete before adding the mount point. // complete before adding the mount point.
void AddDriveMountPoint(); void AddDriveMountPoint();
// Mounts Drive if the directory exists.
void MaybeMountDrive(bool data_directory_exists);
// Registers remote file system for drive mount point. // Registers remote file system for drive mount point.
bool AddDriveMountPointAfterMounted(); bool AddDriveMountPointAfterMounted();
......
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