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_INTERFACE_IMPL_LINUX_H_ |
| 6 #define WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_INTERFACE_IMPL_LINUX_H_ |
| 7 |
| 8 #include "base/file_path.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/platform_file.h" |
| 11 #include "base/sequenced_task_runner_helpers.h" |
| 12 #include "base/timer.h" |
| 13 #include "webkit/fileapi/file_system_file_util.h" |
| 14 #include "webkit/fileapi/media/media_device_interface.h" |
| 15 |
| 16 namespace base { |
| 17 struct PlatformFileInfo; |
| 18 class SequencedTaskRunner; |
| 19 class Time; |
| 20 } |
| 21 |
| 22 namespace fileapi { |
| 23 |
| 24 using base::PlatformFileError; |
| 25 using base::PlatformFileInfo; |
| 26 using base::RefCountedThreadSafe; |
| 27 using base::Time; |
| 28 using base::SequencedTaskRunner; |
| 29 |
| 30 struct DefaultMtpDeviceInterfaceImplDeleter; |
| 31 |
| 32 // Helper class to support MTP device isolated file system operations. This |
| 33 // class contains platform specific code to communicate with the attached |
| 34 // MTP device. We instantiate this class per MTP device. MTP device is |
| 35 // opened for communication during initialization and closed during |
| 36 // destruction. |
| 37 class MtpDeviceInterfaceImplLinux : |
| 38 public MediaDeviceInterface, |
| 39 public RefCountedThreadSafe<MtpDeviceInterfaceImplLinux, |
| 40 DefaultMtpDeviceInterfaceImplDeleter> { |
| 41 public: |
| 42 MtpDeviceInterfaceImplLinux(const FilePath::StringType& device_id, |
| 43 SequencedTaskRunner* media_task_runner) OVERRIDE; |
| 44 |
| 45 // MediaDeviceInterface methods. |
| 46 virtual PlatformFileError GetFileInfo(const FilePath& file_path, |
| 47 PlatformFileInfo* file_info) OVERRIDE; |
| 48 |
| 49 virtual FileSystemFileUtil::AbstractFileEnumerator* CreateFileEnumerator( |
| 50 const FilePath& root, |
| 51 bool recursive) OVERRIDE; |
| 52 |
| 53 virtual PlatformFileError Touch(const FilePath& file_path, |
| 54 const Time& last_access_time, |
| 55 const Time& last_modified_time) OVERRIDE; |
| 56 |
| 57 virtual bool PathExists(const FilePath& file_path) OVERRIDE; |
| 58 virtual bool DirectoryExists(const FilePath& file_path) OVERRIDE; |
| 59 virtual bool IsDirectoryEmpty(const FilePath& file_path) OVERRIDE; |
| 60 |
| 61 private: |
| 62 friend struct DefaultMtpDeviceInterfaceImplDeleter; |
| 63 friend class base::DeleteHelper<MtpDeviceInterfaceImplLinux>; |
| 64 friend class RefCountedThreadSafe<MtpDeviceInterfaceImplLinux, |
| 65 DefaultMtpDeviceInterfaceImplDeleter>; |
| 66 |
| 67 virtual ~MtpDeviceInterfaceImplLinux(); |
| 68 void DeleteOnCorrectThread() const; |
| 69 |
| 70 // Device initialization should be done in |media_task_runner_|. |
| 71 bool LazyInit(); |
| 72 |
| 73 // Mtp device id. |
| 74 FilePath::StringType device_id_; |
| 75 scoped_refptr<SequencedTaskRunner> media_task_runner_; |
| 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(MtpDeviceInterfaceImplLinux); |
| 78 }; |
| 79 |
| 80 struct DefaultMtpDeviceInterfaceImplDeleter { |
| 81 static void Destruct(const MtpDeviceInterfaceImplLinux* device_impl) { |
| 82 device_impl->DeleteOnCorrectThread(); |
| 83 } |
| 84 }; |
| 85 |
| 86 } // namespace fileapi |
| 87 |
| 88 #endif // WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_INTERFACE_IMPL_LINUX_H_ |
OLD | NEW |