Chromium Code Reviews| Index: webkit/fileapi/media/mtp_device_interface_impl_linux.cc |
| diff --git a/webkit/fileapi/media/mtp_device_interface_impl_linux.cc b/webkit/fileapi/media/mtp_device_interface_impl_linux.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..06d3b088eaa5393f0e25dc45e10cdd00b508b0b8 |
| --- /dev/null |
| +++ b/webkit/fileapi/media/mtp_device_interface_impl_linux.cc |
| @@ -0,0 +1,95 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "webkit/fileapi/media/mtp_device_interface_impl_linux.h" |
| + |
| +#include "base/sequenced_task_runner.h" |
| + |
| +namespace fileapi { |
| + |
| +MtpDeviceInterfaceImplLinux::MtpDeviceInterfaceImplLinux( |
| + const FilePath::StringType& device_id, |
| + base::SequencedTaskRunner* media_task_runner) |
| + : device_id_(device_id), |
| + media_task_runner_(media_task_runner) { |
| + // Initialize the device in LazyInit() function. |
| + // This object is constructed on IO thread. |
| +} |
| + |
| +MtpDeviceInterfaceImplLinux::~MtpDeviceInterfaceImplLinux() { |
| + // 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.
|
| + // This object is destructed by media_task_runner. |
| +} |
| + |
| +bool MtpDeviceInterfaceImplLinux::LazyInit() { |
| + if (!media_task_runner_->RunsTasksOnCurrentThread()) |
| + return false; |
| + |
| + // TODO(kmadhusu, thestig): Open the device for communication. If is already |
| + // opened, return. |
| + return true; |
| +} |
| + |
| +void MtpDeviceInterfaceImplLinux::DeleteOnCorrectThread() const { |
| + media_task_runner_->DeleteSoon(FROM_HERE, this); |
| +} |
| + |
| + |
| +PlatformFileError MtpDeviceInterfaceImplLinux::GetFileInfo( |
| + const FilePath& file_path, |
| + PlatformFileInfo* file_info) { |
| + if (!LazyInit()) |
| + return base::PLATFORM_FILE_ERROR_SECURITY; |
| + |
| + NOTIMPLEMENTED(); |
| + return base::PLATFORM_FILE_ERROR_SECURITY; |
| +} |
| + |
| +FileSystemFileUtil::AbstractFileEnumerator* |
| + MtpDeviceInterfaceImplLinux::CreateFileEnumerator( |
| + const FilePath& root, |
| + bool recursive) { |
| + if (!LazyInit()) |
| + return new FileSystemFileUtil::EmptyFileEnumerator(); |
| + |
| + NOTIMPLEMENTED(); |
| + return new FileSystemFileUtil::EmptyFileEnumerator(); |
| +} |
| + |
| +PlatformFileError MtpDeviceInterfaceImplLinux::Touch( |
| + const FilePath& file_path, |
| + const base::Time& last_access_time, |
| + const base::Time& last_modified_time) { |
| + if (!LazyInit()) |
| + return base::PLATFORM_FILE_ERROR_SECURITY; |
| + |
| + NOTIMPLEMENTED(); |
| + return base::PLATFORM_FILE_ERROR_SECURITY; |
| +} |
| + |
| +bool MtpDeviceInterfaceImplLinux::PathExists(const FilePath& file_path) { |
| + if (!LazyInit()) |
| + return false; |
| + |
| + NOTIMPLEMENTED(); |
| + return false; |
| +} |
| + |
| +bool MtpDeviceInterfaceImplLinux::DirectoryExists(const FilePath& file_path) { |
| + if (!LazyInit()) |
| + return false; |
| + |
| + NOTIMPLEMENTED(); |
| + return false; |
| +} |
| + |
| +bool MtpDeviceInterfaceImplLinux::IsDirectoryEmpty(const FilePath& file_path) { |
| + if (!LazyInit()) |
| + return false; |
| + |
| + NOTIMPLEMENTED(); |
| + return true; |
| +} |
| + |
| +} // namespace fileapi |