Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Unified Diff: webkit/fileapi/local_file_system_operation.cc

Issue 10829147: Make MediaFileUtil run on thread pool. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix for windows Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/fileapi/isolated_mount_point_provider.cc ('k') | webkit/fileapi/local_file_system_test_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2f5a5e7923e97ae10f113c7835c9299cc204c1f4 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,22 @@ using webkit_blob::ShareableFileReference;
namespace fileapi {
+namespace {
+
+bool IsMediaFileSystemType(FileSystemType type) {
+ return type == kFileSystemTypeNativeMedia ||
+ type == kFileSystemTypeDeviceMedia;
+}
+
+bool IsCrossOperationAllowed(FileSystemType src_type,
+ 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);
+}
+
+} // namespace
+
class LocalFileSystemOperation::ScopedQuotaNotifier {
public:
ScopedQuotaNotifier(FileSystemContext* context,
@@ -118,6 +135,10 @@ 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) {
+ if (!IsCrossOperationAllowed(src_url.type(), dest_url.type()))
+ result = base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
+ }
if (result != base::PLATFORM_FILE_OK) {
callback.Run(result);
delete this;
@@ -140,6 +161,10 @@ 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) {
+ if (!IsCrossOperationAllowed(src_url.type(), dest_url.type()))
+ result = base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
+ }
if (result != base::PLATFORM_FILE_OK) {
callback.Run(result);
return;
@@ -684,7 +709,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);
}
« no previous file with comments | « webkit/fileapi/isolated_mount_point_provider.cc ('k') | webkit/fileapi/local_file_system_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698