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_CHROMEOS_MTP_MTP_DEV_MANAGER_OBSERVER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_MTP_MTP_DEV_MANAGER_OBSERVER_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 | |
11 #include "base/string16.h" | |
Lei Zhang
2012/08/29 23:11:15
nit: alphabetical order
kmadhusu
2012/08/30 02:07:50
Done.
| |
12 #include "base/memory/ref_counted.h" | |
13 #include "chrome/browser/chromeos/mtp/media_transfer_protocol_manager.h" | |
14 | |
15 namespace chromeos { | |
16 namespace mtp { | |
17 | |
18 // Gets the mtp device information given a |storage_name|. On success, | |
19 // fills in |id|, |name| and |location|. | |
20 typedef void (*GetStorageInfoFunc)(const std::string& storage_name, | |
21 std::string* id, | |
Lei Zhang
2012/08/29 23:11:15
nit: indentation
kmadhusu
2012/08/30 02:07:50
Done.
| |
22 string16* name, | |
23 std::string* location); | |
24 | |
25 // Helper class to send MTP storage attachment and detachment events to | |
26 // SystemMonitor. | |
27 class MtpDevManagerObserver | |
Lei Zhang
2012/08/29 23:11:15
Can you be consistent with the name and call this
kmadhusu
2012/08/30 02:07:50
Done.
| |
28 : public base::RefCountedThreadSafe<MtpDevManagerObserver>, | |
Lei Zhang
2012/08/29 23:11:15
Why does this need to be RefCountedThreadSafe?
kmadhusu
2012/08/30 02:07:50
RefCounting is not required here. Fixed.
| |
29 public MediaTransferProtocolManager::Observer { | |
30 public: | |
31 MtpDevManagerObserver(); | |
32 | |
33 // Only used in unit tests. | |
34 explicit MtpDevManagerObserver(GetStorageInfoFunc get_storage_info_func); | |
35 | |
36 // MediaTransferProtocolManager::Observer implementation. | |
37 // Exposed for unit tests. | |
38 virtual void StorageChanged(bool is_attached, | |
39 const std::string& storage_name) OVERRIDE; | |
40 | |
41 private: | |
42 friend class base::RefCountedThreadSafe<MtpDevManagerObserver>; | |
43 | |
44 // Mapping of storage name and unique id. | |
45 typedef std::map<std::string, std::string> StorageNameAndIdMap; | |
46 | |
47 // Private to avoid code deleting the object. | |
48 virtual ~MtpDevManagerObserver(); | |
49 | |
50 // Enumerate existing mtp storage devices. | |
51 void EnumerateStorages(); | |
52 | |
53 // Map of all attached mtp devices. | |
54 StorageNameAndIdMap storage_map_; | |
55 | |
56 // Function handler to get storage information. This is useful to set a mock | |
57 // handler for unit testing. | |
58 GetStorageInfoFunc get_storage_info_func_; | |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(MtpDevManagerObserver); | |
61 }; | |
62 | |
63 } // namespace mtp | |
64 } // namespace chromeos | |
65 | |
66 #endif // CHROME_BROWSER_CHROMEOS_MTP_MTP_DEV_MANAGER_OBSERVER_H_ | |
OLD | NEW |