Chromium Code Reviews| 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 #include "webkit/fileapi/media/mtp_device_interface_impl_linux.h" | |
| 6 | |
| 7 #include "base/sequenced_task_runner.h" | |
| 8 | |
| 9 using base::PlatformFileError; | |
| 10 using base::PlatformFileInfo; | |
| 11 using base::Time; | |
| 12 | |
| 13 namespace fileapi { | |
| 14 | |
| 15 MtpDeviceInterfaceImplLinux::MtpDeviceInterfaceImplLinux( | |
| 16 const FilePath::StringType& device_id, | |
| 17 base::SequencedTaskRunner* media_task_runner) | |
| 18 : device_id_(device_id), | |
| 19 media_task_runner_(media_task_runner) { | |
| 20 // Initialize the device in LazyInit() function. | |
| 21 // This object is constructed on IO thread. | |
| 22 } | |
| 23 | |
| 24 MtpDeviceInterfaceImplLinux::~MtpDeviceInterfaceImplLinux() { | |
| 25 // Do the clean up in DeleteOnCorrectThread() function. | |
| 26 // This object must be destructed on media_task_runner. | |
| 27 } | |
| 28 | |
| 29 bool MtpDeviceInterfaceImplLinux::LazyInit() { | |
| 30 DCHECK(media_task_runner_->RunsTasksOnCurrentThread()); | |
| 31 | |
| 32 // TODO(kmadhusu, thestig): Open the device for communication. If is already | |
| 33 // opened, return. | |
| 34 return true; | |
| 35 } | |
| 36 | |
| 37 void MtpDeviceInterfaceImplLinux::DeleteOnCorrectThread() const { | |
| 38 if (!media_task_runner_->RunsTasksOnCurrentThread()) { | |
| 39 media_task_runner_->DeleteSoon(FROM_HERE, this); | |
| 40 return; | |
| 41 } | |
| 42 delete this; | |
| 43 } | |
| 44 | |
| 45 PlatformFileError MtpDeviceInterfaceImplLinux::GetFileInfo( | |
| 46 const FilePath& file_path, | |
| 47 PlatformFileInfo* file_info) { | |
| 48 if (!LazyInit()) | |
| 49 return base::PLATFORM_FILE_ERROR_SECURITY; | |
| 50 | |
| 51 NOTIMPLEMENTED(); | |
| 52 return base::PLATFORM_FILE_ERROR_SECURITY; | |
| 53 } | |
| 54 | |
| 55 FileSystemFileUtil::AbstractFileEnumerator* | |
| 56 MtpDeviceInterfaceImplLinux::CreateFileEnumerator( | |
|
kinuko
2012/07/31 20:32:31
style-nit:
LongReturnType*
LongClassName::LongMet
kmadhusu
2012/08/01 01:43:59
Done.
| |
| 57 const FilePath& root, | |
| 58 bool recursive) { | |
| 59 if (!LazyInit()) | |
| 60 return new FileSystemFileUtil::EmptyFileEnumerator(); | |
| 61 | |
| 62 NOTIMPLEMENTED(); | |
| 63 return new FileSystemFileUtil::EmptyFileEnumerator(); | |
| 64 } | |
| 65 | |
| 66 PlatformFileError MtpDeviceInterfaceImplLinux::Touch( | |
| 67 const FilePath& file_path, | |
| 68 const base::Time& last_access_time, | |
| 69 const base::Time& last_modified_time) { | |
| 70 if (!LazyInit()) | |
| 71 return base::PLATFORM_FILE_ERROR_SECURITY; | |
| 72 | |
| 73 NOTIMPLEMENTED(); | |
| 74 return base::PLATFORM_FILE_ERROR_SECURITY; | |
| 75 } | |
| 76 | |
| 77 bool MtpDeviceInterfaceImplLinux::PathExists(const FilePath& file_path) { | |
| 78 if (!LazyInit()) | |
| 79 return false; | |
| 80 | |
| 81 NOTIMPLEMENTED(); | |
| 82 return false; | |
| 83 } | |
| 84 | |
| 85 bool MtpDeviceInterfaceImplLinux::DirectoryExists(const FilePath& file_path) { | |
| 86 if (!LazyInit()) | |
| 87 return false; | |
| 88 | |
| 89 NOTIMPLEMENTED(); | |
| 90 return false; | |
| 91 } | |
| 92 | |
| 93 bool MtpDeviceInterfaceImplLinux::IsDirectoryEmpty(const FilePath& file_path) { | |
| 94 if (!LazyInit()) | |
| 95 return false; | |
| 96 | |
| 97 NOTIMPLEMENTED(); | |
| 98 return true; | |
| 99 } | |
| 100 | |
| 101 PlatformFileError MtpDeviceInterfaceImplLinux::CreateSnapshotFile( | |
| 102 const FilePath& device_file_path, | |
| 103 const FilePath& local_path, | |
| 104 PlatformFileInfo* file_info) { | |
| 105 if (!LazyInit()) | |
| 106 return base::PLATFORM_FILE_ERROR_FAILED; | |
| 107 | |
| 108 // Write the device_file_path data to local_path file and set the file_info | |
| 109 // accordingly. | |
| 110 | |
| 111 NOTIMPLEMENTED(); | |
| 112 return base::PLATFORM_FILE_ERROR_FAILED; | |
| 113 } | |
| 114 | |
| 115 } // namespace fileapi | |
| OLD | NEW |