Chromium Code Reviews| 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 // This function is called on IO thread. | |
| 28 void MaybeAddMediaDevice(const FilePath::StringType& device_id, | |
| 29 base::SequencedTaskRunner* media_task_runner); | |
| 30 | |
| 31 // This function is called on UI thread. | |
| 32 void RemoveMediaDevice(const FilePath::StringType& device_id); | |
| 33 | |
| 34 // This function is called on IO thread. Returns NULL on failure. | |
| 35 MediaDeviceInterfaceImpl* GetMediaDevice( | |
| 36 const FilePath::StringType& device_id); | |
| 37 | |
| 38 private: | |
| 39 MediaDeviceMapService(); | |
|
Lei Zhang
2012/07/31 20:48:18
Add a note to say "access through GetInstance()"
kmadhusu
2012/08/01 01:43:59
Done.
| |
| 40 ~MediaDeviceMapService(); | |
| 41 | |
| 42 friend struct DefaultSingletonTraits<MediaDeviceMapService>; | |
|
Lei Zhang
2012/07/31 20:48:18
nit: friends and typedefs go above the ctor/dtor
kmadhusu
2012/08/01 01:43:59
Done.
| |
| 43 | |
| 44 typedef scoped_refptr<MediaDeviceInterfaceImpl> 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_MEDIA_DEVICE_MAP_SERVICE_H_ | |
| OLD | NEW |