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