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..3a0ee215b811402f5f36ddd1f4df22f19e4aed56 |
--- /dev/null |
+++ b/webkit/fileapi/media/mtp_device_interface_impl_linux.cc |
@@ -0,0 +1,109 @@ |
+// 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 DeleteOnCorrectThread() function. |
+ // This object is destructed by media_task_runner. |
kinuko
2012/07/30 23:19:03
nit: is destructed by -> must be destructed on ?
kmadhusu
2012/07/31 01:17:48
Done.
|
+} |
+ |
+bool MtpDeviceInterfaceImplLinux::LazyInit() { |
+ if (!media_task_runner_->RunsTasksOnCurrentThread()) |
kinuko
2012/07/30 23:19:03
I think this must be DCHECK.
kmadhusu
2012/07/31 01:17:48
Done.
|
+ 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); |
kinuko
2012/07/30 23:19:03
nit: If we're already on media_task_runner we don'
kmadhusu
2012/07/31 01:17:48
Done.
|
+} |
+ |
kinuko
2012/07/30 23:19:03
nit: please remove extra empty line
kmadhusu
2012/07/31 01:17:48
Done.
|
+ |
+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; |
+} |
+ |
+bool MtpDeviceInterfaceImplLinux::CreateSnapshotFile( |
+ const FilePath& device_file_path, |
+ const FilePath& local_path, |
+ PlatformFileInfo* file_info) { |
+ if (!LazyInit()) |
+ return false; |
+ |
+ // Write the device_file_path data to local_path file and set the file_info |
+ // accordingly. |
+ |
+ NOTIMPLEMENTED(); |
+ return false; |
+} |
+ |
+} // namespace fileapi |