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_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_LINUX
_H_ | 5 #ifndef COMPONENTS_STORAGE_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_LINUX
_H_ |
6 #define COMPONENTS_STORAGE_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_LINUX
_H_ | 6 #define COMPONENTS_STORAGE_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_LINUX
_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 base::string16* product_name); | 30 base::string16* product_name); |
31 | 31 |
32 // Helper class to send MTP storage attachment and detachment events to | 32 // Helper class to send MTP storage attachment and detachment events to |
33 // StorageMonitor. | 33 // StorageMonitor. |
34 class MediaTransferProtocolDeviceObserverLinux | 34 class MediaTransferProtocolDeviceObserverLinux |
35 : public device::MediaTransferProtocolManager::Observer { | 35 : public device::MediaTransferProtocolManager::Observer { |
36 public: | 36 public: |
37 MediaTransferProtocolDeviceObserverLinux( | 37 MediaTransferProtocolDeviceObserverLinux( |
38 StorageMonitor::Receiver* receiver, | 38 StorageMonitor::Receiver* receiver, |
39 device::MediaTransferProtocolManager* mtp_manager); | 39 device::MediaTransferProtocolManager* mtp_manager); |
40 virtual ~MediaTransferProtocolDeviceObserverLinux(); | 40 ~MediaTransferProtocolDeviceObserverLinux() override; |
41 | 41 |
42 // Finds the storage that contains |path| and populates |storage_info|. | 42 // Finds the storage that contains |path| and populates |storage_info|. |
43 // Returns false if unable to find the storage. | 43 // Returns false if unable to find the storage. |
44 bool GetStorageInfoForPath(const base::FilePath& path, | 44 bool GetStorageInfoForPath(const base::FilePath& path, |
45 StorageInfo* storage_info) const; | 45 StorageInfo* storage_info) const; |
46 | 46 |
47 void EjectDevice(const std::string& device_id, | 47 void EjectDevice(const std::string& device_id, |
48 base::Callback<void(StorageMonitor::EjectStatus)> callback); | 48 base::Callback<void(StorageMonitor::EjectStatus)> callback); |
49 | 49 |
50 protected: | 50 protected: |
51 // Only used in unit tests. | 51 // Only used in unit tests. |
52 MediaTransferProtocolDeviceObserverLinux( | 52 MediaTransferProtocolDeviceObserverLinux( |
53 StorageMonitor::Receiver* receiver, | 53 StorageMonitor::Receiver* receiver, |
54 device::MediaTransferProtocolManager* mtp_manager, | 54 device::MediaTransferProtocolManager* mtp_manager, |
55 GetStorageInfoFunc get_storage_info_func); | 55 GetStorageInfoFunc get_storage_info_func); |
56 | 56 |
57 // device::MediaTransferProtocolManager::Observer implementation. | 57 // device::MediaTransferProtocolManager::Observer implementation. |
58 // Exposed for unit tests. | 58 // Exposed for unit tests. |
59 virtual void StorageChanged(bool is_attached, | 59 void StorageChanged(bool is_attached, |
60 const std::string& storage_name) override; | 60 const std::string& storage_name) override; |
61 | 61 |
62 private: | 62 private: |
63 // Mapping of storage location and mtp storage info object. | 63 // Mapping of storage location and mtp storage info object. |
64 typedef std::map<std::string, StorageInfo> StorageLocationToInfoMap; | 64 typedef std::map<std::string, StorageInfo> StorageLocationToInfoMap; |
65 | 65 |
66 // Enumerate existing mtp storage devices. | 66 // Enumerate existing mtp storage devices. |
67 void EnumerateStorages(); | 67 void EnumerateStorages(); |
68 | 68 |
69 // Find the |storage_map_| key for the record with this |device_id|. Returns | 69 // Find the |storage_map_| key for the record with this |device_id|. Returns |
70 // true on success, false on failure. | 70 // true on success, false on failure. |
(...skipping 14 matching lines...) Expand all Loading... |
85 // The notifications object to use to signal newly attached devices. | 85 // The notifications object to use to signal newly attached devices. |
86 // Guaranteed to outlive this class. | 86 // Guaranteed to outlive this class. |
87 StorageMonitor::Receiver* const notifications_; | 87 StorageMonitor::Receiver* const notifications_; |
88 | 88 |
89 DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDeviceObserverLinux); | 89 DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDeviceObserverLinux); |
90 }; | 90 }; |
91 | 91 |
92 } // namespace storage_monitor | 92 } // namespace storage_monitor |
93 | 93 |
94 #endif // COMPONENTS_STORAGE_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_LI
NUX_H_ | 94 #endif // COMPONENTS_STORAGE_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_LI
NUX_H_ |
OLD | NEW |