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 if the |filesystem_id| is no longer valid (e.g. because the |
| 29 // corresponding device is detached etc). This function is called on IO |
| 30 // thread. |
| 31 MediaDeviceInterfaceImpl* CreateOrGetMediaDevice( |
| 32 const std::string& filesystem_id, |
| 33 base::SequencedTaskRunner* media_task_runner); |
| 34 |
| 35 // This function is called on UI thread. |
| 36 void RemoveMediaDevice(const FilePath::StringType& device_location); |
| 37 |
| 38 private: |
| 39 friend struct DefaultSingletonTraits<MediaDeviceMapService>; |
| 40 |
| 41 typedef scoped_refptr<MediaDeviceInterfaceImpl> MediaDeviceRefPtr; |
| 42 typedef std::map<FilePath::StringType, MediaDeviceRefPtr> MediaDeviceMap; |
| 43 |
| 44 // Get access to this class using GetInstance() method. |
| 45 MediaDeviceMapService(); |
| 46 ~MediaDeviceMapService(); |
| 47 |
| 48 base::Lock media_device_map_lock_; |
| 49 |
| 50 // Store a map of attached mtp devices. |
| 51 // Key: Device location. |
| 52 // Value: MtpDeviceInterface. |
| 53 MediaDeviceMap media_device_map_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(MediaDeviceMapService); |
| 56 }; |
| 57 |
| 58 } // namespace fileapi |
| 59 |
| 60 #endif // WEBKIT_FILEAPI_MEDIA_MEDIA_DEVICE_MAP_SERVICE_H_ |
OLD | NEW |