Chromium Code Reviews| 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_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_LI NUX_H_ | 5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_LI NUX_H_ |
| 6 #define CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_LI NUX_H_ | 6 #define CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER_LI NUX_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 virtual ~MediaTransferProtocolDeviceObserverLinux(); | 33 virtual ~MediaTransferProtocolDeviceObserverLinux(); |
| 34 | 34 |
| 35 static MediaTransferProtocolDeviceObserverLinux* GetInstance(); | 35 static MediaTransferProtocolDeviceObserverLinux* GetInstance(); |
| 36 | 36 |
| 37 // Finds the storage that contains |path| and populates |storage_info|. | 37 // Finds the storage that contains |path| and populates |storage_info|. |
| 38 // Returns false if unable to find the storage. | 38 // Returns false if unable to find the storage. |
| 39 bool GetStorageInfoForPath( | 39 bool GetStorageInfoForPath( |
| 40 const FilePath& path, | 40 const FilePath& path, |
| 41 RemovableStorageNotifications::StorageInfo* storage_info) const; | 41 RemovableStorageNotifications::StorageInfo* storage_info) const; |
| 42 | 42 |
| 43 // Set the volume notifications object to be used when new | |
| 44 // MTP devices are found. | |
| 45 void SetNotifications(RemovableStorageNotifications::Receiver* notifications); | |
|
vandebo (ex-Chrome)
2013/01/31 23:51:29
Pass in constructor?
Greg Billock
2013/02/01 18:28:42
see above.
On 2013/01/31 23:51:29, vandebo wrote:
| |
| 46 | |
| 43 protected: | 47 protected: |
| 44 // Only used in unit tests. | 48 // Only used in unit tests. |
| 45 explicit MediaTransferProtocolDeviceObserverLinux( | 49 explicit MediaTransferProtocolDeviceObserverLinux( |
| 46 GetStorageInfoFunc get_storage_info_func); | 50 GetStorageInfoFunc get_storage_info_func); |
| 47 | 51 |
| 48 // device::MediaTransferProtocolManager::Observer implementation. | 52 // device::MediaTransferProtocolManager::Observer implementation. |
| 49 // Exposed for unit tests. | 53 // Exposed for unit tests. |
| 50 virtual void StorageChanged(bool is_attached, | 54 virtual void StorageChanged(bool is_attached, |
| 51 const std::string& storage_name) OVERRIDE; | 55 const std::string& storage_name) OVERRIDE; |
| 52 | 56 |
| 53 private: | 57 private: |
| 54 // Mapping of storage location and mtp storage info object. | 58 // Mapping of storage location and mtp storage info object. |
| 55 typedef std::map<std::string, RemovableStorageNotifications::StorageInfo> | 59 typedef std::map<std::string, RemovableStorageNotifications::StorageInfo> |
| 56 StorageLocationToInfoMap; | 60 StorageLocationToInfoMap; |
| 57 | 61 |
| 58 // Enumerate existing mtp storage devices. | 62 // Enumerate existing mtp storage devices. |
| 59 void EnumerateStorages(); | 63 void EnumerateStorages(); |
| 60 | 64 |
| 61 // Map of all attached mtp devices. | 65 // Map of all attached mtp devices. |
| 62 StorageLocationToInfoMap storage_map_; | 66 StorageLocationToInfoMap storage_map_; |
| 63 | 67 |
| 64 // Function handler to get storage information. This is useful to set a mock | 68 // Function handler to get storage information. This is useful to set a mock |
| 65 // handler for unit testing. | 69 // handler for unit testing. |
| 66 GetStorageInfoFunc get_storage_info_func_; | 70 GetStorageInfoFunc get_storage_info_func_; |
| 67 | 71 |
| 72 // The notifications object to use to signal newly attached devices. | |
|
vandebo (ex-Chrome)
2013/01/31 23:51:29
Note lifetime and todo to update when it changes.
Greg Billock
2013/02/01 18:28:43
Done.
| |
| 73 RemovableStorageNotifications::Receiver* notifications_; | |
| 74 | |
| 68 DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDeviceObserverLinux); | 75 DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDeviceObserverLinux); |
| 69 }; | 76 }; |
| 70 | 77 |
| 71 } // namespace chrome | 78 } // namespace chrome |
| 72 | 79 |
| 73 #endif // CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER _LINUX_H_ | 80 #endif // CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER _LINUX_H_ |
| OLD | NEW |