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_MEDIA_DEVICE_MAP_SERVICE_H_ | |
6 #define WEBKIT_FILEAPI_MEDIA_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 #include "webkit/fileapi/media/media_device_interface_impl.h" | |
15 | |
16 namespace base { | |
17 class SequencedTaskRunner; | |
18 } | |
19 | |
20 namespace fileapi { | |
21 | |
22 // Helper class to manage media device interfaces. | |
23 class FILEAPI_EXPORT MediaDeviceMapService { | |
24 public: | |
25 static MediaDeviceMapService* GetInstance(); | |
26 | |
27 // Create or get media device interface associated with |filesystem_id|. | |
28 // Return NULL on failure. This function is called on IO thread. | |
kinuko
2012/08/02 04:27:05
nit: 'Return NULL if the filesystem_id is no longe
kmadhusu
2012/08/02 16:59:03
Done.
| |
29 MediaDeviceInterfaceImpl* CreateOrGetMediaDevice( | |
30 const std::string& filesystem_id, | |
31 base::SequencedTaskRunner* media_task_runner); | |
32 | |
33 // This function is called on UI thread. | |
34 void RemoveMediaDevice(const FilePath::StringType& device_location); | |
35 | |
36 private: | |
37 friend struct DefaultSingletonTraits<MediaDeviceMapService>; | |
38 | |
39 typedef scoped_refptr<MediaDeviceInterfaceImpl> MediaDeviceRefPtr; | |
40 typedef std::map<FilePath::StringType, MediaDeviceRefPtr> MediaDeviceMap; | |
41 | |
42 // Get access to this class using GetInstance() method. | |
43 MediaDeviceMapService(); | |
44 ~MediaDeviceMapService(); | |
45 | |
46 base::Lock media_device_map_lock_; | |
47 | |
48 // Store a map of attached mtp devices. | |
49 // Key: Device location. | |
50 // Value: MtpDeviceInterface. | |
51 MediaDeviceMap media_device_map_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(MediaDeviceMapService); | |
54 }; | |
55 | |
56 } // namespace fileapi | |
57 | |
58 #endif // WEBKIT_FILEAPI_MEDIA_MEDIA_DEVICE_MAP_SERVICE_H_ | |
OLD | NEW |