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

Unified Diff: chrome/browser/media_gallery/media_device_notifications_linux.h

Issue 10829228: [LINUX] Extract the name and id of the device and send it along the device attach message. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments Created 8 years, 4 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
Index: chrome/browser/media_gallery/media_device_notifications_linux.h
diff --git a/chrome/browser/media_gallery/media_device_notifications_linux.h b/chrome/browser/media_gallery/media_device_notifications_linux.h
index 67393ae70615f59c88d5702b265075b70fb74386..18b34bb89d38b8d592d32795be26e88c7b3477d5 100644
--- a/chrome/browser/media_gallery/media_device_notifications_linux.h
+++ b/chrome/browser/media_gallery/media_device_notifications_linux.h
@@ -21,10 +21,17 @@
#include "base/compiler_specific.h"
#include "base/files/file_path_watcher.h"
#include "base/memory/ref_counted.h"
+#include "base/system_monitor/system_monitor.h"
#include "content/public/browser/browser_thread.h"
class FilePath;
+typedef bool (*GetDeviceInfoFunc)(
+ const std::string& device_path,
+ base::SystemMonitor::MediaDeviceType media_device_type,
+ std::string* device_name,
+ string16* device_id);
+
namespace chrome {
class MediaDeviceNotificationsLinux
@@ -33,6 +40,10 @@ class MediaDeviceNotificationsLinux
public:
explicit MediaDeviceNotificationsLinux(const FilePath& path);
+ // Only for use in unit tests.
+ MediaDeviceNotificationsLinux(const FilePath& path,
Lei Zhang 2012/08/10 10:26:33 protected?
kmadhusu 2012/08/10 19:41:01 Done.
+ GetDeviceInfoFunc getDeviceInfo);
+
// Must be called for MediaDeviceNotificationsLinux to work.
void Init();
@@ -51,24 +62,40 @@ class MediaDeviceNotificationsLinux
friend struct content::BrowserThread::DeleteOnThread<
content::BrowserThread::FILE>;
- // (mount device, device id)
- typedef std::pair<std::string, std::string> MountDeviceAndId;
+ struct MountDeviceAndId {
+ MountDeviceAndId(const std::string& mount_device, const std::string& id)
+ : mount_device(mount_device),
Lei Zhang 2012/08/10 10:26:33 nit: name the parameter can just be "device" so th
kmadhusu 2012/08/10 19:41:01 Done.
+ device_unique_id(id) {
+ }
+
+ // Mounted device path.
+ std::string mount_device;
+
+ // Device unique id.
+ std::string device_unique_id;
vandebo (ex-Chrome) 2012/08/10 00:32:58 nit: device_id is probably sufficient
kmadhusu 2012/08/10 19:41:01 Done.
+ };
+
// Mapping of mount points to MountDeviceAndId.
typedef std::map<std::string, MountDeviceAndId> MountMap;
+ // (mount point, mount device)
+ // Helper map to get new entries from mtab file.
+ typedef std::map<std::string, std::string> MountPointDeviceMap;
+
+ // Update |known_file_systems_| based on known file system information.
+ void PopulateKnownFileSystemsInfo();
+
void InitOnFileThread();
// Parse the mtab file and find all changes.
void UpdateMtab();
// Read the mtab file entries into |mtab|.
- void ReadMtab(MountMap* mtab);
+ void ReadMtab(MountPointDeviceMap* mtab);
- // Add a media device with a given device and mount device. Assign it a device
- // id as well.
- void AddNewDevice(const std::string& mount_device,
- const std::string& mount_point,
- std::string* device_id);
+ // Check and add |mount_device| as media device given the |mount_point|.
+ void CheckAndAddMediaDevice(const std::string& mount_device,
+ const std::string& mount_point);
// Remove a media device with a given device id.
void RemoveOldDevice(const std::string& device_id);
@@ -85,15 +112,13 @@ class MediaDeviceNotificationsLinux
// Mapping of relevant mount points and their corresponding mount devices.
// Keep in mind on Linux, a device can be mounted at multiple mount points,
// and multiple devices can be mounted at a mount point.
- MountMap mtab_;
-
- // The lowest available device id number.
- // TODO(thestig) Remove this and use a real per-device unique id instead.
- int current_device_id_;
+ MountMap mount_info_map_;
// Set of known file systems that we care about.
std::set<std::string> known_file_systems_;
+ GetDeviceInfoFunc get_device_info_func_;
+
DISALLOW_COPY_AND_ASSIGN(MediaDeviceNotificationsLinux);
};

Powered by Google App Engine
This is Rietveld 408576698