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

Side by Side Diff: chrome/browser/system_monitor/removable_device_notifications_mac.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 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_ 5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_
6 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_ 6 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_
7 7
8 #include <DiskArbitration/DiskArbitration.h> 8 #include <DiskArbitration/DiskArbitration.h>
9 #include <map> 9 #include <map>
10 10
11 #include "base/mac/scoped_cftyperef.h" 11 #include "base/mac/scoped_cftyperef.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/system_monitor/system_monitor.h" 13 #include "base/system_monitor/system_monitor.h"
14 #include "chrome/browser/system_monitor/disk_info_mac.h" 14 #include "chrome/browser/system_monitor/disk_info_mac.h"
15 15
16 namespace chrome { 16 namespace chrome {
17 17
18 // This class posts notifications to base::SystemMonitor when a new disk 18 // This class posts notifications to base::SystemMonitor when a new disk
19 // is attached, removed, or changed. 19 // is attached, removed, or changed.
20 class RemovableDeviceNotificationsMac : 20 class RemovableDeviceNotificationsMac :
21 public base::SupportsWeakPtr<RemovableDeviceNotificationsMac> { 21 public base::SupportsWeakPtr<RemovableDeviceNotificationsMac>,
22 public base::SystemMonitor::StorageFreeSpaceDelegate {
22 public: 23 public:
23 enum UpdateType { 24 enum UpdateType {
24 UPDATE_DEVICE_ADDED, 25 UPDATE_DEVICE_ADDED,
25 UPDATE_DEVICE_CHANGED, 26 UPDATE_DEVICE_CHANGED,
26 UPDATE_DEVICE_REMOVED, 27 UPDATE_DEVICE_REMOVED,
27 }; 28 };
28 29
29 RemovableDeviceNotificationsMac(); 30 RemovableDeviceNotificationsMac();
30 virtual ~RemovableDeviceNotificationsMac(); 31 virtual ~RemovableDeviceNotificationsMac();
31 32
32 void UpdateDisk(const DiskInfoMac& info, UpdateType update_type); 33 void UpdateDisk(const DiskInfoMac& info, UpdateType update_type);
33 34
34 bool GetDeviceInfoForPath( 35 bool GetDeviceInfoForPath(
35 const FilePath& path, 36 const FilePath& path,
36 base::SystemMonitor::RemovableStorageInfo* device_info) const; 37 base::SystemMonitor::RemovableStorageInfo* device_info) const;
37 38
39 // Overriden from SystemMonitor::StorageFreeSpaceDelegate.
40 virtual void StartWatchingStorage(const FilePath& path) OVERRIDE;
41 virtual void StopWatchingStorage(const FilePath& path) OVERRIDE;
42
38 private: 43 private:
39 static void DiskAppearedCallback(DADiskRef disk, void* context); 44 static void DiskAppearedCallback(DADiskRef disk, void* context);
40 static void DiskDisappearedCallback(DADiskRef disk, void* context); 45 static void DiskDisappearedCallback(DADiskRef disk, void* context);
41 static void DiskDescriptionChangedCallback(DADiskRef disk, 46 static void DiskDescriptionChangedCallback(DADiskRef disk,
42 CFArrayRef keys, 47 CFArrayRef keys,
43 void *context); 48 void *context);
44 49
45 bool ShouldPostNotificationForDisk(const DiskInfoMac& info) const; 50 bool ShouldPostNotificationForDisk(const DiskInfoMac& info) const;
46 bool FindDiskWithMountPoint(const FilePath& mount_point, 51 bool FindDiskWithMountPoint(const FilePath& mount_point,
47 DiskInfoMac* info) const; 52 DiskInfoMac* info) const;
48 53
49 base::mac::ScopedCFTypeRef<DASessionRef> session_; 54 base::mac::ScopedCFTypeRef<DASessionRef> session_;
50 // Maps disk bsd names to disk info objects. This map tracks all mountable 55 // Maps disk bsd names to disk info objects. This map tracks all mountable
51 // devices on the system though only notifications for removable devices are 56 // devices on the system though only notifications for removable devices are
52 // posted. 57 // posted.
53 std::map<std::string, DiskInfoMac> disk_info_map_; 58 std::map<std::string, DiskInfoMac> disk_info_map_;
54 59
55 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsMac); 60 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsMac);
56 }; 61 };
57 62
58 } // namespace chrome 63 } // namespace chrome
59 64
60 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_ 65 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698