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

Unified Diff: webkit/fileapi/file_util_helper.cc

Issue 10834167: Create ShareableFileReference on IO thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adding unknown policy for DCHECK 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/file_system_file_util_proxy.cc ('k') | webkit/fileapi/local_file_system_operation.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/file_util_helper.cc
diff --git a/webkit/fileapi/file_util_helper.cc b/webkit/fileapi/file_util_helper.cc
index a8ddb4cf3829d7793243e9b2f04c744b05bec249..651220b4272bd84d7606812283331e1ee545b5d7 100644
--- a/webkit/fileapi/file_util_helper.cc
+++ b/webkit/fileapi/file_util_helper.cc
@@ -6,7 +6,6 @@
#include <stack>
-#include "webkit/blob/shareable_file_reference.h"
#include "webkit/fileapi/file_system_file_util.h"
#include "webkit/fileapi/file_system_operation_context.h"
#include "webkit/fileapi/file_system_url.h"
@@ -17,6 +16,18 @@ namespace fileapi {
namespace {
+// A helper class to delete a temporary file.
+class ScopedFileDeleter {
+ public:
+ explicit ScopedFileDeleter(const FilePath& path) : path_(path) {}
+ ~ScopedFileDeleter() {
+ file_util::Delete(path_, false /* recursive */);
+ }
+
+ private:
+ FilePath path_;
+};
+
// A helper class for cross-FileUtil Copy/Move operations.
class CrossFileUtilHelper {
public:
@@ -250,14 +261,17 @@ PlatformFileError CrossFileUtilHelper::CopyOrMoveFile(
// Resolve the src_url's underlying file path.
base::PlatformFileInfo file_info;
FilePath platform_file_path;
- PlatformFileError error = base::PLATFORM_FILE_OK;
+ FileSystemFileUtil::SnapshotFilePolicy snapshot_policy;
- scoped_refptr<webkit_blob::ShareableFileReference> file_ref =
- src_util_->CreateSnapshotFile(context_, src_url,
- &error, &file_info, &platform_file_path);
+ PlatformFileError error = src_util_->CreateSnapshotFile(
+ context_, src_url, &file_info, &platform_file_path, &snapshot_policy);
if (error != base::PLATFORM_FILE_OK)
return error;
+ scoped_ptr<ScopedFileDeleter> file_deleter;
+ if (snapshot_policy == FileSystemFileUtil::kSnapshotFileTemporary)
+ file_deleter.reset(new ScopedFileDeleter(platform_file_path));
+
// Call CopyInForeignFile() on the dest_util_ with the resolved source path
// to perform limited cross-FileSystemFileUtil copy/move.
error = dest_util_->CopyInForeignFile(
« no previous file with comments | « webkit/fileapi/file_system_file_util_proxy.cc ('k') | webkit/fileapi/local_file_system_operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698