| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_ |
| 6 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_ |
| 7 |
| 8 #include <DiskArbitration/DiskArbitration.h> |
| 9 #include <map> |
| 10 |
| 11 #include "base/mac/scoped_cftyperef.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/system_monitor/system_monitor.h" |
| 14 #include "chrome/browser/system_monitor/disk_info_mac.h" |
| 15 |
| 16 namespace chrome { |
| 17 |
| 18 // This class posts notifications to base::SystemMonitor when a new disk |
| 19 // is attached, removed, or changed. |
| 20 class RemovableDeviceNotificationsMac : |
| 21 public base::SupportsWeakPtr<RemovableDeviceNotificationsMac> { |
| 22 public: |
| 23 enum UpdateType { |
| 24 UPDATE_DEVICE_ADDED, |
| 25 UPDATE_DEVICE_CHANGED, |
| 26 UPDATE_DEVICE_REMOVED, |
| 27 }; |
| 28 |
| 29 RemovableDeviceNotificationsMac(); |
| 30 virtual ~RemovableDeviceNotificationsMac(); |
| 31 |
| 32 void UpdateDisk(const DiskInfoMac& info, UpdateType update_type); |
| 33 |
| 34 bool GetDeviceInfoForPath( |
| 35 const FilePath& path, |
| 36 base::SystemMonitor::RemovableStorageInfo* device_info) const; |
| 37 |
| 38 private: |
| 39 static void DiskAppearedCallback(DADiskRef disk, void* context); |
| 40 static void DiskDisappearedCallback(DADiskRef disk, void* context); |
| 41 static void DiskDescriptionChangedCallback(DADiskRef disk, |
| 42 CFArrayRef keys, |
| 43 void *context); |
| 44 |
| 45 bool ShouldPostNotificationForDisk(const DiskInfoMac& info) const; |
| 46 bool FindDiskWithMountPoint(const FilePath& mount_point, |
| 47 DiskInfoMac* info) const; |
| 48 |
| 49 base::mac::ScopedCFTypeRef<DASessionRef> session_; |
| 50 // 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 |
| 52 // posted. |
| 53 std::map<std::string, DiskInfoMac> disk_info_map_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsMac); |
| 56 }; |
| 57 |
| 58 } // namespace chrome |
| 59 |
| 60 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_ |
| OLD | NEW |