| 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_MTP_DEVICE_MAP_SERVICE_H_ | |
| 6 #define WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_MAP_SERVICE_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/files/file_path.h" | |
| 11 #include "base/lazy_instance.h" | |
| 12 #include "base/threading/thread_checker.h" | |
| 13 #include "webkit/storage/webkit_storage_export.h" | |
| 14 | |
| 15 namespace fileapi { | |
| 16 | |
| 17 class MTPDeviceAsyncDelegate; | |
| 18 | |
| 19 // This class provides media transfer protocol (MTP) device delegate to | |
| 20 // complete media file system operations. ScopedMTPDeviceMapEntry class | |
| 21 // manages the device map entries. | |
| 22 class WEBKIT_STORAGE_EXPORT MTPDeviceMapService { | |
| 23 public: | |
| 24 static MTPDeviceMapService* GetInstance(); | |
| 25 | |
| 26 ///////////////////////////////////////////////////////////////////////////// | |
| 27 // Following methods are used to manage MTPDeviceAsyncDelegate objects. // | |
| 28 ///////////////////////////////////////////////////////////////////////////// | |
| 29 // Adds the MTP device delegate to the map service. |device_location| | |
| 30 // specifies the mount location of the MTP device. | |
| 31 // Called on the IO thread. | |
| 32 void AddAsyncDelegate(const base::FilePath::StringType& device_location, | |
| 33 MTPDeviceAsyncDelegate* delegate); | |
| 34 | |
| 35 // Removes the MTP device delegate from the map service. |device_location| | |
| 36 // specifies the mount location of the MTP device. | |
| 37 // Called on the IO thread. | |
| 38 void RemoveAsyncDelegate(const base::FilePath::StringType& device_location); | |
| 39 | |
| 40 // Gets the media device delegate associated with |filesystem_id|. | |
| 41 // Return NULL if the |filesystem_id| is no longer valid (e.g. because the | |
| 42 // corresponding device is detached, etc). | |
| 43 // Called on the IO thread. | |
| 44 MTPDeviceAsyncDelegate* GetMTPDeviceAsyncDelegate( | |
| 45 const std::string& filesystem_id); | |
| 46 | |
| 47 private: | |
| 48 friend struct base::DefaultLazyInstanceTraits<MTPDeviceMapService>; | |
| 49 | |
| 50 // Mapping of device_location and MTPDeviceAsyncDelegate* object. It is safe | |
| 51 // to store and access the raw pointer. This class operates on the IO thread. | |
| 52 typedef std::map<base::FilePath::StringType, MTPDeviceAsyncDelegate*> | |
| 53 AsyncDelegateMap; | |
| 54 | |
| 55 // Get access to this class using GetInstance() method. | |
| 56 MTPDeviceMapService(); | |
| 57 ~MTPDeviceMapService(); | |
| 58 | |
| 59 ///////////////////////////////////////////////////////////////////////////// | |
| 60 // Following member variables are used to manage asynchronous // | |
| 61 // MTP device delegate objects. // | |
| 62 ///////////////////////////////////////////////////////////////////////////// | |
| 63 // Map of attached mtp device async delegates. | |
| 64 AsyncDelegateMap async_delegate_map_; | |
| 65 base::ThreadChecker thread_checker_; | |
| 66 | |
| 67 DISALLOW_COPY_AND_ASSIGN(MTPDeviceMapService); | |
| 68 }; | |
| 69 | |
| 70 } // namespace fileapi | |
| 71 | |
| 72 #endif // WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_MAP_SERVICE_H_ | |
| OLD | NEW |