Chromium Code Reviews| Index: webkit/fileapi/media_device_map_service.h |
| diff --git a/webkit/fileapi/media_device_map_service.h b/webkit/fileapi/media_device_map_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..04a5475b3e69d20037aa20144bb729f6dd33e51b |
| --- /dev/null |
| +++ b/webkit/fileapi/media_device_map_service.h |
| @@ -0,0 +1,59 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
|
kinuko
2012/07/25 23:22:28
A suggestion-- I think it'd be better to create a
kmadhusu
2012/07/27 02:13:40
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef WEBKIT_FILEAPI_MEDIA_DEVICE_MAP_SERVICE_H_ |
| +#define WEBKIT_FILEAPI_MEDIA_DEVICE_MAP_SERVICE_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/file_path.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/singleton.h" |
| +#include "base/synchronization/lock.h" |
| + |
| +namespace fileapi { |
| + |
| +#if defined(OS_WIN) |
| +class MtpDeviceInterfaceWin; |
| +typedef class MtpDeviceInterfaceWin MediaDeviceInterfaceImpl; |
| +#elif defined(OS_POSIX) && !defined(OS_MACOSX) |
| +class MtpDeviceInterfaceLinux; |
| +typedef class MtpDeviceInterfaceLinux MediaDeviceInterfaceImpl; |
| +#endif |
| + |
| +// Helper class to manage MTP device interfaces. |
| +class MediaDeviceMapService { |
| + public: |
| + static MediaDeviceMapService* GetInstance(); |
| + |
| + void AddMediaDevice(const FilePath::StringType& device_id); |
| + |
| + // TODO(kmadhusu): Implement a media device detached observer and remove the |
| + // media device from the map. |
| + void RemoveMediaDevice(const FilePath::StringType& device_id); |
| + bool GetMediaDevice(const FilePath::StringType& device_id, |
| + scoped_refptr<MediaDeviceInterfaceImpl>* device); |
| + |
| + private: |
| + MediaDeviceMapService(); |
| + ~MediaDeviceMapService(); |
| + |
| + friend struct DefaultSingletonTraits<MediaDeviceMapService>; |
| + |
| + typedef scoped_refptr<MediaDeviceInterfaceImpl> MediaDeviceRefPtr; |
| + typedef std::map<FilePath::StringType, MediaDeviceRefPtr> MediaDeviceMap; |
| + |
| + base::Lock media_device_map_lock_; |
| + |
| + // Store a map of attached mtp devices. |
| + // Key: Device id. |
| + // Value: MtpDeviceInterface. |
| + MediaDeviceMap media_device_map_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MediaDeviceMapService); |
| +}; |
| + |
| +} // namespace fileapi |
| + |
| +#endif // WEBKIT_FILEAPI_MEDIA_DEVICE_MAP_SERVICE_H_ |