Commit eeff20ab authored by Austin Tankiang's avatar Austin Tankiang Committed by Commit Bot

Add pref to control verbose logging in DriveFS

Bug: 1049071
Change-Id: I4156e737f1cd760d783f086be2d058609a50b4fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2208327Reviewed-by: default avatarStuart Langley <slangley@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarSergei Datsenko <dats@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774989}
parent 2f31b6ff
...@@ -518,6 +518,11 @@ class DriveIntegrationService::DriveFsHolder ...@@ -518,6 +518,11 @@ class DriveIntegrationService::DriveFsHolder
IDS_FILE_BROWSER_RECOVERED_FILES_FROM_GOOGLE_DRIVE_DIRECTORY_NAME); IDS_FILE_BROWSER_RECOVERED_FILES_FROM_GOOGLE_DRIVE_DIRECTORY_NAME);
} }
bool IsVerboseLoggingEnabled() override {
return profile_->GetPrefs()->GetBoolean(
prefs::kDriveFsEnableVerboseLogging);
}
Profile* const profile_; Profile* const profile_;
drivefs::DriveFsHost::MountObserver* const mount_observer_; drivefs::DriveFsHost::MountObserver* const mount_observer_;
......
...@@ -266,6 +266,8 @@ void Preferences::RegisterProfilePrefs( ...@@ -266,6 +266,8 @@ void Preferences::RegisterProfilePrefs(
false); false);
registry->RegisterStringPref(drive::prefs::kDriveFsProfileSalt, ""); registry->RegisterStringPref(drive::prefs::kDriveFsProfileSalt, "");
registry->RegisterBooleanPref(drive::prefs::kDriveFsPinnedMigrated, false); registry->RegisterBooleanPref(drive::prefs::kDriveFsPinnedMigrated, false);
registry->RegisterBooleanPref(drive::prefs::kDriveFsEnableVerboseLogging,
false);
// We don't sync ::prefs::kLanguageCurrentInputMethod and PreviousInputMethod // We don't sync ::prefs::kLanguageCurrentInputMethod and PreviousInputMethod
// because they're just used to track the logout state of the device. // because they're just used to track the logout state of the device.
registry->RegisterStringPref(::prefs::kLanguageCurrentInputMethod, ""); registry->RegisterStringPref(::prefs::kLanguageCurrentInputMethod, "");
......
...@@ -78,7 +78,8 @@ class DriveFsHost::MountState : public DriveFsSession, ...@@ -78,7 +78,8 @@ class DriveFsHost::MountState : public DriveFsSession,
std::move(access_token), std::move(access_token),
auth_delegate->IsMetricsCollectionEnabled(), auth_delegate->IsMetricsCollectionEnabled(),
delegate->GetLostAndFoundDirectoryName(), delegate->GetLostAndFoundDirectoryName(),
base::FeatureList::IsEnabled(chromeos::features::kDriveFsMirroring)}; base::FeatureList::IsEnabled(chromeos::features::kDriveFsMirroring),
delegate->IsVerboseLoggingEnabled()};
return DriveFsConnection::Create(delegate->CreateMojoListener(), return DriveFsConnection::Create(delegate->CreateMojoListener(),
std::move(config)); std::move(config));
} }
......
...@@ -57,6 +57,7 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsHost { ...@@ -57,6 +57,7 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsHost {
virtual std::unique_ptr<DriveFsBootstrapListener> CreateMojoListener(); virtual std::unique_ptr<DriveFsBootstrapListener> CreateMojoListener();
virtual base::FilePath GetMyFilesPath() = 0; virtual base::FilePath GetMyFilesPath() = 0;
virtual std::string GetLostAndFoundDirectoryName() = 0; virtual std::string GetLostAndFoundDirectoryName() = 0;
virtual bool IsVerboseLoggingEnabled() = 0;
private: private:
DISALLOW_COPY_AND_ASSIGN(Delegate); DISALLOW_COPY_AND_ASSIGN(Delegate);
......
...@@ -114,6 +114,10 @@ class TestingDriveFsHostDelegate : public DriveFsHost::Delegate, ...@@ -114,6 +114,10 @@ class TestingDriveFsHostDelegate : public DriveFsHost::Delegate,
pending_bootstrap_ = std::move(pending_bootstrap); pending_bootstrap_ = std::move(pending_bootstrap);
} }
void set_verbose_logging_enabled(bool enabled) {
verbose_logging_enabled_ = enabled;
}
// DriveFsHost::MountObserver: // DriveFsHost::MountObserver:
MOCK_METHOD1(OnMounted, void(const base::FilePath&)); MOCK_METHOD1(OnMounted, void(const base::FilePath&));
MOCK_METHOD2(OnMountFailed, MOCK_METHOD2(OnMountFailed,
...@@ -153,9 +157,12 @@ class TestingDriveFsHostDelegate : public DriveFsHost::Delegate, ...@@ -153,9 +157,12 @@ class TestingDriveFsHostDelegate : public DriveFsHost::Delegate,
return base::FilePath("/MyFiles"); return base::FilePath("/MyFiles");
} }
bool IsVerboseLoggingEnabled() override { return verbose_logging_enabled_; }
signin::IdentityManager* const identity_manager_; signin::IdentityManager* const identity_manager_;
const AccountId account_id_; const AccountId account_id_;
mojo::PendingRemote<mojom::DriveFsBootstrap> pending_bootstrap_; mojo::PendingRemote<mojom::DriveFsBootstrap> pending_bootstrap_;
bool verbose_logging_enabled_ = false;
invalidation::FakeInvalidationService invalidation_service_; invalidation::FakeInvalidationService invalidation_service_;
drive::DriveNotificationManager drive_notification_manager_; drive::DriveNotificationManager drive_notification_manager_;
...@@ -295,6 +302,7 @@ class DriveFsHostTest : public ::testing::Test, public mojom::DriveFsBootstrap { ...@@ -295,6 +302,7 @@ class DriveFsHostTest : public ::testing::Test, public mojom::DriveFsBootstrap {
EXPECT_EQ("test@example.com", config->user_email); EXPECT_EQ("test@example.com", config->user_email);
EXPECT_EQ("recovered files", EXPECT_EQ("recovered files",
config->lost_and_found_directory_name.value_or("<None>")); config->lost_and_found_directory_name.value_or("<None>"));
verbose_logging_enabled_ = config->enable_verbose_logging;
init_access_token_ = std::move(config->access_token); init_access_token_ = std::move(config->access_token);
receiver_.Bind(std::move(drive_fs_receiver)); receiver_.Bind(std::move(drive_fs_receiver));
mojo::FusePipes(std::move(pending_delegate_receiver_), std::move(delegate)); mojo::FusePipes(std::move(pending_delegate_receiver_), std::move(delegate));
...@@ -311,6 +319,7 @@ class DriveFsHostTest : public ::testing::Test, public mojom::DriveFsBootstrap { ...@@ -311,6 +319,7 @@ class DriveFsHostTest : public ::testing::Test, public mojom::DriveFsBootstrap {
std::unique_ptr<TestingDriveFsHostDelegate> host_delegate_; std::unique_ptr<TestingDriveFsHostDelegate> host_delegate_;
std::unique_ptr<DriveFsHost> host_; std::unique_ptr<DriveFsHost> host_;
base::MockOneShotTimer* timer_; base::MockOneShotTimer* timer_;
base::Optional<bool> verbose_logging_enabled_;
mojo::Receiver<mojom::DriveFsBootstrap> bootstrap_receiver_{this}; mojo::Receiver<mojom::DriveFsBootstrap> bootstrap_receiver_{this};
MockDriveFs mock_drivefs_; MockDriveFs mock_drivefs_;
...@@ -336,6 +345,8 @@ TEST_F(DriveFsHostTest, Basic) { ...@@ -336,6 +345,8 @@ TEST_F(DriveFsHostTest, Basic) {
ASSERT_NO_FATAL_FAILURE(DoMount()); ASSERT_NO_FATAL_FAILURE(DoMount());
EXPECT_FALSE(init_access_token_); EXPECT_FALSE(init_access_token_);
ASSERT_TRUE(verbose_logging_enabled_);
EXPECT_FALSE(verbose_logging_enabled_.value());
EXPECT_EQ(base::FilePath("/media/drivefsroot/salt-g-ID"), EXPECT_EQ(base::FilePath("/media/drivefsroot/salt-g-ID"),
host_->GetMountPath()); host_->GetMountPath());
...@@ -348,6 +359,15 @@ TEST_F(DriveFsHostTest, Basic) { ...@@ -348,6 +359,15 @@ TEST_F(DriveFsHostTest, Basic) {
run_loop.Run(); run_loop.Run();
} }
TEST_F(DriveFsHostTest, EnableVerboseLogging) {
ASSERT_FALSE(host_->IsMounted());
host_delegate_->set_verbose_logging_enabled(true);
ASSERT_NO_FATAL_FAILURE(DoMount());
ASSERT_TRUE(verbose_logging_enabled_);
EXPECT_TRUE(verbose_logging_enabled_.value());
}
TEST_F(DriveFsHostTest, GetMountPathWhileUnmounted) { TEST_F(DriveFsHostTest, GetMountPathWhileUnmounted) {
EXPECT_EQ(base::FilePath("/media/fuse/drivefs-salt-g-ID"), EXPECT_EQ(base::FilePath("/media/fuse/drivefs-salt-g-ID"),
host_->GetMountPath()); host_->GetMountPath());
......
...@@ -111,7 +111,7 @@ interface DriveFsDelegate { ...@@ -111,7 +111,7 @@ interface DriveFsDelegate {
OnHeartbeat(); OnHeartbeat();
}; };
// Next MinVersion: 5 // Next MinVersion: 6
struct DriveFsConfiguration { struct DriveFsConfiguration {
string user_email; string user_email;
...@@ -128,6 +128,9 @@ struct DriveFsConfiguration { ...@@ -128,6 +128,9 @@ struct DriveFsConfiguration {
[MinVersion=4] [MinVersion=4]
bool enable_experimental_mirroring = false; bool enable_experimental_mirroring = false;
[MinVersion=5]
bool enable_verbose_logging = false;
}; };
enum AccessTokenStatus { enum AccessTokenStatus {
......
...@@ -15,6 +15,9 @@ const char kDisableDrive[] = "gdata.disabled"; ...@@ -15,6 +15,9 @@ const char kDisableDrive[] = "gdata.disabled";
// The pref prefix should remain as "gdata" for backward compatibility. // The pref prefix should remain as "gdata" for backward compatibility.
const char kDisableDriveOverCellular[] = "gdata.cellular.disabled"; const char kDisableDriveOverCellular[] = "gdata.cellular.disabled";
// A boolean pref to enable or disable verbose logging in DriveFS.
const char kDriveFsEnableVerboseLogging[] = "drivefs.enable_verbose_logging";
// A string pref containing a random salt used to obfuscate account IDs // A string pref containing a random salt used to obfuscate account IDs
// when passed to drivefs. // when passed to drivefs.
const char kDriveFsProfileSalt[] = "drivefs.profile_salt"; const char kDriveFsProfileSalt[] = "drivefs.profile_salt";
......
...@@ -12,6 +12,7 @@ namespace prefs { ...@@ -12,6 +12,7 @@ namespace prefs {
extern const char kDisableDrive[]; extern const char kDisableDrive[];
extern const char kDisableDriveOverCellular[]; extern const char kDisableDriveOverCellular[];
extern const char kDriveFsEnableVerboseLogging[];
extern const char kDriveFsProfileSalt[]; extern const char kDriveFsProfileSalt[];
extern const char kDriveFsPinnedMigrated[]; extern const char kDriveFsPinnedMigrated[];
extern const char kDriveFsWasLaunchedAtLeastOnce[]; extern const char kDriveFsWasLaunchedAtLeastOnce[];
......
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