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 WEBKIT_FILEAPI_MEDIA_DEVICE_MAP_SERVICE_H_ | |
6 #define WEBKIT_FILEAPI_MEDIA_DEVICE_MAP_SERVICE_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #include "base/file_path.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "base/memory/singleton.h" | |
13 #include "base/synchronization/lock.h" | |
14 | |
15 namespace fileapi { | |
16 | |
17 #if defined(OS_WIN) | |
18 class MtpDeviceInterfaceWin; | |
19 typedef class MtpDeviceInterfaceWin MediaDevice; | |
20 #elif defined(OS_POSIX) && !defined(OS_MACOSX) | |
21 class MtpDeviceInterfaceLinux; | |
22 typedef class MtpDeviceInterfaceLinux MediaDevice; | |
23 #endif | |
24 | |
25 // Helper class to manage MTP device interfaces. | |
26 class MediaDeviceMapService { | |
kmadhusu
2012/07/23 17:58:47
This class needs a better name. How about MediaDev
| |
27 public: | |
28 static MediaDeviceMapService* GetInstance(); | |
29 | |
30 void AddMediaDevice(const FilePath::StringType& device_id); | |
31 | |
32 // TODO(kmadhusu): Implement a media device detached observer and remove the | |
33 // media device from the map. | |
34 void RemoveMediaDevice(const FilePath::StringType& device_id); | |
35 bool GetMediaDevice(const FilePath::StringType& device_id, | |
36 scoped_refptr<MediaDevice>* device); | |
37 | |
38 private: | |
39 MediaDeviceMapService(); | |
40 ~MediaDeviceMapService(); | |
41 | |
42 friend struct DefaultSingletonTraits<MediaDeviceMapService>; | |
43 | |
44 typedef scoped_refptr<MediaDevice> MediaDeviceRefPtr; | |
45 typedef std::map<FilePath::StringType, MediaDeviceRefPtr> MediaDeviceMap; | |
46 | |
47 base::Lock media_device_map_lock_; | |
48 | |
49 // Store a map of attached mtp devices. | |
50 // Key: Device id. | |
51 // Value: MtpDeviceInterface. | |
52 MediaDeviceMap media_device_map_; | |
53 | |
54 DISALLOW_COPY_AND_ASSIGN(MediaDeviceMapService); | |
55 }; | |
56 | |
57 } // namespace fileapi | |
58 | |
59 #endif // WEBKIT_FILEAPI_MEDIA_DEVICE_MAP_SERVICE_H_ | |
OLD | NEW |