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 namespace fileapi { | |
| 10 | |
| 11 MtpDeviceInterfaceImplLinux::MtpDeviceInterfaceImplLinux( | |
| 12 const FilePath::StringType& device_id, | |
| 13 base::SequencedTaskRunner* media_task_runner) | |
| 14 : device_id_(device_id), | |
| 15 media_task_runner_(media_task_runner) { | |
| 16 // Initialize the device in LazyInit() function. | |
| 17 // This object is constructed on IO thread. | |
| 18 } | |
| 19 | |
| 20 MtpDeviceInterfaceImplLinux::~MtpDeviceInterfaceImplLinux() { | |
| 21 // Do the clean up in DeleteOnCurrentThread() function. | |
|
kinuko
2012/07/28 02:29:59
nit: Current -> Correct
kmadhusu
2012/07/28 23:15:30
Done.
| |
| 22 // This object is destructed by media_task_runner. | |
| 23 } | |
| 24 | |
| 25 bool MtpDeviceInterfaceImplLinux::LazyInit() { | |
| 26 if (!media_task_runner_->RunsTasksOnCurrentThread()) | |
| 27 return false; | |
| 28 | |
| 29 // TODO(kmadhusu, thestig): Open the device for communication. If is already | |
| 30 // opened, return. | |
| 31 return true; | |
| 32 } | |
| 33 | |
| 34 void MtpDeviceInterfaceImplLinux::DeleteOnCorrectThread() const { | |
| 35 media_task_runner_->DeleteSoon(FROM_HERE, this); | |
| 36 } | |
| 37 | |
| 38 | |
| 39 PlatformFileError MtpDeviceInterfaceImplLinux::GetFileInfo( | |
| 40 const FilePath& file_path, | |
| 41 PlatformFileInfo* file_info) { | |
| 42 if (!LazyInit()) | |
| 43 return base::PLATFORM_FILE_ERROR_SECURITY; | |
| 44 | |
| 45 NOTIMPLEMENTED(); | |
| 46 return base::PLATFORM_FILE_ERROR_SECURITY; | |
| 47 } | |
| 48 | |
| 49 FileSystemFileUtil::AbstractFileEnumerator* | |
| 50 MtpDeviceInterfaceImplLinux::CreateFileEnumerator( | |
| 51 const FilePath& root, | |
| 52 bool recursive) { | |
| 53 if (!LazyInit()) | |
| 54 return new FileSystemFileUtil::EmptyFileEnumerator(); | |
| 55 | |
| 56 NOTIMPLEMENTED(); | |
| 57 return new FileSystemFileUtil::EmptyFileEnumerator(); | |
| 58 } | |
| 59 | |
| 60 PlatformFileError MtpDeviceInterfaceImplLinux::Touch( | |
| 61 const FilePath& file_path, | |
| 62 const base::Time& last_access_time, | |
| 63 const base::Time& last_modified_time) { | |
| 64 if (!LazyInit()) | |
| 65 return base::PLATFORM_FILE_ERROR_SECURITY; | |
| 66 | |
| 67 NOTIMPLEMENTED(); | |
| 68 return base::PLATFORM_FILE_ERROR_SECURITY; | |
| 69 } | |
| 70 | |
| 71 bool MtpDeviceInterfaceImplLinux::PathExists(const FilePath& file_path) { | |
| 72 if (!LazyInit()) | |
| 73 return false; | |
| 74 | |
| 75 NOTIMPLEMENTED(); | |
| 76 return false; | |
| 77 } | |
| 78 | |
| 79 bool MtpDeviceInterfaceImplLinux::DirectoryExists(const FilePath& file_path) { | |
| 80 if (!LazyInit()) | |
| 81 return false; | |
| 82 | |
| 83 NOTIMPLEMENTED(); | |
| 84 return false; | |
| 85 } | |
| 86 | |
| 87 bool MtpDeviceInterfaceImplLinux::IsDirectoryEmpty(const FilePath& file_path) { | |
| 88 if (!LazyInit()) | |
| 89 return false; | |
| 90 | |
| 91 NOTIMPLEMENTED(); | |
| 92 return true; | |
| 93 } | |
| 94 | |
| 95 } // namespace fileapi | |
| OLD | NEW |