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 |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "chrome/browser/system_monitor/removable_storage_notifications.h" | 12 #include "chrome/browser/system_monitor/removable_storage_notifications.h" |
13 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" | 13 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" |
14 | 14 |
| 15 namespace base { |
15 class FilePath; | 16 class FilePath; |
| 17 } |
16 | 18 |
17 namespace chrome { | 19 namespace chrome { |
18 | 20 |
19 // Gets the mtp device information given a |storage_name|. On success, | 21 // Gets the mtp device information given a |storage_name|. On success, |
20 // fills in |id|, |name| and |location|. | 22 // fills in |id|, |name| and |location|. |
21 typedef void (*GetStorageInfoFunc)(const std::string& storage_name, | 23 typedef void (*GetStorageInfoFunc)(const std::string& storage_name, |
22 std::string* id, | 24 std::string* id, |
23 string16* name, | 25 string16* name, |
24 std::string* location); | 26 std::string* location); |
25 | 27 |
26 // Helper class to send MTP storage attachment and detachment events to | 28 // Helper class to send MTP storage attachment and detachment events to |
27 // RemovableStorageNotifications. | 29 // RemovableStorageNotifications. |
28 class MediaTransferProtocolDeviceObserverLinux | 30 class MediaTransferProtocolDeviceObserverLinux |
29 : public device::MediaTransferProtocolManager::Observer { | 31 : public device::MediaTransferProtocolManager::Observer { |
30 public: | 32 public: |
31 // Should only be called by browser start up code. Use GetInstance() instead. | 33 // Should only be called by browser start up code. Use GetInstance() instead. |
32 MediaTransferProtocolDeviceObserverLinux(); | 34 MediaTransferProtocolDeviceObserverLinux(); |
33 virtual ~MediaTransferProtocolDeviceObserverLinux(); | 35 virtual ~MediaTransferProtocolDeviceObserverLinux(); |
34 | 36 |
35 static MediaTransferProtocolDeviceObserverLinux* GetInstance(); | 37 static MediaTransferProtocolDeviceObserverLinux* GetInstance(); |
36 | 38 |
37 // Finds the storage that contains |path| and populates |storage_info|. | 39 // Finds the storage that contains |path| and populates |storage_info|. |
38 // Returns false if unable to find the storage. | 40 // Returns false if unable to find the storage. |
39 bool GetStorageInfoForPath( | 41 bool GetStorageInfoForPath( |
40 const FilePath& path, | 42 const base::FilePath& path, |
41 RemovableStorageNotifications::StorageInfo* storage_info) const; | 43 RemovableStorageNotifications::StorageInfo* storage_info) const; |
42 | 44 |
43 protected: | 45 protected: |
44 // Only used in unit tests. | 46 // Only used in unit tests. |
45 explicit MediaTransferProtocolDeviceObserverLinux( | 47 explicit MediaTransferProtocolDeviceObserverLinux( |
46 GetStorageInfoFunc get_storage_info_func); | 48 GetStorageInfoFunc get_storage_info_func); |
47 | 49 |
48 // device::MediaTransferProtocolManager::Observer implementation. | 50 // device::MediaTransferProtocolManager::Observer implementation. |
49 // Exposed for unit tests. | 51 // Exposed for unit tests. |
50 virtual void StorageChanged(bool is_attached, | 52 virtual void StorageChanged(bool is_attached, |
(...skipping 13 matching lines...) Expand all Loading... |
64 // Function handler to get storage information. This is useful to set a mock | 66 // Function handler to get storage information. This is useful to set a mock |
65 // handler for unit testing. | 67 // handler for unit testing. |
66 GetStorageInfoFunc get_storage_info_func_; | 68 GetStorageInfoFunc get_storage_info_func_; |
67 | 69 |
68 DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDeviceObserverLinux); | 70 DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDeviceObserverLinux); |
69 }; | 71 }; |
70 | 72 |
71 } // namespace chrome | 73 } // namespace chrome |
72 | 74 |
73 #endif // CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER
_LINUX_H_ | 75 #endif // CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_TRANSFER_PROTOCOL_DEVICE_OBSERVER
_LINUX_H_ |
OLD | NEW |