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

Side by Side 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: Address 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // MediaDeviceNotificationsLinux listens for mount point changes and notifies 5 // MediaDeviceNotificationsLinux listens for mount point changes and notifies
6 // the SystemMonitor about the addition and deletion of media devices. 6 // the SystemMonitor about the addition and deletion of media devices.
7 7
8 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_ 8 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_
9 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_ 9 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_
10 10
(...skipping 27 matching lines...) Expand all
38 38
39 protected: 39 protected:
40 // Avoids code deleting the object while there are references to it. 40 // Avoids code deleting the object while there are references to it.
41 // Aside from the base::RefCountedThreadSafe friend class, and derived 41 // Aside from the base::RefCountedThreadSafe friend class, and derived
42 // classes, any attempts to call this dtor will result in a compile-time 42 // classes, any attempts to call this dtor will result in a compile-time
43 // error. 43 // error.
44 virtual ~MediaDeviceNotificationsLinux(); 44 virtual ~MediaDeviceNotificationsLinux();
45 45
46 virtual void OnFilePathChanged(const FilePath& path, bool error); 46 virtual void OnFilePathChanged(const FilePath& path, bool error);
47 47
48 // Get mounted device properties. This function is exposed for unit test.
49 virtual bool GetDeviceInfo(const std::string& dev_path,
Lei Zhang 2012/08/09 03:47:16 I suspect you can make this private.
kmadhusu 2012/08/09 08:10:03 Done.
50 std::string* device_label,
51 string16* device_name);
52
48 private: 53 private:
49 friend class base::RefCountedThreadSafe<MediaDeviceNotificationsLinux>; 54 friend class base::RefCountedThreadSafe<MediaDeviceNotificationsLinux>;
50 friend class base::DeleteHelper<MediaDeviceNotificationsLinux>; 55 friend class base::DeleteHelper<MediaDeviceNotificationsLinux>;
51 friend struct content::BrowserThread::DeleteOnThread< 56 friend struct content::BrowserThread::DeleteOnThread<
52 content::BrowserThread::FILE>; 57 content::BrowserThread::FILE>;
53 58
54 // (mount device, device id) 59 // (mount device, device id)
55 typedef std::pair<std::string, std::string> MountDeviceAndId; 60 typedef std::pair<std::string, std::string> MountDeviceAndId;
56 // Mapping of mount points to MountDeviceAndId. 61 // Mapping of mount points to MountDeviceAndId.
57 typedef std::map<std::string, MountDeviceAndId> MountMap; 62 typedef std::map<std::string, MountDeviceAndId> MountMap;
58 63
64 // (mount point, mount device)
65 // Helper map to get new entries from mtab file.
66 typedef std::map<std::string, std::string> MountPointDeviceMap;
67
59 void InitOnFileThread(); 68 void InitOnFileThread();
60 69
61 // Parse the mtab file and find all changes. 70 // Parse the mtab file and find all changes.
62 void UpdateMtab(); 71 void UpdateMtab();
63 72
64 // Read the mtab file entries into |mtab|. 73 // Read the mtab file entries into |mtab|.
65 void ReadMtab(MountMap* mtab); 74 void ReadMtab(MountPointDeviceMap* mtab);
66 75
67 // Add a media device with a given device and mount device. Assign it a device 76 // Add a media device with a given device and mount device. Assign it a device
68 // id as well. 77 // id as well.
69 void AddNewDevice(const std::string& mount_device, 78 void AddNewDevice(const std::string& mount_device,
70 const std::string& mount_point, 79 const std::string& mount_point,
71 std::string* device_id); 80 std::string* device_id);
72 81
73 // Remove a media device with a given device id. 82 // Remove a media device with a given device id.
74 void RemoveOldDevice(const std::string& device_id); 83 void RemoveOldDevice(const std::string& device_id);
75 84
76 // Whether Init() has been called or not. 85 // Whether Init() has been called or not.
77 bool initialized_; 86 bool initialized_;
78 87
79 // Mtab file that lists the mount points. 88 // Mtab file that lists the mount points.
80 const FilePath mtab_path_; 89 const FilePath mtab_path_;
81 90
82 // Watcher for |mtab_path_|. 91 // Watcher for |mtab_path_|.
83 base::files::FilePathWatcher file_watcher_; 92 base::files::FilePathWatcher file_watcher_;
84 93
85 // Mapping of relevant mount points and their corresponding mount devices. 94 // Mapping of relevant mount points and their corresponding mount devices.
86 // Keep in mind on Linux, a device can be mounted at multiple mount points, 95 // Keep in mind on Linux, a device can be mounted at multiple mount points,
87 // and multiple devices can be mounted at a mount point. 96 // and multiple devices can be mounted at a mount point.
88 MountMap mtab_; 97 MountMap mtab_;
89 98
90 // The lowest available device id number.
91 // TODO(thestig) Remove this and use a real per-device unique id instead.
92 int current_device_id_;
93
94 // Set of known file systems that we care about. 99 // Set of known file systems that we care about.
95 std::set<std::string> known_file_systems_; 100 std::set<std::string> known_file_systems_;
96 101
97 DISALLOW_COPY_AND_ASSIGN(MediaDeviceNotificationsLinux); 102 DISALLOW_COPY_AND_ASSIGN(MediaDeviceNotificationsLinux);
98 }; 103 };
99 104
100 } // namespace chrome 105 } // namespace chrome
101 106
102 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_ 107 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_DEVICE_NOTIFICATIONS_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698