| 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 24 matching lines...) Expand all Loading... |
| 35 virtual ~MediaTransferProtocolDeviceObserverLinux(); | 35 virtual ~MediaTransferProtocolDeviceObserverLinux(); |
| 36 | 36 |
| 37 static MediaTransferProtocolDeviceObserverLinux* GetInstance(); | 37 static MediaTransferProtocolDeviceObserverLinux* GetInstance(); |
| 38 | 38 |
| 39 // Finds the storage that contains |path| and populates |storage_info|. | 39 // Finds the storage that contains |path| and populates |storage_info|. |
| 40 // Returns false if unable to find the storage. | 40 // Returns false if unable to find the storage. |
| 41 bool GetStorageInfoForPath( | 41 bool GetStorageInfoForPath( |
| 42 const base::FilePath& path, | 42 const base::FilePath& path, |
| 43 RemovableStorageNotifications::StorageInfo* storage_info) const; | 43 RemovableStorageNotifications::StorageInfo* storage_info) const; |
| 44 | 44 |
| 45 // Set the volume notifications object to be used when new |
| 46 // MTP devices are found. |
| 47 void SetNotifications(RemovableStorageNotifications::Receiver* notifications); |
| 48 |
| 45 protected: | 49 protected: |
| 46 // Only used in unit tests. | 50 // Only used in unit tests. |
| 47 explicit MediaTransferProtocolDeviceObserverLinux( | 51 explicit MediaTransferProtocolDeviceObserverLinux( |
| 48 GetStorageInfoFunc get_storage_info_func); | 52 GetStorageInfoFunc get_storage_info_func); |
| 49 | 53 |
| 50 // device::MediaTransferProtocolManager::Observer implementation. | 54 // device::MediaTransferProtocolManager::Observer implementation. |
| 51 // Exposed for unit tests. | 55 // Exposed for unit tests. |
| 52 virtual void StorageChanged(bool is_attached, | 56 virtual void StorageChanged(bool is_attached, |
| 53 const std::string& storage_name) OVERRIDE; | 57 const std::string& storage_name) OVERRIDE; |
| 54 | 58 |
| 55 private: | 59 private: |
| 56 // Mapping of storage location and mtp storage info object. | 60 // Mapping of storage location and mtp storage info object. |
| 57 typedef std::map<std::string, RemovableStorageNotifications::StorageInfo> | 61 typedef std::map<std::string, RemovableStorageNotifications::StorageInfo> |
| 58 StorageLocationToInfoMap; | 62 StorageLocationToInfoMap; |
| 59 | 63 |
| 60 // Enumerate existing mtp storage devices. | 64 // Enumerate existing mtp storage devices. |
| 61 void EnumerateStorages(); | 65 void EnumerateStorages(); |
| 62 | 66 |
| 63 // Map of all attached mtp devices. | 67 // Map of all attached mtp devices. |
| 64 StorageLocationToInfoMap storage_map_; | 68 StorageLocationToInfoMap storage_map_; |
| 65 | 69 |
| 66 // Function handler to get storage information. This is useful to set a mock | 70 // Function handler to get storage information. This is useful to set a mock |
| 67 // handler for unit testing. | 71 // handler for unit testing. |
| 68 GetStorageInfoFunc get_storage_info_func_; | 72 GetStorageInfoFunc get_storage_info_func_; |
| 69 | 73 |
| 74 // The notifications object to use to signal newly attached devices. |
| 75 // Guaranteed to outlive this class. |
| 76 // TODO(gbillock): Edit this when this class is owned by a |
| 77 // RemovableStorageNotifications subclass. |
| 78 RemovableStorageNotifications::Receiver* notifications_; |
| 79 |
| 70 DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDeviceObserverLinux); | 80 DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDeviceObserverLinux); |
| 71 }; | 81 }; |
| 72 | 82 |
| 73 } // namespace chrome | 83 } // namespace chrome |
| 74 | 84 |
| 75 #endif // CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER
_LINUX_H_ | 85 #endif // CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER
_LINUX_H_ |
| OLD | NEW |