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

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

Issue 12382005: Rename RemovableDeviceNotifications=>StorageMonitor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 // StorageMonitorLinux listens for mount point changes, notifies listeners
6 // listeners about the addition and deletion of media devices, and 6 // about the addition and deletion of media devices, and answers queries about
7 // answers queries about mounted devices. 7 // mounted devices.
8 8
9 #ifndef CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_ 9 #ifndef CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_LINUX_H_
10 #define CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_ 10 #define CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_LINUX_H_
11 11
12 #if defined(OS_CHROMEOS) 12 #if defined(OS_CHROMEOS)
13 #error "Use the ChromeOS-specific implementation instead." 13 #error "Use the ChromeOS-specific implementation instead."
14 #endif 14 #endif
15 15
16 #include <map> 16 #include <map>
17 #include <set> 17 #include <set>
18 #include <string> 18 #include <string>
19 #include <utility> 19 #include <utility>
20 20
(...skipping 11 matching lines...) Expand all
32 // Gets device information given a |device_path|. On success, fills in 32 // Gets device information given a |device_path|. On success, fills in
33 // |unique_id|, |name|, |removable| and |partition_size_in_bytes|. 33 // |unique_id|, |name|, |removable| and |partition_size_in_bytes|.
34 typedef void (*GetDeviceInfoFunc)(const base::FilePath& device_path, 34 typedef void (*GetDeviceInfoFunc)(const base::FilePath& device_path,
35 std::string* unique_id, 35 std::string* unique_id,
36 string16* name, 36 string16* name,
37 bool* removable, 37 bool* removable,
38 uint64* partition_size_in_bytes); 38 uint64* partition_size_in_bytes);
39 39
40 namespace chrome { 40 namespace chrome {
41 41
42 class RemovableDeviceNotificationsLinux 42 class StorageMonitorLinux
43 : public StorageMonitor, 43 : public StorageMonitor,
44 public base::RefCountedThreadSafe<RemovableDeviceNotificationsLinux, 44 public base::RefCountedThreadSafe<StorageMonitorLinux,
45 content::BrowserThread::DeleteOnFileThread> { 45 content::BrowserThread::DeleteOnFileThread> {
46 public: 46 public:
47 // Should only be called by browser start up code. Use GetInstance() instead. 47 // Should only be called by browser start up code. Use GetInstance() instead.
48 explicit RemovableDeviceNotificationsLinux(const base::FilePath& path); 48 explicit StorageMonitorLinux(const base::FilePath& path);
49 49
50 // Must be called for RemovableDeviceNotificationsLinux to work. 50 // Must be called for StorageMonitorLinux to work.
51 void Init(); 51 void Init();
52 52
53 // Finds the device that contains |path| and populates |device_info|. 53 // Finds the device that contains |path| and populates |device_info|.
54 // Returns false if unable to find the device. 54 // Returns false if unable to find the device.
55 virtual bool GetStorageInfoForPath( 55 virtual bool GetStorageInfoForPath(
56 const base::FilePath& path, 56 const base::FilePath& path,
57 StorageInfo* device_info) const OVERRIDE; 57 StorageInfo* device_info) const OVERRIDE;
58 58
59 // Returns the storage partition size of the device present at |location|. 59 // Returns the storage partition size of the device present at |location|.
60 // If the requested information is unavailable, returns 0. 60 // If the requested information is unavailable, returns 0.
61 virtual uint64 GetStorageSize(const std::string& location) const OVERRIDE; 61 virtual uint64 GetStorageSize(const std::string& location) const OVERRIDE;
62 62
63 protected: 63 protected:
64 // Only for use in unit tests. 64 // Only for use in unit tests.
65 RemovableDeviceNotificationsLinux(const base::FilePath& path, 65 StorageMonitorLinux(const base::FilePath& path,
66 GetDeviceInfoFunc getDeviceInfo); 66 GetDeviceInfoFunc getDeviceInfo);
67 67
68 // Avoids code deleting the object while there are references to it. 68 // Avoids code deleting the object while there are references to it.
69 // Aside from the base::RefCountedThreadSafe friend class, and derived 69 // Aside from the base::RefCountedThreadSafe friend class, and derived
70 // classes, any attempts to call this dtor will result in a compile-time 70 // classes, any attempts to call this dtor will result in a compile-time
71 // error. 71 // error.
72 virtual ~RemovableDeviceNotificationsLinux(); 72 virtual ~StorageMonitorLinux();
73 73
74 virtual void OnFilePathChanged(const base::FilePath& path, bool error); 74 virtual void OnFilePathChanged(const base::FilePath& path, bool error);
75 75
76 private: 76 private:
77 friend class base::RefCountedThreadSafe<RemovableDeviceNotificationsLinux>; 77 friend class base::RefCountedThreadSafe<StorageMonitorLinux>;
78 friend class base::DeleteHelper<RemovableDeviceNotificationsLinux>; 78 friend class base::DeleteHelper<StorageMonitorLinux>;
79 friend struct content::BrowserThread::DeleteOnThread< 79 friend struct content::BrowserThread::DeleteOnThread<
80 content::BrowserThread::FILE>; 80 content::BrowserThread::FILE>;
81 81
82 // Structure to save mounted device information such as device path, unique 82 // Structure to save mounted device information such as device path, unique
83 // identifier, device name and partition size. 83 // identifier, device name and partition size.
84 struct MountPointInfo { 84 struct MountPointInfo {
85 MountPointInfo(); 85 MountPointInfo();
86 86
87 base::FilePath mount_device; 87 base::FilePath mount_device;
88 std::string device_id; 88 std::string device_id;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // Keep in mind on Linux, a device can be mounted at multiple mount points, 134 // Keep in mind on Linux, a device can be mounted at multiple mount points,
135 // and multiple devices can be mounted at a mount point. 135 // and multiple devices can be mounted at a mount point.
136 MountMap mount_info_map_; 136 MountMap mount_info_map_;
137 137
138 // Because a device can be mounted to multiple places, we only want to 138 // Because a device can be mounted to multiple places, we only want to
139 // notify about one of them. If (and only if) that one is unmounted, we need 139 // notify about one of them. If (and only if) that one is unmounted, we need
140 // to notify about it's departure and notify about another one of it's mount 140 // to notify about it's departure and notify about another one of it's mount
141 // points. 141 // points.
142 MountPriorityMap mount_priority_map_; 142 MountPriorityMap mount_priority_map_;
143 143
144 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsLinux); 144 DISALLOW_COPY_AND_ASSIGN(StorageMonitorLinux);
145 }; 145 };
146 146
147 } // namespace chrome 147 } // namespace chrome
148 148
149 #endif // CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H _ 149 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698