Index: webkit/fileapi/media_file_util.cc |
diff --git a/webkit/fileapi/media_file_util.cc b/webkit/fileapi/media_file_util.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..541c422aed003c506c989d6cd28dea8416bb6cde |
--- /dev/null |
+++ b/webkit/fileapi/media_file_util.cc |
@@ -0,0 +1,202 @@ |
+// 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_file_util.h" |
+ |
+#include "base/memory/scoped_ptr.h" |
+#include "webkit/blob/shareable_file_reference.h" |
+#include "webkit/fileapi/file_system_operation_context.h" |
+#include "webkit/fileapi/file_system_url.h" |
+#include "webkit/fileapi/media_device_map_service.h" |
+#include "webkit/fileapi/isolated_context.h" |
+ |
+#if defined(OS_WIN) |
+#include "webkit/fileapi/mtp_device_interface_win.h" |
+#elif defined(OS_POSIX) && !defined(OS_MACOSX) |
+#include "webkit/fileapi/mtp_device_interface_linux.h" |
+#endif |
+ |
+using base::PlatformFileError; |
+using base::PlatformFileInfo; |
+ |
+namespace fileapi { |
+ |
+namespace { |
+ |
+bool GetPlatformPathAndDeviceForUrl( |
kinuko
2012/07/26 00:38:06
Let's call GetMediaDevice in IsolatedMPP::CreateFi
kmadhusu
2012/07/27 02:13:41
Done.
|
+ const FileSystemURL& url, |
+ FilePath* platform_path, |
+ scoped_refptr<MediaDeviceInterfaceImpl>* device) { |
+ DCHECK(platform_path); |
+ std::string filesystem_id; |
+ if (!IsolatedContext::GetInstance()->CrackIsolatedPath( |
+ url.path(), &filesystem_id, NULL, platform_path)) { |
+ return false; |
+ } |
+ |
+ FilePath root_path; |
+ if (!IsolatedContext::GetInstance()->GetRegisteredPath(filesystem_id, |
+ &root_path)) { |
+ return false; |
+ } |
+ |
+ if (!MediaDeviceMapService::GetInstance()->GetMediaDevice(root_path.value(), |
+ device)) { |
+ return false; |
+ } |
+ return true; |
+} |
+ |
+} // namespace |
+ |
+ |
+MediaFileUtil::MediaFileUtil() { |
+} |
+ |
+PlatformFileError MediaFileUtil::CreateOrOpen( |
+ FileSystemOperationContext* context, |
+ const FileSystemURL& url, int file_flags, |
+ PlatformFile* file_handle, bool* created) { |
+ return base::PLATFORM_FILE_ERROR_SECURITY; |
+} |
+ |
+PlatformFileError MediaFileUtil::Close( |
+ FileSystemOperationContext* context, |
+ PlatformFile file_handle) { |
+ // We don't allow open thus Close won't be called. |
+ return base::PLATFORM_FILE_ERROR_SECURITY; |
+} |
+ |
+PlatformFileError MediaFileUtil::EnsureFileExists( |
+ FileSystemOperationContext* context, |
+ const FileSystemURL& url, |
+ bool* created) { |
+ return base::PLATFORM_FILE_ERROR_SECURITY; |
+} |
+ |
+PlatformFileError MediaFileUtil::CreateDirectory( |
+ FileSystemOperationContext* context, |
+ const FileSystemURL& url, |
+ bool exclusive, |
+ bool recursive) { |
+ return base::PLATFORM_FILE_ERROR_SECURITY; |
+} |
+ |
+PlatformFileError MediaFileUtil::GetFileInfo( |
+ FileSystemOperationContext* context, |
+ const FileSystemURL& url, |
+ PlatformFileInfo* file_info, |
+ FilePath* platform_path) { |
+ scoped_refptr<MediaDeviceInterfaceImpl> device; |
+ if (!GetPlatformPathAndDeviceForUrl(url, platform_path, &device)) |
+ return base::PLATFORM_FILE_ERROR_INVALID_URL; |
+ return device->GetFileInfo(*platform_path, file_info); |
+} |
+ |
+FileSystemFileUtil::AbstractFileEnumerator* |
+MediaFileUtil::CreateFileEnumerator( |
+ FileSystemOperationContext* context, |
+ const FileSystemURL& url, |
+ bool recursive) { |
+ FilePath platform_path; |
+ scoped_refptr<MediaDeviceInterfaceImpl> device; |
+ if (!GetPlatformPathAndDeviceForUrl(url, &platform_path, &device)) |
+ return new FileSystemFileUtil::EmptyFileEnumerator(); |
+ return device->CreateFileEnumerator(platform_path, recursive); |
+} |
+ |
+PlatformFileError MediaFileUtil::GetLocalFilePath( |
+ FileSystemOperationContext* context, |
+ const FileSystemURL& file_system_url, |
+ FilePath* local_file_path) { |
+ return base::PLATFORM_FILE_ERROR_SECURITY; |
+} |
+ |
+PlatformFileError MediaFileUtil::Touch( |
+ FileSystemOperationContext* context, |
+ const FileSystemURL& url, |
+ const base::Time& last_access_time, |
+ const base::Time& last_modified_time) { |
+ FilePath platform_path; |
+ scoped_refptr<MediaDeviceInterfaceImpl> device; |
+ if (!GetPlatformPathAndDeviceForUrl(url, &platform_path, &device)) |
+ return base::PLATFORM_FILE_ERROR_INVALID_URL; |
+ return device->Touch(platform_path, last_access_time, last_modified_time); |
+} |
+ |
+PlatformFileError MediaFileUtil::Truncate( |
+ FileSystemOperationContext* context, |
+ const FileSystemURL& url, |
+ int64 length) { |
+ return base::PLATFORM_FILE_ERROR_SECURITY; |
+} |
+ |
+bool MediaFileUtil::PathExists( |
+ FileSystemOperationContext* context, |
+ const FileSystemURL& url) { |
+ FilePath platform_path; |
+ scoped_refptr<MediaDeviceInterfaceImpl> device; |
+ if (!GetPlatformPathAndDeviceForUrl(url, &platform_path, &device)) |
+ return false; |
+ return device->PathExists(platform_path); |
+} |
+ |
+bool MediaFileUtil::DirectoryExists( |
+ FileSystemOperationContext* context, |
+ const FileSystemURL& url) { |
+ FilePath platform_path; |
+ scoped_refptr<MediaDeviceInterfaceImpl> device; |
+ if (!GetPlatformPathAndDeviceForUrl(url, &platform_path, &device)) |
+ return false; |
+ return device->DirectoryExists(platform_path); |
+} |
+ |
+bool MediaFileUtil::IsDirectoryEmpty( |
+ FileSystemOperationContext* context, |
+ const FileSystemURL& url) { |
+ FilePath platform_path; |
+ scoped_refptr<MediaDeviceInterfaceImpl> device; |
+ if (!GetPlatformPathAndDeviceForUrl(url, &platform_path, &device)) |
+ return false; |
+ return device->IsDirectoryEmpty(platform_path); |
+} |
+ |
+PlatformFileError MediaFileUtil::CopyOrMoveFile( |
+ FileSystemOperationContext* context, |
+ const FileSystemURL& src_url, |
+ const FileSystemURL& dest_url, |
+ bool copy) { |
+ return base::PLATFORM_FILE_ERROR_SECURITY; |
+} |
+ |
+PlatformFileError MediaFileUtil::CopyInForeignFile( |
+ FileSystemOperationContext* context, |
+ const FilePath& src_file_path, |
+ const FileSystemURL& dest_url) { |
+ return base::PLATFORM_FILE_ERROR_SECURITY; |
+} |
+ |
+PlatformFileError MediaFileUtil::DeleteFile( |
+ FileSystemOperationContext* context, |
+ const FileSystemURL& url) { |
+ return base::PLATFORM_FILE_ERROR_SECURITY; |
+} |
+ |
+PlatformFileError MediaFileUtil::DeleteSingleDirectory( |
+ FileSystemOperationContext* context, |
+ const FileSystemURL& url) { |
+ return base::PLATFORM_FILE_ERROR_SECURITY; |
+} |
+ |
+scoped_refptr<webkit_blob::ShareableFileReference> |
+ MediaFileUtil::CreateSnapshotFile( |
+ FileSystemOperationContext* context, |
+ const FileSystemURL& url, |
+ base::PlatformFileError* result, |
+ base::PlatformFileInfo* file_info, |
+ FilePath* platform_path) { |
+ return NULL; |
+} |
+ |
+} // namespace fileapi |