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

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

Issue 10917166: Extend the capability of SystemMonitor to support watching storage free space change (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Update and add unit test 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 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 // the SystemMonitor about the addition and deletion of media devices, and 6 // the SystemMonitor 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_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_ 9 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_
10 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_ 10 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_
(...skipping 19 matching lines...) Expand all
30 // Gets device information given a |device_path|. On success, fills in 30 // Gets device information given a |device_path|. On success, fills in
31 // |unique_id|, |name|, and |removable|. 31 // |unique_id|, |name|, and |removable|.
32 typedef void (*GetDeviceInfoFunc)(const FilePath& device_path, 32 typedef void (*GetDeviceInfoFunc)(const FilePath& device_path,
33 std::string* unique_id, string16* name, 33 std::string* unique_id, string16* name,
34 bool* removable); 34 bool* removable);
35 35
36 namespace chrome { 36 namespace chrome {
37 37
38 class RemovableDeviceNotificationsLinux 38 class RemovableDeviceNotificationsLinux
39 : public base::RefCountedThreadSafe<RemovableDeviceNotificationsLinux, 39 : public base::RefCountedThreadSafe<RemovableDeviceNotificationsLinux,
40 content::BrowserThread::DeleteOnFileThread> { 40 content::BrowserThread::DeleteOnFileThread>,
41 public base::SystemMonitor::StorageFreeSpaceDelegate {
41 public: 42 public:
42 // Should only be called by browser start up code. Use GetInstance() instead. 43 // Should only be called by browser start up code. Use GetInstance() instead.
43 explicit RemovableDeviceNotificationsLinux(const FilePath& path); 44 explicit RemovableDeviceNotificationsLinux(const FilePath& path);
44 45
45 static RemovableDeviceNotificationsLinux* GetInstance(); 46 static RemovableDeviceNotificationsLinux* GetInstance();
46 47
47 // Must be called for RemovableDeviceNotificationsLinux to work. 48 // Must be called for RemovableDeviceNotificationsLinux to work.
48 void Init(); 49 void Init();
49 50
50 // Use |device_id| to find and return where the device is mounted. 51 // Use |device_id| to find and return where the device is mounted.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // Do initialization on the File Thread. 102 // Do initialization on the File Thread.
102 void InitOnFileThread(); 103 void InitOnFileThread();
103 104
104 // Parses mtab file and find all changes. 105 // Parses mtab file and find all changes.
105 void UpdateMtab(); 106 void UpdateMtab();
106 107
107 // Adds |mount_device| as mounted on |mount_point|. If the device is a new 108 // Adds |mount_device| as mounted on |mount_point|. If the device is a new
108 // device SystemMonitor is notified. 109 // device SystemMonitor is notified.
109 void AddNewMount(const FilePath& mount_device, const FilePath& mount_point); 110 void AddNewMount(const FilePath& mount_device, const FilePath& mount_point);
110 111
112 // Overriden from SystemMonitor::StorageFreeSpaceDelegate.
113 virtual void StartWatchingStorage(const FilePath& path) OVERRIDE;
114 virtual void StopWatchingStorage(const FilePath& path) OVERRIDE;
115
111 // Whether Init() has been called or not. 116 // Whether Init() has been called or not.
112 bool initialized_; 117 bool initialized_;
113 118
114 // Mtab file that lists the mount points. 119 // Mtab file that lists the mount points.
115 const FilePath mtab_path_; 120 const FilePath mtab_path_;
116 121
117 // Watcher for |mtab_path_|. 122 // Watcher for |mtab_path_|.
118 base::files::FilePathWatcher file_watcher_; 123 base::files::FilePathWatcher file_watcher_;
119 124
120 // Set of known file systems that we care about. 125 // Set of known file systems that we care about.
(...skipping 13 matching lines...) Expand all
134 // to notify about it's departure and notify about another one of it's mount 139 // to notify about it's departure and notify about another one of it's mount
135 // points. 140 // points.
136 MountPriorityMap mount_priority_map_; 141 MountPriorityMap mount_priority_map_;
137 142
138 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsLinux); 143 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsLinux);
139 }; 144 };
140 145
141 } // namespace chrome 146 } // namespace chrome
142 147
143 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_ 148 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698