Index: webkit/fileapi/local_file_system_operation.cc |
diff --git a/webkit/fileapi/local_file_system_operation.cc b/webkit/fileapi/local_file_system_operation.cc |
index bbae406692db1add95a27a128df7c1a6cbc86a24..445d5d22c791e0b6f3bed7e9735f35e4fac39a37 100644 |
--- a/webkit/fileapi/local_file_system_operation.cc |
+++ b/webkit/fileapi/local_file_system_operation.cc |
@@ -5,7 +5,7 @@ |
#include "webkit/fileapi/local_file_system_operation.h" |
#include "base/bind.h" |
-#include "base/sequenced_task_runner.h" |
+#include "base/single_thread_task_runner.h" |
#include "base/time.h" |
#include "base/utf_string_conversions.h" |
#include "net/base/escape.h" |
@@ -16,6 +16,7 @@ |
#include "webkit/fileapi/file_system_mount_point_provider.h" |
#include "webkit/fileapi/file_system_operation_context.h" |
#include "webkit/fileapi/file_system_quota_util.h" |
+#include "webkit/fileapi/file_system_task_runners.h" |
#include "webkit/fileapi/file_system_types.h" |
#include "webkit/fileapi/file_system_url.h" |
#include "webkit/fileapi/file_system_util.h" |
@@ -28,6 +29,24 @@ using webkit_blob::ShareableFileReference; |
namespace fileapi { |
+namespace { |
+ |
+bool IsMediaFileSystemType(FileSystemType type) { |
+ return type == kFileSystemTypeNativeMedia || |
+ type == kFileSystemTypeDeviceMedia; |
+} |
+ |
+base::PlatformFileError AllowCrossOperation(FileSystemType src_type, |
kinuko
2012/08/06 19:00:14
This function name doesn't sound like a check func
tzik
2012/08/06 20:09:01
Done.
|
+ FileSystemType dest_type) { |
+ // If two types are supposed to run on different task runners we should not |
+ // allow cross FileUtil operations at this layer. |
+ return IsMediaFileSystemType(src_type) == IsMediaFileSystemType(dest_type) ? |
+ base::PLATFORM_FILE_OK : |
+ base::PLATFORM_FILE_ERROR_INVALID_OPERATION; |
+} |
+ |
+} // namespace |
+ |
class LocalFileSystemOperation::ScopedQuotaNotifier { |
public: |
ScopedQuotaNotifier(FileSystemContext* context, |
@@ -118,6 +137,8 @@ void LocalFileSystemOperation::Copy(const FileSystemURL& src_url, |
base::PlatformFileError result = SetUp(src_url, &src_util_, SETUP_FOR_READ); |
if (result == base::PLATFORM_FILE_OK) |
result = SetUp(dest_url, &dest_util_, SETUP_FOR_CREATE); |
+ if (result == base::PLATFORM_FILE_OK) |
+ result = AllowCrossOperation(src_url.type(), dest_url.type()); |
if (result != base::PLATFORM_FILE_OK) { |
callback.Run(result); |
delete this; |
@@ -140,6 +161,8 @@ void LocalFileSystemOperation::Move(const FileSystemURL& src_url, |
base::PlatformFileError result = SetUp(src_url, &src_util_, SETUP_FOR_WRITE); |
if (result == base::PLATFORM_FILE_OK) |
result = SetUp(dest_url, &dest_util_, SETUP_FOR_CREATE); |
+ if (result == base::PLATFORM_FILE_OK) |
+ result = AllowCrossOperation(src_url.type(), dest_url.type()); |
if (result != base::PLATFORM_FILE_OK) { |
callback.Run(result); |
return; |
@@ -684,7 +707,7 @@ void LocalFileSystemOperation::DidCreateSnapshotFile( |
snapshot_policy == FileSystemFileUtil::kSnapshotFileTemporary) { |
file_ref = ShareableFileReference::GetOrCreate( |
platform_path, ShareableFileReference::DELETE_ON_FINAL_RELEASE, |
- file_system_context()->file_task_runner()); |
+ file_system_context()->task_runners()->file_task_runner()); |
} |
callback.Run(result, file_info, platform_path, file_ref); |
} |