OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_CHROMEOS_MEDIA_TRANSFER_PROTOCOL_DEVICE_OB SERVER_H_ | |
6 #define CHROME_BROWSER_SYSTEM_MONITOR_CHROMEOS_MEDIA_TRANSFER_PROTOCOL_DEVICE_OB SERVER_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 | |
11 #include "base/string16.h" | |
12 #include "chrome/browser/chromeos/mtp/media_transfer_protocol_manager.h" | |
13 | |
14 namespace chromeos { | |
15 namespace mtp { | |
16 | |
17 // Gets the mtp device information given a |storage_name|. On success, | |
18 // fills in |id|, |name| and |location|. | |
19 typedef void (*GetStorageInfoFunc)(const std::string& storage_name, | |
20 std::string* id, | |
21 string16* name, | |
22 std::string* location); | |
23 | |
24 // Helper class to send MTP storage attachment and detachment events to | |
25 // SystemMonitor. | |
26 class MediaTransferProtocolDeviceObserver | |
27 : public MediaTransferProtocolManager::Observer { | |
28 public: | |
29 MediaTransferProtocolDeviceObserver(); | |
30 | |
31 // Only used in unit tests. | |
Lei Zhang
2012/09/10 18:18:01
You can probably mark this and StorageChanged() as
kmadhusu
2012/09/11 01:50:19
Done.
| |
32 explicit MediaTransferProtocolDeviceObserver( | |
33 GetStorageInfoFunc get_storage_info_func); | |
34 | |
35 virtual ~MediaTransferProtocolDeviceObserver(); | |
36 | |
37 // MediaTransferProtocolManager::Observer implementation. | |
38 // Exposed for unit tests. | |
39 virtual void StorageChanged(bool is_attached, | |
40 const std::string& storage_name) OVERRIDE; | |
41 | |
42 private: | |
43 // Mapping of storage name and device id. | |
44 typedef std::map<std::string, std::string> StorageNameAndIdMap; | |
45 | |
46 // Enumerate existing mtp storage devices. | |
47 void EnumerateStorages(); | |
48 | |
49 // Map of all attached mtp devices. | |
50 StorageNameAndIdMap storage_map_; | |
51 | |
52 // Function handler to get storage information. This is useful to set a mock | |
53 // handler for unit testing. | |
54 GetStorageInfoFunc get_storage_info_func_; | |
55 | |
56 DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDeviceObserver); | |
57 }; | |
58 | |
59 } // namespace mtp | |
60 } // namespace chromeos | |
61 | |
62 #endif // CHROME_BROWSER_SYSTEM_MONITOR_CHROMEOS_MEDIA_TRANSFER_PROTOCOL_DEVICE _OBSERVER_H_ | |
OLD | NEW |