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

Side by Side Diff: chrome/browser/storage_monitor/removable_device_notifications_linux.h

Issue 12211084: [Media Galleries] Populate volume metadata in ChromeOS/Linux (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reset header file Created 7 years, 9 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
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 // RemovableDeviceNotificationsLinux listens for mount point changes, notifies 5 // RemovableDeviceNotificationsLinux listens for mount point changes, notifies
6 // listeners about the addition and deletion of media devices, and 6 // listeners about the addition and deletion of media devices, and
7 // answers queries about mounted devices. 7 // answers queries about mounted devices.
8 8
9 #ifndef CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_ 9 #ifndef CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_
10 #define CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_ 10 #define CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_
(...skipping 11 matching lines...) Expand all
22 #include "base/compiler_specific.h" 22 #include "base/compiler_specific.h"
23 #include "base/files/file_path_watcher.h" 23 #include "base/files/file_path_watcher.h"
24 #include "base/memory/ref_counted.h" 24 #include "base/memory/ref_counted.h"
25 #include "chrome/browser/storage_monitor/storage_monitor.h" 25 #include "chrome/browser/storage_monitor/storage_monitor.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 27
28 namespace base { 28 namespace base {
29 class FilePath; 29 class FilePath;
30 } 30 }
31 31
32 // Gets device information given a |device_path|. On success, fills in 32 // Gets device information given a |device_path| and |mount_point|.
33 // |unique_id|, |name|, |removable| and |partition_size_in_bytes|. 33 // On success, fills in metadata fields.
34 typedef void (*GetDeviceInfoFunc)(const base::FilePath& device_path, 34 typedef void (*GetDeviceInfoFunc)(const base::FilePath& device_path,
vandebo (ex-Chrome) 2013/03/01 22:21:48 So I think the signature of this function is prett
Greg Billock 2013/03/05 19:20:55 We are in the position now where we can use inheri
vandebo (ex-Chrome) 2013/03/06 01:34:54 Inheritance for the test sounds good. The swappab
Greg Billock 2013/03/06 23:24:25 I think we have a plan for this now.
35 std::string* unique_id, 35 const base::FilePath& mount_point,
36 std::string* device_id,
36 string16* name, 37 string16* name,
37 bool* removable, 38 bool* removable,
38 uint64* partition_size_in_bytes); 39 uint64* partition_size_in_bytes,
40 string16* volume_label,
41 string16* vendor_name,
42 string16* model_name);
39 43
40 namespace chrome { 44 namespace chrome {
41 45
42 class RemovableDeviceNotificationsLinux 46 class RemovableDeviceNotificationsLinux
43 : public StorageMonitor, 47 : public StorageMonitor,
44 public base::RefCountedThreadSafe<RemovableDeviceNotificationsLinux, 48 public base::RefCountedThreadSafe<RemovableDeviceNotificationsLinux,
45 content::BrowserThread::DeleteOnFileThread> { 49 content::BrowserThread::DeleteOnFileThread> {
46 public: 50 public:
47 // Should only be called by browser start up code. Use GetInstance() instead. 51 // Should only be called by browser start up code. Use GetInstance() instead.
48 explicit RemovableDeviceNotificationsLinux(const base::FilePath& path); 52 explicit RemovableDeviceNotificationsLinux(const base::FilePath& path);
(...skipping 23 matching lines...) Expand all
72 virtual ~RemovableDeviceNotificationsLinux(); 76 virtual ~RemovableDeviceNotificationsLinux();
73 77
74 virtual void OnFilePathChanged(const base::FilePath& path, bool error); 78 virtual void OnFilePathChanged(const base::FilePath& path, bool error);
75 79
76 private: 80 private:
77 friend class base::RefCountedThreadSafe<RemovableDeviceNotificationsLinux>; 81 friend class base::RefCountedThreadSafe<RemovableDeviceNotificationsLinux>;
78 friend class base::DeleteHelper<RemovableDeviceNotificationsLinux>; 82 friend class base::DeleteHelper<RemovableDeviceNotificationsLinux>;
79 friend struct content::BrowserThread::DeleteOnThread< 83 friend struct content::BrowserThread::DeleteOnThread<
80 content::BrowserThread::FILE>; 84 content::BrowserThread::FILE>;
81 85
82 // Structure to save mounted device information such as device path, unique 86 base::FilePath GetDeviceForMountPoint(const base::FilePath& mount_point);
83 // identifier, device name and partition size.
84 struct MountPointInfo {
85 MountPointInfo();
86 87
87 base::FilePath mount_device; 88 // Mapping of mount points to StorageInfo.
88 std::string device_id; 89 typedef std::map<base::FilePath, StorageInfo> MountMap;
89 string16 device_name;
90 uint64 partition_size_in_bytes;
91 };
92
93 // Mapping of mount points to MountPointInfo.
94 typedef std::map<base::FilePath, MountPointInfo> MountMap;
95 90
96 // (mount point, priority) 91 // (mount point, priority)
97 // For devices that are mounted to multiple mount points, this helps us track 92 // For devices that are mounted to multiple mount points, this helps us track
98 // which one we've notified system monitor about. 93 // which one we've notified system monitor about.
99 typedef std::map<base::FilePath, bool> ReferencedMountPoint; 94 typedef std::map<base::FilePath, bool> ReferencedMountPoint;
100 95
101 // (mount device, map of known mount points) 96 // (mount device, map of known mount points)
102 // For each mount device, track the places it is mounted and which one (if 97 // For each mount device, track the places it is mounted and which one (if
103 // any) we have notified system monitor about. 98 // any) we have notified system monitor about.
104 typedef std::map<base::FilePath, ReferencedMountPoint> MountPriorityMap; 99 typedef std::map<base::FilePath, ReferencedMountPoint> MountPriorityMap;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // to notify about it's departure and notify about another one of it's mount 135 // to notify about it's departure and notify about another one of it's mount
141 // points. 136 // points.
142 MountPriorityMap mount_priority_map_; 137 MountPriorityMap mount_priority_map_;
143 138
144 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsLinux); 139 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsLinux);
145 }; 140 };
146 141
147 } // namespace chrome 142 } // namespace chrome
148 143
149 #endif // CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H _ 144 #endif // CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698