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

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: 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
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 d197dfd4cb1fec30ddb9294fd49d7ee93a182702..d3ee2fbe6933b26ea058ceb37a7ef810a76c366b 100644
--- a/webkit/fileapi/local_file_system_operation.cc
+++ b/webkit/fileapi/local_file_system_operation.cc
@@ -26,6 +26,24 @@
namespace fileapi {
+namespace {
+
+bool IsMediaFileSystemType(FileSystemType type) {
+ return type == kFileSystemTypeNativeMedia ||
+ type == kFileSystemTypeDeviceMedia;
+}
+
+// TODO(tzik): Cleanup this.
+base::PlatformFileError IsCompatibleFileSystemPair(FileSystemType src_type,
kinuko 2012/08/03 23:13:39 nit: IsCrossOperationAllowed(src, dest) ...? Also
tzik 2012/08/04 00:24:21 Done.
+ FileSystemType dest_type) {
+ return IsMediaFileSystemType(src_type) == IsMediaFileSystemType(dest_type) ?
+ base::PLATFORM_FILE_OK :
+ base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
+
kinuko 2012/08/03 23:13:39 nit: extra empty line
tzik 2012/08/04 00:24:21 Done.
+}
+
+} // namespace
+
class LocalFileSystemOperation::ScopedQuotaNotifier {
public:
ScopedQuotaNotifier(FileSystemContext* context,
@@ -116,6 +134,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 = IsCompatibleFileSystemPair(src_url.type(), dest_url.type());
if (result != base::PLATFORM_FILE_OK) {
callback.Run(result);
delete this;
@@ -138,6 +158,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 = IsCompatibleFileSystemPair(src_url.type(), dest_url.type());
if (result != base::PLATFORM_FILE_OK) {
callback.Run(result);
return;

Powered by Google App Engine
This is Rietveld 408576698