Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Unified Diff: chrome/browser/system_monitor/removable_device_notifications_chromeos.cc

Issue 10918259: [Chrome OS]Implement MediaStorageUtil::GetDeviceInfoForPath function to support media gallery permi… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/system_monitor/removable_device_notifications_chromeos.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4a9a49f26ecdee9989f6620e7af17d7adc0b56e2..94d43a0a534243445649a40e8c3a52b1a0aa397b 100644
--- a/chrome/browser/system_monitor/removable_device_notifications_chromeos.cc
+++ b/chrome/browser/system_monitor/removable_device_notifications_chromeos.cc
@@ -20,6 +20,8 @@
namespace chromeos {
+using base::SystemMonitor;
+
namespace {
// Construct a device name using label or manufacturer (vendor and product) name
@@ -60,6 +62,9 @@ std::string MakeDeviceUniqueId(const disks::DiskMountManager::Disk& disk) {
product.c_str(), chrome::kNonSpaceDelim);
}
+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,
@@ -84,17 +89,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 =
@@ -152,13 +167,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));
@@ -175,10 +212,8 @@ void RemovableDeviceNotificationsCros::AddMountedPathOnUIThread(
const disks::DiskMountManager::MountPointInfo& mount_info, bool has_dcim) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (ContainsKey(mount_map_, mount_info.mount_path)) {
- NOTREACHED();
kmadhusu 2012/09/17 21:47:55 CheckExistingMountPointsOnUIThread() added the mou
+ if (ContainsKey(mount_map_, mount_info.mount_path))
return;
- }
// Get the media device uuid and label if exists.
std::string unique_id;
@@ -200,8 +235,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);
« no previous file with comments | « chrome/browser/system_monitor/removable_device_notifications_chromeos.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698