OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_MAC_H_ | 5 #ifndef COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_MAC_H_ |
6 #define COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_MAC_H_ | 6 #define COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_MAC_H_ |
7 | 7 |
8 #include <DiskArbitration/DiskArbitration.h> | 8 #include <DiskArbitration/DiskArbitration.h> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 public: | 23 public: |
24 enum UpdateType { | 24 enum UpdateType { |
25 UPDATE_DEVICE_ADDED, | 25 UPDATE_DEVICE_ADDED, |
26 UPDATE_DEVICE_CHANGED, | 26 UPDATE_DEVICE_CHANGED, |
27 UPDATE_DEVICE_REMOVED, | 27 UPDATE_DEVICE_REMOVED, |
28 }; | 28 }; |
29 | 29 |
30 // 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. |
31 StorageMonitorMac(); | 31 StorageMonitorMac(); |
32 | 32 |
33 virtual ~StorageMonitorMac(); | 33 ~StorageMonitorMac() override; |
34 | 34 |
35 virtual void Init() override; | 35 void Init() override; |
36 | 36 |
37 void UpdateDisk(const std::string& bsd_name, | 37 void UpdateDisk(const std::string& bsd_name, |
38 const StorageInfo& info, | 38 const StorageInfo& info, |
39 UpdateType update_type); | 39 UpdateType update_type); |
40 | 40 |
41 virtual bool GetStorageInfoForPath( | 41 bool GetStorageInfoForPath(const base::FilePath& path, |
42 const base::FilePath& path, | 42 StorageInfo* device_info) const override; |
43 StorageInfo* device_info) const override; | |
44 | 43 |
45 virtual void EjectDevice( | 44 void EjectDevice(const std::string& device_id, |
46 const std::string& device_id, | 45 base::Callback<void(EjectStatus)> callback) override; |
47 base::Callback<void(EjectStatus)> callback) override; | |
48 | 46 |
49 private: | 47 private: |
50 static void DiskAppearedCallback(DADiskRef disk, void* context); | 48 static void DiskAppearedCallback(DADiskRef disk, void* context); |
51 static void DiskDisappearedCallback(DADiskRef disk, void* context); | 49 static void DiskDisappearedCallback(DADiskRef disk, void* context); |
52 static void DiskDescriptionChangedCallback(DADiskRef disk, | 50 static void DiskDescriptionChangedCallback(DADiskRef disk, |
53 CFArrayRef keys, | 51 CFArrayRef keys, |
54 void *context); | 52 void *context); |
55 void GetDiskInfoAndUpdate(DADiskRef disk, UpdateType update_type); | 53 void GetDiskInfoAndUpdate(DADiskRef disk, UpdateType update_type); |
56 | 54 |
57 bool ShouldPostNotificationForDisk(const StorageInfo& info) const; | 55 bool ShouldPostNotificationForDisk(const StorageInfo& info) const; |
58 bool FindDiskWithMountPoint(const base::FilePath& mount_point, | 56 bool FindDiskWithMountPoint(const base::FilePath& mount_point, |
59 StorageInfo* info) const; | 57 StorageInfo* info) const; |
60 | 58 |
61 base::ScopedCFTypeRef<DASessionRef> session_; | 59 base::ScopedCFTypeRef<DASessionRef> session_; |
62 // Maps disk bsd names to disk info objects. This map tracks all mountable | 60 // Maps disk bsd names to disk info objects. This map tracks all mountable |
63 // devices on the system, though only notifications for removable devices are | 61 // devices on the system, though only notifications for removable devices are |
64 // posted. | 62 // posted. |
65 std::map<std::string, StorageInfo> disk_info_map_; | 63 std::map<std::string, StorageInfo> disk_info_map_; |
66 | 64 |
67 int pending_disk_updates_; | 65 int pending_disk_updates_; |
68 | 66 |
69 scoped_ptr<ImageCaptureDeviceManager> image_capture_device_manager_; | 67 scoped_ptr<ImageCaptureDeviceManager> image_capture_device_manager_; |
70 | 68 |
71 DISALLOW_COPY_AND_ASSIGN(StorageMonitorMac); | 69 DISALLOW_COPY_AND_ASSIGN(StorageMonitorMac); |
72 }; | 70 }; |
73 | 71 |
74 } // namespace storage_monitor | 72 } // namespace storage_monitor |
75 | 73 |
76 #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_MAC_H_ | 74 #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_MAC_H_ |
OLD | NEW |