| OLD | NEW |
| 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/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/system_monitor/system_monitor.h" | |
| 14 #include "chrome/browser/system_monitor/disk_info_mac.h" | 13 #include "chrome/browser/system_monitor/disk_info_mac.h" |
| 15 #include "chrome/browser/system_monitor/removable_storage_notifications.h" | 14 #include "chrome/browser/system_monitor/removable_storage_notifications.h" |
| 16 | 15 |
| 17 namespace chrome { | 16 namespace chrome { |
| 18 | 17 |
| 19 // This class posts notifications to base::SystemMonitor when a new disk | 18 // This class posts notifications to listeners when a new disk |
| 20 // is attached, removed, or changed. | 19 // is attached, removed, or changed. |
| 21 class RemovableDeviceNotificationsMac | 20 class RemovableDeviceNotificationsMac |
| 22 : public RemovableStorageNotifications, | 21 : public RemovableStorageNotifications, |
| 23 public base::RefCountedThreadSafe<RemovableDeviceNotificationsMac> { | 22 public base::RefCountedThreadSafe<RemovableDeviceNotificationsMac> { |
| 24 public: | 23 public: |
| 25 enum UpdateType { | 24 enum UpdateType { |
| 26 UPDATE_DEVICE_ADDED, | 25 UPDATE_DEVICE_ADDED, |
| 27 UPDATE_DEVICE_CHANGED, | 26 UPDATE_DEVICE_CHANGED, |
| 28 UPDATE_DEVICE_REMOVED, | 27 UPDATE_DEVICE_REMOVED, |
| 29 }; | 28 }; |
| 30 | 29 |
| 31 // Should only be called by browser start up code. Use GetInstance() instead. | 30 // Should only be called by browser start up code. Use GetInstance() instead. |
| 32 RemovableDeviceNotificationsMac(); | 31 RemovableDeviceNotificationsMac(); |
| 33 | 32 |
| 34 void UpdateDisk(const DiskInfoMac& info, UpdateType update_type); | 33 void UpdateDisk(const DiskInfoMac& info, UpdateType update_type); |
| 35 | 34 |
| 36 virtual bool GetDeviceInfoForPath( | 35 virtual bool GetDeviceInfoForPath( |
| 37 const FilePath& path, | 36 const FilePath& path, |
| 38 base::SystemMonitor::RemovableStorageInfo* device_info) const OVERRIDE; | 37 StorageInfo* device_info) const OVERRIDE; |
| 39 | 38 |
| 40 // Returns the storage size of the device present at |location|. If the | 39 // Returns the storage size of the device present at |location|. If the |
| 41 // device information is unavailable, returns zero. |location| must be a | 40 // device information is unavailable, returns zero. |location| must be a |
| 42 // top-level mount point. | 41 // top-level mount point. |
| 43 virtual uint64 GetStorageSize(const std::string& location) const OVERRIDE; | 42 virtual uint64 GetStorageSize(const std::string& location) const OVERRIDE; |
| 44 | 43 |
| 45 private: | 44 private: |
| 46 friend class base::RefCountedThreadSafe<RemovableDeviceNotificationsMac>; | 45 friend class base::RefCountedThreadSafe<RemovableDeviceNotificationsMac>; |
| 47 virtual ~RemovableDeviceNotificationsMac(); | 46 virtual ~RemovableDeviceNotificationsMac(); |
| 48 | 47 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 61 // devices on the system though only notifications for removable devices are | 60 // devices on the system though only notifications for removable devices are |
| 62 // posted. | 61 // posted. |
| 63 std::map<std::string, DiskInfoMac> disk_info_map_; | 62 std::map<std::string, DiskInfoMac> disk_info_map_; |
| 64 | 63 |
| 65 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsMac); | 64 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsMac); |
| 66 }; | 65 }; |
| 67 | 66 |
| 68 } // namespace chrome | 67 } // namespace chrome |
| 69 | 68 |
| 70 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_ | 69 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_MAC_H_ |
| OLD | NEW |