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

Plumb device label through events in volume manager

Bug: 988586
Change-Id: I122c3a16cdd21d594a8fc7f4205cc8d6655aeed9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1966799Reviewed-by: default avatarAnand Mistry <amistry@chromium.org>
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726243}
parent 8bb79e58
...@@ -49,8 +49,8 @@ void DeviceEventRouter::OnDeviceAdded(const std::string& device_path) { ...@@ -49,8 +49,8 @@ void DeviceEventRouter::OnDeviceAdded(const std::string& device_path) {
SetDeviceState(device_path, DEVICE_STATE_USUAL); SetDeviceState(device_path, DEVICE_STATE_USUAL);
if (IsExternalStorageDisabled()) { if (IsExternalStorageDisabled()) {
OnDeviceEvent(file_manager_private::DEVICE_EVENT_TYPE_DISABLED, OnDeviceEvent(file_manager_private::DEVICE_EVENT_TYPE_DISABLED, device_path,
device_path); "");
return; return;
} }
} }
...@@ -58,7 +58,8 @@ void DeviceEventRouter::OnDeviceAdded(const std::string& device_path) { ...@@ -58,7 +58,8 @@ void DeviceEventRouter::OnDeviceAdded(const std::string& device_path) {
void DeviceEventRouter::OnDeviceRemoved(const std::string& device_path) { void DeviceEventRouter::OnDeviceRemoved(const std::string& device_path) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
SetDeviceState(device_path, DEVICE_STATE_USUAL); SetDeviceState(device_path, DEVICE_STATE_USUAL);
OnDeviceEvent(file_manager_private::DEVICE_EVENT_TYPE_REMOVED, device_path); OnDeviceEvent(file_manager_private::DEVICE_EVENT_TYPE_REMOVED, device_path,
"");
} }
void DeviceEventRouter::OnDiskAdded(const chromeos::disks::Disk& disk, void DeviceEventRouter::OnDiskAdded(const chromeos::disks::Disk& disk,
...@@ -76,7 +77,7 @@ void DeviceEventRouter::OnDiskRemoved(const chromeos::disks::Disk& disk) { ...@@ -76,7 +77,7 @@ void DeviceEventRouter::OnDiskRemoved(const chromeos::disks::Disk& disk) {
if (!disk.is_read_only() && disk.is_mounted() && if (!disk.is_read_only() && disk.is_mounted() &&
GetDeviceState(device_path) != DEVICE_HARD_UNPLUGGED_AND_REPORTED) { GetDeviceState(device_path) != DEVICE_HARD_UNPLUGGED_AND_REPORTED) {
OnDeviceEvent(file_manager_private::DEVICE_EVENT_TYPE_HARD_UNPLUGGED, OnDeviceEvent(file_manager_private::DEVICE_EVENT_TYPE_HARD_UNPLUGGED,
device_path); device_path, disk.device_label());
SetDeviceState(device_path, DEVICE_HARD_UNPLUGGED_AND_REPORTED); SetDeviceState(device_path, DEVICE_HARD_UNPLUGGED_AND_REPORTED);
} }
} }
...@@ -95,43 +96,47 @@ void DeviceEventRouter::OnVolumeUnmounted(chromeos::MountError error_code, ...@@ -95,43 +96,47 @@ void DeviceEventRouter::OnVolumeUnmounted(chromeos::MountError error_code,
} }
void DeviceEventRouter::OnFormatStarted(const std::string& device_path, void DeviceEventRouter::OnFormatStarted(const std::string& device_path,
const std::string& device_label,
bool success) { bool success) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (success) { if (success) {
OnDeviceEvent(file_manager_private::DEVICE_EVENT_TYPE_FORMAT_START, OnDeviceEvent(file_manager_private::DEVICE_EVENT_TYPE_FORMAT_START,
device_path); device_path, device_label);
} else { } else {
OnDeviceEvent(file_manager_private::DEVICE_EVENT_TYPE_FORMAT_FAIL, OnDeviceEvent(file_manager_private::DEVICE_EVENT_TYPE_FORMAT_FAIL,
device_path); device_path, device_label);
} }
} }
void DeviceEventRouter::OnFormatCompleted(const std::string& device_path, void DeviceEventRouter::OnFormatCompleted(const std::string& device_path,
const std::string& device_label,
bool success) { bool success) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
OnDeviceEvent(success ? file_manager_private::DEVICE_EVENT_TYPE_FORMAT_SUCCESS OnDeviceEvent(success ? file_manager_private::DEVICE_EVENT_TYPE_FORMAT_SUCCESS
: file_manager_private::DEVICE_EVENT_TYPE_FORMAT_FAIL, : file_manager_private::DEVICE_EVENT_TYPE_FORMAT_FAIL,
device_path); device_path, device_label);
} }
void DeviceEventRouter::OnRenameStarted(const std::string& device_path, void DeviceEventRouter::OnRenameStarted(const std::string& device_path,
const std::string& device_label,
bool success) { bool success) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
OnDeviceEvent(success ? file_manager_private::DEVICE_EVENT_TYPE_RENAME_START OnDeviceEvent(success ? file_manager_private::DEVICE_EVENT_TYPE_RENAME_START
: file_manager_private::DEVICE_EVENT_TYPE_RENAME_FAIL, : file_manager_private::DEVICE_EVENT_TYPE_RENAME_FAIL,
device_path); device_path, device_label);
} }
void DeviceEventRouter::OnRenameCompleted(const std::string& device_path, void DeviceEventRouter::OnRenameCompleted(const std::string& device_path,
const std::string& device_label,
bool success) { bool success) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
OnDeviceEvent(success ? file_manager_private::DEVICE_EVENT_TYPE_RENAME_SUCCESS OnDeviceEvent(success ? file_manager_private::DEVICE_EVENT_TYPE_RENAME_SUCCESS
: file_manager_private::DEVICE_EVENT_TYPE_RENAME_FAIL, : file_manager_private::DEVICE_EVENT_TYPE_RENAME_FAIL,
device_path); device_path, device_label);
} }
void DeviceEventRouter::SuspendImminent( void DeviceEventRouter::SuspendImminent(
......
...@@ -50,10 +50,18 @@ class DeviceEventRouter : public VolumeManagerObserver, ...@@ -50,10 +50,18 @@ class DeviceEventRouter : public VolumeManagerObserver,
const Volume& volume) override; const Volume& volume) override;
void OnVolumeUnmounted(chromeos::MountError error_code, void OnVolumeUnmounted(chromeos::MountError error_code,
const Volume& volume) override; const Volume& volume) override;
void OnFormatStarted(const std::string& device_path, bool success) override; void OnFormatStarted(const std::string& device_path,
void OnFormatCompleted(const std::string& device_path, bool success) override; const std::string& device_label,
void OnRenameStarted(const std::string& device_path, bool success) override; bool success) override;
void OnRenameCompleted(const std::string& device_path, bool success) override; void OnFormatCompleted(const std::string& device_path,
const std::string& device_label,
bool success) override;
void OnRenameStarted(const std::string& device_path,
const std::string& device_label,
bool success) override;
void OnRenameCompleted(const std::string& device_path,
const std::string& device_label,
bool success) override;
// PowerManagerClient::Observer overrides. // PowerManagerClient::Observer overrides.
void SuspendImminent(power_manager::SuspendImminent::Reason reason) override; void SuspendImminent(power_manager::SuspendImminent::Reason reason) override;
...@@ -66,7 +74,8 @@ class DeviceEventRouter : public VolumeManagerObserver, ...@@ -66,7 +74,8 @@ class DeviceEventRouter : public VolumeManagerObserver,
// Handles a device event containing |type| and |device_path|. // Handles a device event containing |type| and |device_path|.
virtual void OnDeviceEvent( virtual void OnDeviceEvent(
extensions::api::file_manager_private::DeviceEventType type, extensions::api::file_manager_private::DeviceEventType type,
const std::string& device_path) = 0; const std::string& device_path,
const std::string& device_label) = 0;
// Returns external storage is disabled or not. // Returns external storage is disabled or not.
virtual bool IsExternalStorageDisabled() = 0; virtual bool IsExternalStorageDisabled() = 0;
......
...@@ -26,6 +26,7 @@ const char kTestDevicePath[] = "/device/test"; ...@@ -26,6 +26,7 @@ const char kTestDevicePath[] = "/device/test";
struct DeviceEvent { struct DeviceEvent {
extensions::api::file_manager_private::DeviceEventType type; extensions::api::file_manager_private::DeviceEventType type;
std::string device_path; std::string device_path;
std::string device_label;
}; };
// DeviceEventRouter implementation for testing. // DeviceEventRouter implementation for testing.
...@@ -38,10 +39,12 @@ class DeviceEventRouterImpl : public DeviceEventRouter { ...@@ -38,10 +39,12 @@ class DeviceEventRouterImpl : public DeviceEventRouter {
// DeviceEventRouter overrides. // DeviceEventRouter overrides.
void OnDeviceEvent(file_manager_private::DeviceEventType type, void OnDeviceEvent(file_manager_private::DeviceEventType type,
const std::string& device_path) override { const std::string& device_path,
const std::string& device_label) override {
DeviceEvent event; DeviceEvent event;
event.type = type; event.type = type;
event.device_path = device_path; event.device_path = device_path;
event.device_label = device_label;
events.push_back(event); events.push_back(event);
} }
......
...@@ -314,12 +314,14 @@ class DeviceEventRouterImpl : public DeviceEventRouter { ...@@ -314,12 +314,14 @@ class DeviceEventRouterImpl : public DeviceEventRouter {
// DeviceEventRouter overrides. // DeviceEventRouter overrides.
void OnDeviceEvent(file_manager_private::DeviceEventType type, void OnDeviceEvent(file_manager_private::DeviceEventType type,
const std::string& device_path) override { const std::string& device_path,
const std::string& device_label) override {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
file_manager_private::DeviceEvent event; file_manager_private::DeviceEvent event;
event.type = type; event.type = type;
event.device_path = device_path; event.device_path = device_path;
event.device_label = device_label;
BroadcastEvent(profile_, BroadcastEvent(profile_,
extensions::events::FILE_MANAGER_PRIVATE_ON_DEVICE_CHANGED, extensions::events::FILE_MANAGER_PRIVATE_ON_DEVICE_CHANGED,
...@@ -815,24 +817,28 @@ void EventRouter::DispatchMountCompletedEvent( ...@@ -815,24 +817,28 @@ void EventRouter::DispatchMountCompletedEvent(
} }
void EventRouter::OnFormatStarted(const std::string& device_path, void EventRouter::OnFormatStarted(const std::string& device_path,
const std::string& device_label,
bool success) { bool success) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
// Do nothing. // Do nothing.
} }
void EventRouter::OnFormatCompleted(const std::string& device_path, void EventRouter::OnFormatCompleted(const std::string& device_path,
const std::string& device_label,
bool success) { bool success) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
// Do nothing. // Do nothing.
} }
void EventRouter::OnRenameStarted(const std::string& device_path, void EventRouter::OnRenameStarted(const std::string& device_path,
const std::string& device_label,
bool success) { bool success) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
// Do nothing. // Do nothing.
} }
void EventRouter::OnRenameCompleted(const std::string& device_path, void EventRouter::OnRenameCompleted(const std::string& device_path,
const std::string& device_label,
bool success) { bool success) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
// Do nothing. // Do nothing.
......
...@@ -121,10 +121,18 @@ class EventRouter ...@@ -121,10 +121,18 @@ class EventRouter
const Volume& volume) override; const Volume& volume) override;
void OnVolumeUnmounted(chromeos::MountError error_code, void OnVolumeUnmounted(chromeos::MountError error_code,
const Volume& volume) override; const Volume& volume) override;
void OnFormatStarted(const std::string& device_path, bool success) override; void OnFormatStarted(const std::string& device_path,
void OnFormatCompleted(const std::string& device_path, bool success) override; const std::string& device_label,
void OnRenameStarted(const std::string& device_path, bool success) override; bool success) override;
void OnRenameCompleted(const std::string& device_path, bool success) override; void OnFormatCompleted(const std::string& device_path,
const std::string& device_label,
bool success) override;
void OnRenameStarted(const std::string& device_path,
const std::string& device_label,
bool success) override;
void OnRenameCompleted(const std::string& device_path,
const std::string& device_label,
bool success) override;
// Set custom dispatch directory change event implementation for testing. // Set custom dispatch directory change event implementation for testing.
void SetDispatchDirectoryChangeEventImplForTesting( void SetDispatchDirectoryChangeEventImplForTesting(
const DispatchDirectoryChangeEventImplCallback& callback); const DispatchDirectoryChangeEventImplCallback& callback);
......
...@@ -934,7 +934,7 @@ void VolumeManager::OnFormatEvent( ...@@ -934,7 +934,7 @@ void VolumeManager::OnFormatEvent(
switch (event) { switch (event) {
case chromeos::disks::DiskMountManager::FORMAT_STARTED: case chromeos::disks::DiskMountManager::FORMAT_STARTED:
for (auto& observer : observers_) { for (auto& observer : observers_) {
observer.OnFormatStarted(device_path, observer.OnFormatStarted(device_path, device_label,
error_code == chromeos::FORMAT_ERROR_NONE); error_code == chromeos::FORMAT_ERROR_NONE);
} }
return; return;
...@@ -949,7 +949,7 @@ void VolumeManager::OnFormatEvent( ...@@ -949,7 +949,7 @@ void VolumeManager::OnFormatEvent(
GetExternalStorageAccessMode(profile_)); GetExternalStorageAccessMode(profile_));
for (auto& observer : observers_) { for (auto& observer : observers_) {
observer.OnFormatCompleted(device_path, observer.OnFormatCompleted(device_path, device_label,
error_code == chromeos::FORMAT_ERROR_NONE); error_code == chromeos::FORMAT_ERROR_NONE);
} }
...@@ -970,7 +970,7 @@ void VolumeManager::OnRenameEvent( ...@@ -970,7 +970,7 @@ void VolumeManager::OnRenameEvent(
switch (event) { switch (event) {
case chromeos::disks::DiskMountManager::RENAME_STARTED: case chromeos::disks::DiskMountManager::RENAME_STARTED:
for (auto& observer : observers_) { for (auto& observer : observers_) {
observer.OnRenameStarted(device_path, observer.OnRenameStarted(device_path, device_label,
error_code == chromeos::RENAME_ERROR_NONE); error_code == chromeos::RENAME_ERROR_NONE);
} }
return; return;
...@@ -995,7 +995,8 @@ void VolumeManager::OnRenameEvent( ...@@ -995,7 +995,8 @@ void VolumeManager::OnRenameEvent(
bool successfully_renamed = error_code == chromeos::RENAME_ERROR_NONE; bool successfully_renamed = error_code == chromeos::RENAME_ERROR_NONE;
for (auto& observer : observers_) for (auto& observer : observers_)
observer.OnRenameCompleted(device_path, successfully_renamed); observer.OnRenameCompleted(device_path, device_label,
successfully_renamed);
return; return;
} }
......
...@@ -45,18 +45,24 @@ class VolumeManagerObserver { ...@@ -45,18 +45,24 @@ class VolumeManagerObserver {
const Volume& volume) {} const Volume& volume) {}
// Fired when formatting a device is started (or failed to start). // Fired when formatting a device is started (or failed to start).
virtual void OnFormatStarted(const std::string& device_path, bool success) {} virtual void OnFormatStarted(const std::string& device_path,
const std::string& device_label,
bool success) {}
// Fired when formatting a device is completed (or terminated on error). // Fired when formatting a device is completed (or terminated on error).
virtual void OnFormatCompleted(const std::string& device_path, bool success) { virtual void OnFormatCompleted(const std::string& device_path,
} const std::string& device_label,
bool success) {}
// Fired when renaming a device is started (or failed to start). // Fired when renaming a device is started (or failed to start).
virtual void OnRenameStarted(const std::string& device_path, bool success) {} virtual void OnRenameStarted(const std::string& device_path,
const std::string& device_label,
bool success) {}
// Fired when renaming a device is completed (or terminated on error). // Fired when renaming a device is completed (or terminated on error).
virtual void OnRenameCompleted(const std::string& device_path, bool success) { virtual void OnRenameCompleted(const std::string& device_path,
} const std::string& device_label,
bool success) {}
}; };
} // namespace file_manager } // namespace file_manager
......
...@@ -69,6 +69,10 @@ class LoggingObserver : public VolumeManagerObserver { ...@@ -69,6 +69,10 @@ class LoggingObserver : public VolumeManagerObserver {
// VOLUME_UNMOUNTED, FORMAT_STARTED and FORMAT_COMPLETED. // VOLUME_UNMOUNTED, FORMAT_STARTED and FORMAT_COMPLETED.
std::string device_path; std::string device_path;
// Available on FORMAT_STARTED, FORMAT_COMPLETED, RENAME_STARTED and
// RENAME_COMPLETED.
std::string device_label;
// Available on DISK_ADDED. // Available on DISK_ADDED.
bool mounting; bool mounting;
...@@ -132,36 +136,46 @@ class LoggingObserver : public VolumeManagerObserver { ...@@ -132,36 +136,46 @@ class LoggingObserver : public VolumeManagerObserver {
events_.push_back(event); events_.push_back(event);
} }
void OnFormatStarted(const std::string& device_path, bool success) override { void OnFormatStarted(const std::string& device_path,
const std::string& device_label,
bool success) override {
Event event; Event event;
event.type = Event::FORMAT_STARTED; event.type = Event::FORMAT_STARTED;
event.device_path = device_path; event.device_path = device_path;
event.device_label = device_label;
event.success = success; event.success = success;
events_.push_back(event); events_.push_back(event);
} }
void OnFormatCompleted(const std::string& device_path, void OnFormatCompleted(const std::string& device_path,
const std::string& device_label,
bool success) override { bool success) override {
Event event; Event event;
event.type = Event::FORMAT_COMPLETED; event.type = Event::FORMAT_COMPLETED;
event.device_path = device_path; event.device_path = device_path;
event.device_label = device_label;
event.success = success; event.success = success;
events_.push_back(event); events_.push_back(event);
} }
void OnRenameStarted(const std::string& device_path, bool success) override { void OnRenameStarted(const std::string& device_path,
const std::string& device_label,
bool success) override {
Event event; Event event;
event.type = Event::RENAME_STARTED; event.type = Event::RENAME_STARTED;
event.device_path = device_path; event.device_path = device_path;
event.device_label = device_label;
event.success = success; event.success = success;
events_.push_back(event); events_.push_back(event);
} }
void OnRenameCompleted(const std::string& device_path, void OnRenameCompleted(const std::string& device_path,
const std::string& device_label,
bool success) override { bool success) override {
Event event; Event event;
event.type = Event::RENAME_COMPLETED; event.type = Event::RENAME_COMPLETED;
event.device_path = device_path; event.device_path = device_path;
event.device_label = device_label;
event.success = success; event.success = success;
events_.push_back(event); events_.push_back(event);
} }
...@@ -681,6 +695,7 @@ TEST_F(VolumeManagerTest, OnFormatEvent_Started) { ...@@ -681,6 +695,7 @@ TEST_F(VolumeManagerTest, OnFormatEvent_Started) {
const LoggingObserver::Event& event = observer.events()[0]; const LoggingObserver::Event& event = observer.events()[0];
EXPECT_EQ(LoggingObserver::Event::FORMAT_STARTED, event.type); EXPECT_EQ(LoggingObserver::Event::FORMAT_STARTED, event.type);
EXPECT_EQ("device1", event.device_path); EXPECT_EQ("device1", event.device_path);
EXPECT_EQ("label1", event.device_label);
EXPECT_TRUE(event.success); EXPECT_TRUE(event.success);
volume_manager()->RemoveObserver(&observer); volume_manager()->RemoveObserver(&observer);
...@@ -698,6 +713,7 @@ TEST_F(VolumeManagerTest, OnFormatEvent_StartFailed) { ...@@ -698,6 +713,7 @@ TEST_F(VolumeManagerTest, OnFormatEvent_StartFailed) {
const LoggingObserver::Event& event = observer.events()[0]; const LoggingObserver::Event& event = observer.events()[0];
EXPECT_EQ(LoggingObserver::Event::FORMAT_STARTED, event.type); EXPECT_EQ(LoggingObserver::Event::FORMAT_STARTED, event.type);
EXPECT_EQ("device1", event.device_path); EXPECT_EQ("device1", event.device_path);
EXPECT_EQ("label1", event.device_label);
EXPECT_FALSE(event.success); EXPECT_FALSE(event.success);
volume_manager()->RemoveObserver(&observer); volume_manager()->RemoveObserver(&observer);
...@@ -715,6 +731,7 @@ TEST_F(VolumeManagerTest, OnFormatEvent_Completed) { ...@@ -715,6 +731,7 @@ TEST_F(VolumeManagerTest, OnFormatEvent_Completed) {
const LoggingObserver::Event& event = observer.events()[0]; const LoggingObserver::Event& event = observer.events()[0];
EXPECT_EQ(LoggingObserver::Event::FORMAT_COMPLETED, event.type); EXPECT_EQ(LoggingObserver::Event::FORMAT_COMPLETED, event.type);
EXPECT_EQ("device1", event.device_path); EXPECT_EQ("device1", event.device_path);
EXPECT_EQ("label1", event.device_label);
EXPECT_TRUE(event.success); EXPECT_TRUE(event.success);
// When "format" is done, VolumeManager requests to mount it. // When "format" is done, VolumeManager requests to mount it.
...@@ -741,6 +758,7 @@ TEST_F(VolumeManagerTest, OnFormatEvent_CompletedFailed) { ...@@ -741,6 +758,7 @@ TEST_F(VolumeManagerTest, OnFormatEvent_CompletedFailed) {
const LoggingObserver::Event& event = observer.events()[0]; const LoggingObserver::Event& event = observer.events()[0];
EXPECT_EQ(LoggingObserver::Event::FORMAT_COMPLETED, event.type); EXPECT_EQ(LoggingObserver::Event::FORMAT_COMPLETED, event.type);
EXPECT_EQ("device1", event.device_path); EXPECT_EQ("device1", event.device_path);
EXPECT_EQ("label1", event.device_label);
EXPECT_FALSE(event.success); EXPECT_FALSE(event.success);
// When "format" is done, VolumeManager requests to mount it. // When "format" is done, VolumeManager requests to mount it.
...@@ -1005,6 +1023,7 @@ TEST_F(VolumeManagerTest, OnRenameEvent_Started) { ...@@ -1005,6 +1023,7 @@ TEST_F(VolumeManagerTest, OnRenameEvent_Started) {
const LoggingObserver::Event& event = observer.events()[0]; const LoggingObserver::Event& event = observer.events()[0];
EXPECT_EQ(LoggingObserver::Event::RENAME_STARTED, event.type); EXPECT_EQ(LoggingObserver::Event::RENAME_STARTED, event.type);
EXPECT_EQ("device1", event.device_path); EXPECT_EQ("device1", event.device_path);
EXPECT_EQ("label1", event.device_label);
EXPECT_TRUE(event.success); EXPECT_TRUE(event.success);
volume_manager()->RemoveObserver(&observer); volume_manager()->RemoveObserver(&observer);
...@@ -1022,6 +1041,7 @@ TEST_F(VolumeManagerTest, OnRenameEvent_StartFailed) { ...@@ -1022,6 +1041,7 @@ TEST_F(VolumeManagerTest, OnRenameEvent_StartFailed) {
const LoggingObserver::Event& event = observer.events()[0]; const LoggingObserver::Event& event = observer.events()[0];
EXPECT_EQ(LoggingObserver::Event::RENAME_STARTED, event.type); EXPECT_EQ(LoggingObserver::Event::RENAME_STARTED, event.type);
EXPECT_EQ("device1", event.device_path); EXPECT_EQ("device1", event.device_path);
EXPECT_EQ("label1", event.device_label);
EXPECT_FALSE(event.success); EXPECT_FALSE(event.success);
volume_manager()->RemoveObserver(&observer); volume_manager()->RemoveObserver(&observer);
...@@ -1039,6 +1059,7 @@ TEST_F(VolumeManagerTest, OnRenameEvent_Completed) { ...@@ -1039,6 +1059,7 @@ TEST_F(VolumeManagerTest, OnRenameEvent_Completed) {
const LoggingObserver::Event& event = observer.events()[0]; const LoggingObserver::Event& event = observer.events()[0];
EXPECT_EQ(LoggingObserver::Event::RENAME_COMPLETED, event.type); EXPECT_EQ(LoggingObserver::Event::RENAME_COMPLETED, event.type);
EXPECT_EQ("device1", event.device_path); EXPECT_EQ("device1", event.device_path);
EXPECT_EQ("label1", event.device_label);
EXPECT_TRUE(event.success); EXPECT_TRUE(event.success);
// When "rename" is successfully done, VolumeManager requests to mount it. // When "rename" is successfully done, VolumeManager requests to mount it.
...@@ -1064,6 +1085,7 @@ TEST_F(VolumeManagerTest, OnRenameEvent_CompletedFailed) { ...@@ -1064,6 +1085,7 @@ TEST_F(VolumeManagerTest, OnRenameEvent_CompletedFailed) {
const LoggingObserver::Event& event = observer.events()[0]; const LoggingObserver::Event& event = observer.events()[0];
EXPECT_EQ(LoggingObserver::Event::RENAME_COMPLETED, event.type); EXPECT_EQ(LoggingObserver::Event::RENAME_COMPLETED, event.type);
EXPECT_EQ("device1", event.device_path); EXPECT_EQ("device1", event.device_path);
EXPECT_EQ("label1", event.device_label);
EXPECT_FALSE(event.success); EXPECT_FALSE(event.success);
EXPECT_EQ(1U, disk_mount_manager_->mount_requests().size()); EXPECT_EQ(1U, disk_mount_manager_->mount_requests().size());
......
...@@ -633,6 +633,8 @@ dictionary DeviceEvent { ...@@ -633,6 +633,8 @@ dictionary DeviceEvent {
DeviceEventType type; DeviceEventType type;
// Device path to identify the device. // Device path to identify the device.
DOMString devicePath; DOMString devicePath;
// Human readable label for the device.
DOMString deviceLabel;
}; };
// Describes an installed provider. // Describes an installed provider.
......
...@@ -474,7 +474,8 @@ chrome.fileManagerPrivate.DriveConnectionState; ...@@ -474,7 +474,8 @@ chrome.fileManagerPrivate.DriveConnectionState;
/** /**
* @typedef {{ * @typedef {{
* type: !chrome.fileManagerPrivate.DeviceEventType, * type: !chrome.fileManagerPrivate.DeviceEventType,
* devicePath: string * devicePath: string,
* deviceLabel: string
* }} * }}
*/ */
chrome.fileManagerPrivate.DeviceEvent; chrome.fileManagerPrivate.DeviceEvent;
......
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