| Index: chrome/browser/system_monitor/removable_device_notifications_chromeos.cc
|
| diff --git a/chrome/browser/system_monitor/removable_device_notifications_chromeos.cc b/chrome/browser/system_monitor/removable_device_notifications_chromeos.cc
|
| index 1b17b925cd5ac927a22b4c38c31401bcfae19d69..3527df248b444d5d34591f19807ea1cf564a7b85 100644
|
| --- a/chrome/browser/system_monitor/removable_device_notifications_chromeos.cc
|
| +++ b/chrome/browser/system_monitor/removable_device_notifications_chromeos.cc
|
| @@ -14,12 +14,18 @@
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/browser/system_monitor/media_device_notifications_utils.h"
|
| #include "chrome/browser/system_monitor/media_storage_util.h"
|
| +#include "chrome/browser/system_monitor/removable_device_constants.h"
|
| #include "content/public/browser/browser_thread.h"
|
|
|
| namespace chromeos {
|
|
|
| +using base::SystemMonitor;
|
| +
|
| namespace {
|
|
|
| +static RemovableDeviceNotificationsCros*
|
| + g_removable_device_notifications_chromeos = NULL;
|
| +
|
| // Returns true if the requested device is valid, else false. On success, fills
|
| // in |unique_id| and |device_label|
|
| bool GetDeviceInfo(const std::string& source_path, std::string* unique_id,
|
| @@ -46,17 +52,27 @@ using content::BrowserThread;
|
|
|
| RemovableDeviceNotificationsCros::RemovableDeviceNotificationsCros() {
|
| DCHECK(disks::DiskMountManager::GetInstance());
|
| + DCHECK(!g_removable_device_notifications_chromeos);
|
| + g_removable_device_notifications_chromeos = this;
|
| disks::DiskMountManager::GetInstance()->AddObserver(this);
|
| CheckExistingMountPointsOnUIThread();
|
| }
|
|
|
| RemovableDeviceNotificationsCros::~RemovableDeviceNotificationsCros() {
|
| + DCHECK_EQ(this, g_removable_device_notifications_chromeos);
|
| + g_removable_device_notifications_chromeos = NULL;
|
| disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance();
|
| if (manager) {
|
| manager->RemoveObserver(this);
|
| }
|
| }
|
|
|
| +// static
|
| +RemovableDeviceNotificationsCros*
|
| +RemovableDeviceNotificationsCros::GetInstance() {
|
| + return g_removable_device_notifications_chromeos;
|
| +}
|
| +
|
| void RemovableDeviceNotificationsCros::CheckExistingMountPointsOnUIThread() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| const disks::DiskMountManager::MountPointMap& mount_point_map =
|
| @@ -114,13 +130,35 @@ void RemovableDeviceNotificationsCros::MountCompleted(
|
| MountMap::iterator it = mount_map_.find(mount_info.mount_path);
|
| if (it == mount_map_.end())
|
| return;
|
| - base::SystemMonitor::Get()->ProcessRemovableStorageDetached(it->second);
|
| + SystemMonitor::Get()->ProcessRemovableStorageDetached(
|
| + it->second.device_id);
|
| mount_map_.erase(it);
|
| break;
|
| }
|
| }
|
| }
|
|
|
| +bool RemovableDeviceNotificationsCros::GetDeviceInfoForPath(
|
| + const FilePath& path,
|
| + SystemMonitor::RemovableStorageInfo* device_info) const {
|
| + if (!path.IsAbsolute())
|
| + return false;
|
| +
|
| + FilePath current = path;
|
| + while (!ContainsKey(mount_map_, current.value()) &&
|
| + current != current.DirName()) {
|
| + current = current.DirName();
|
| + }
|
| +
|
| + MountMap::const_iterator info_it = mount_map_.find(current.value());
|
| + if (info_it == mount_map_.end())
|
| + return false;
|
| +
|
| + if (device_info)
|
| + *device_info = info_it->second;
|
| + return true;
|
| +}
|
| +
|
| void RemovableDeviceNotificationsCros::CheckMountedPathOnFileThread(
|
| const disks::DiskMountManager::MountPointInfo& mount_info) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| @@ -160,8 +198,10 @@ void RemovableDeviceNotificationsCros::AddMountedPathOnUIThread(
|
|
|
| std::string device_id = chrome::MediaStorageUtil::MakeDeviceId(type,
|
| unique_id);
|
| - mount_map_.insert(std::make_pair(mount_info.mount_path, device_id));
|
| - base::SystemMonitor::Get()->ProcessRemovableStorageAttached(
|
| + SystemMonitor::RemovableStorageInfo info(device_id, device_label,
|
| + mount_info.mount_path);
|
| + mount_map_.insert(std::make_pair(mount_info.mount_path, info));
|
| + SystemMonitor::Get()->ProcessRemovableStorageAttached(
|
| device_id,
|
| device_label,
|
| mount_info.mount_path);
|
|
|