Commit a0c0018f authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Pass the lost and found directory name to DriveFS in the config struct.

Also, prepare to pass the myfiles directory as a mount option, but don't
actually send it yet - cros-disks isn't ready for it (and won't be until
after DriveFS runs as chronos) so would log the unsupported mount
option.

Bug: 928157
Change-Id: I2d38df787fb12b0a50a063aa445dc6c7d2e23597
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1623617Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Sam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662091}
parent 742fbc53
...@@ -591,6 +591,15 @@ class DriveIntegrationService::DriveFsHolder ...@@ -591,6 +591,15 @@ class DriveIntegrationService::DriveFsHolder
return Delegate::CreateMojoListener(); return Delegate::CreateMojoListener();
} }
base::FilePath GetMyFilesPath() override {
return file_manager::util::GetMyFilesFolderForProfile(profile_);
}
std::string GetLostAndFoundDirectoryName() override {
return l10n_util::GetStringUTF8(
IDS_FILE_BROWSER_RECOVERED_FILES_FROM_GOOGLE_DRIVE_DIRECTORY_NAME);
}
Profile* const profile_; Profile* const profile_;
drivefs::DriveFsHost::MountObserver* const mount_observer_; drivefs::DriveFsHost::MountObserver* const mount_observer_;
......
...@@ -47,6 +47,7 @@ class DriveFsHost::MountState : public DriveFsSession, ...@@ -47,6 +47,7 @@ class DriveFsHost::MountState : public DriveFsSession,
CreateMojoConnection(host->account_token_delegate_.get(), CreateMojoConnection(host->account_token_delegate_.get(),
host->delegate_), host->delegate_),
host->GetDataPath(), host->GetDataPath(),
host->delegate_->GetMyFilesPath(),
host->GetDefaultMountDirName(), host->GetDefaultMountDirName(),
host->mount_observer_), host->mount_observer_),
host_(host) { host_(host) {
...@@ -72,7 +73,8 @@ class DriveFsHost::MountState : public DriveFsSession, ...@@ -72,7 +73,8 @@ class DriveFsHost::MountState : public DriveFsSession,
auto access_token = auth_delegate->GetCachedAccessToken(); auto access_token = auth_delegate->GetCachedAccessToken();
mojom::DriveFsConfigurationPtr config = { mojom::DriveFsConfigurationPtr config = {
base::in_place, auth_delegate->GetAccountId().GetUserEmail(), base::in_place, auth_delegate->GetAccountId().GetUserEmail(),
std::move(access_token), auth_delegate->IsMetricsCollectionEnabled()}; std::move(access_token), auth_delegate->IsMetricsCollectionEnabled(),
delegate->GetLostAndFoundDirectoryName()};
return DriveFsConnection::Create(delegate->CreateMojoListener(), return DriveFsConnection::Create(delegate->CreateMojoListener(),
std::move(config)); std::move(config));
} }
......
...@@ -54,6 +54,8 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsHost { ...@@ -54,6 +54,8 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsHost {
virtual drive::DriveNotificationManager& GetDriveNotificationManager() = 0; virtual drive::DriveNotificationManager& GetDriveNotificationManager() = 0;
virtual std::unique_ptr<DriveFsBootstrapListener> CreateMojoListener(); virtual std::unique_ptr<DriveFsBootstrapListener> CreateMojoListener();
virtual base::FilePath GetMyFilesPath() = 0;
virtual std::string GetLostAndFoundDirectoryName() = 0;
private: private:
DISALLOW_COPY_AND_ASSIGN(Delegate); DISALLOW_COPY_AND_ASSIGN(Delegate);
......
...@@ -141,6 +141,14 @@ class TestingDriveFsHostDelegate : public DriveFsHost::Delegate, ...@@ -141,6 +141,14 @@ class TestingDriveFsHostDelegate : public DriveFsHost::Delegate,
std::move(pending_bootstrap_)); std::move(pending_bootstrap_));
} }
std::string GetLostAndFoundDirectoryName() override {
return "recovered files";
}
base::FilePath GetMyFilesPath() override {
return base::FilePath("/MyFiles");
}
const std::unique_ptr<service_manager::Connector> connector_; const std::unique_ptr<service_manager::Connector> connector_;
const AccountId account_id_; const AccountId account_id_;
mojom::DriveFsBootstrapPtrInfo pending_bootstrap_; mojom::DriveFsBootstrapPtrInfo pending_bootstrap_;
...@@ -401,6 +409,8 @@ class DriveFsHostTest : public ::testing::Test, public mojom::DriveFsBootstrap { ...@@ -401,6 +409,8 @@ class DriveFsHostTest : public ::testing::Test, public mojom::DriveFsBootstrap {
mojom::DriveFsRequest drive_fs_request, mojom::DriveFsRequest drive_fs_request,
mojom::DriveFsDelegatePtr delegate) override { mojom::DriveFsDelegatePtr delegate) override {
EXPECT_EQ("test@example.com", config->user_email); EXPECT_EQ("test@example.com", config->user_email);
EXPECT_EQ("recovered files",
config->lost_and_found_directory_name.value_or("<None>"));
init_access_token_ = std::move(config->access_token); init_access_token_ = std::move(config->access_token);
binding_.Bind(std::move(drive_fs_request)); binding_.Bind(std::move(drive_fs_request));
mojo::FuseInterface(std::move(pending_delegate_request_), mojo::FuseInterface(std::move(pending_delegate_request_),
......
...@@ -34,6 +34,7 @@ class DiskMounterImpl : public DiskMounter, ...@@ -34,6 +34,7 @@ class DiskMounterImpl : public DiskMounter,
void Mount(const base::UnguessableToken& token, void Mount(const base::UnguessableToken& token,
const base::FilePath& data_path, const base::FilePath& data_path,
const base::FilePath& my_files_path,
const std::string& desired_mount_dir_name, const std::string& desired_mount_dir_name,
base::OnceCallback<void(base::FilePath)> callback) override { base::OnceCallback<void(base::FilePath)> callback) override {
DCHECK(mount_path_.empty()); DCHECK(mount_path_.empty());
...@@ -100,6 +101,7 @@ DriveFsSession::DriveFsSession(base::OneShotTimer* timer, ...@@ -100,6 +101,7 @@ DriveFsSession::DriveFsSession(base::OneShotTimer* timer,
std::unique_ptr<DiskMounter> disk_mounter, std::unique_ptr<DiskMounter> disk_mounter,
std::unique_ptr<DriveFsConnection> connection, std::unique_ptr<DriveFsConnection> connection,
const base::FilePath& data_path, const base::FilePath& data_path,
const base::FilePath& my_files_path,
const std::string& desired_mount_dir_name, const std::string& desired_mount_dir_name,
MountObserver* observer) MountObserver* observer)
: timer_(timer), : timer_(timer),
...@@ -111,7 +113,7 @@ DriveFsSession::DriveFsSession(base::OneShotTimer* timer, ...@@ -111,7 +113,7 @@ DriveFsSession::DriveFsSession(base::OneShotTimer* timer,
base::Unretained(this))); base::Unretained(this)));
CHECK(token); CHECK(token);
drivefs_ = &connection_->GetDriveFs(); drivefs_ = &connection_->GetDriveFs();
disk_mounter_->Mount(token, data_path, desired_mount_dir_name, disk_mounter_->Mount(token, data_path, my_files_path, desired_mount_dir_name,
base::BindOnce(&DriveFsSession::OnDiskMountCompleted, base::BindOnce(&DriveFsSession::OnDiskMountCompleted,
base::Unretained(this))); base::Unretained(this)));
timer_->Start( timer_->Start(
......
...@@ -26,6 +26,7 @@ class COMPONENT_EXPORT(DRIVEFS) DiskMounter { ...@@ -26,6 +26,7 @@ class COMPONENT_EXPORT(DRIVEFS) DiskMounter {
virtual ~DiskMounter() = default; virtual ~DiskMounter() = default;
virtual void Mount(const base::UnguessableToken& token, virtual void Mount(const base::UnguessableToken& token,
const base::FilePath& data_path, const base::FilePath& data_path,
const base::FilePath& my_files_path,
const std::string& desired_mount_dir_name, const std::string& desired_mount_dir_name,
base::OnceCallback<void(base::FilePath)> callback) = 0; base::OnceCallback<void(base::FilePath)> callback) = 0;
...@@ -68,6 +69,7 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsSession : public mojom::DriveFsDelegate { ...@@ -68,6 +69,7 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsSession : public mojom::DriveFsDelegate {
std::unique_ptr<DiskMounter> disk_mounter, std::unique_ptr<DiskMounter> disk_mounter,
std::unique_ptr<DriveFsConnection> connection, std::unique_ptr<DriveFsConnection> connection,
const base::FilePath& data_path, const base::FilePath& data_path,
const base::FilePath& my_files_path,
const std::string& desired_mount_dir_name, const std::string& desired_mount_dir_name,
MountObserver* observer); MountObserver* observer);
~DriveFsSession() override; ~DriveFsSession() override;
......
...@@ -24,6 +24,7 @@ namespace { ...@@ -24,6 +24,7 @@ namespace {
constexpr char kExpectedMountDir[] = "drivefs-salt-g-ID"; constexpr char kExpectedMountDir[] = "drivefs-salt-g-ID";
constexpr char kExpectedMountPath[] = "/media/drivefsroot/mountdir"; constexpr char kExpectedMountPath[] = "/media/drivefsroot/mountdir";
constexpr char kExpectedDataDir[] = "/path/to/profile/GCache/v2/salt-g-ID"; constexpr char kExpectedDataDir[] = "/path/to/profile/GCache/v2/salt-g-ID";
constexpr char kExpectedMyFilesDir[] = "/path/to/profile/MyFiles";
static const base::Optional<base::TimeDelta> kEmptyDelay; static const base::Optional<base::TimeDelta> kEmptyDelay;
static const base::Optional<base::TimeDelta> kDefaultDelay = static const base::Optional<base::TimeDelta> kDefaultDelay =
...@@ -43,11 +44,15 @@ class DriveFsDiskMounterTest : public testing::Test { ...@@ -43,11 +44,15 @@ class DriveFsDiskMounterTest : public testing::Test {
disk_manager_, disk_manager_,
MountPath( MountPath(
testing::StartsWith("drivefs://"), "", kExpectedMountDir, testing::StartsWith("drivefs://"), "", kExpectedMountDir,
testing::Contains("datadir=/path/to/profile/GCache/v2/salt-g-ID"), testing::AllOf(testing::Contains(
"datadir=/path/to/profile/GCache/v2/salt-g-ID"),
testing::Not(testing::Contains(
"myfiles=/path/to/profile/MyFiles"))),
_, chromeos::MOUNT_ACCESS_MODE_READ_WRITE)) _, chromeos::MOUNT_ACCESS_MODE_READ_WRITE))
.WillOnce(testing::SaveArg<0>(&source)); .WillOnce(testing::SaveArg<0>(&source));
mounter->Mount(token, base::FilePath(kExpectedDataDir), kExpectedMountDir, mounter->Mount(token, base::FilePath(kExpectedDataDir),
base::FilePath(kExpectedMyFilesDir), kExpectedMountDir,
base::BindOnce(&DriveFsDiskMounterTest::OnCompleted, base::BindOnce(&DriveFsDiskMounterTest::OnCompleted,
base::Unretained(this))); base::Unretained(this)));
testing::Mock::VerifyAndClear(&disk_manager_); testing::Mock::VerifyAndClear(&disk_manager_);
...@@ -168,6 +173,7 @@ class MockDiskMounter : public DiskMounter { ...@@ -168,6 +173,7 @@ class MockDiskMounter : public DiskMounter {
void Mount(const base::UnguessableToken& token, void Mount(const base::UnguessableToken& token,
const base::FilePath& data_path, const base::FilePath& data_path,
const base::FilePath& my_files_path,
const std::string& desired_mount_dir_name, const std::string& desired_mount_dir_name,
base::OnceCallback<void(base::FilePath)> callback) override { base::OnceCallback<void(base::FilePath)> callback) override {
callback_ = std::move(callback); callback_ = std::move(callback);
...@@ -237,12 +243,14 @@ class DriveFsSessionForTest : public DriveFsSession { ...@@ -237,12 +243,14 @@ class DriveFsSessionForTest : public DriveFsSession {
std::unique_ptr<DiskMounter> disk_mounter, std::unique_ptr<DiskMounter> disk_mounter,
std::unique_ptr<DriveFsConnection> connection, std::unique_ptr<DriveFsConnection> connection,
const base::FilePath& data_path, const base::FilePath& data_path,
const base::FilePath& my_files_path,
const std::string& desired_mount_dir_name, const std::string& desired_mount_dir_name,
MountObserver* observer) MountObserver* observer)
: DriveFsSession(timer, : DriveFsSession(timer,
std::move(disk_mounter), std::move(disk_mounter),
std::move(connection), std::move(connection),
data_path, data_path,
my_files_path,
desired_mount_dir_name, desired_mount_dir_name,
observer) {} observer) {}
~DriveFsSessionForTest() override = default; ~DriveFsSessionForTest() override = default;
...@@ -291,7 +299,7 @@ class DriveFsSessionTest : public ::testing::Test, ...@@ -291,7 +299,7 @@ class DriveFsSessionTest : public ::testing::Test,
OnMountCalled(_, data_path, kExpectedMountDir)); OnMountCalled(_, data_path, kExpectedMountDir));
session_ = std::make_unique<DriveFsSessionForTest>( session_ = std::make_unique<DriveFsSessionForTest>(
&timer_, std::move(mounter), std::move(connection), data_path, &timer_, std::move(mounter), std::move(connection), data_path,
kExpectedMountDir, this); base::FilePath(kExpectedMyFilesDir), kExpectedMountDir, this);
holder_->delegate = session_.get(); holder_->delegate = session_.get();
ASSERT_FALSE(session_->is_mounted()); ASSERT_FALSE(session_->is_mounted());
} }
......
...@@ -100,7 +100,7 @@ interface DriveFsDelegate { ...@@ -100,7 +100,7 @@ interface DriveFsDelegate {
OnHeartbeat(); OnHeartbeat();
}; };
// Next MinVersion: 3 // Next MinVersion: 4
struct DriveFsConfiguration { struct DriveFsConfiguration {
string user_email; string user_email;
...@@ -109,6 +109,11 @@ struct DriveFsConfiguration { ...@@ -109,6 +109,11 @@ struct DriveFsConfiguration {
[MinVersion=2] [MinVersion=2]
bool enable_metrics = false; bool enable_metrics = false;
// The directory name to use for lost and found within the user's My files
// directory.
[MinVersion=3]
string? lost_and_found_directory_name;
}; };
enum AccessTokenStatus { enum AccessTokenStatus {
......
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