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

Unified Diff: webkit/fileapi/transient_file_util.cc

Issue 14493007: Add Transient FileSystem which goes away after its snapsot file is gone (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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/transient_file_util.h ('k') | webkit/fileapi/transient_file_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/transient_file_util.cc
diff --git a/webkit/fileapi/transient_file_util.cc b/webkit/fileapi/transient_file_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d78ff5e37c8168ee639047277efbcb1c45696e77
--- /dev/null
+++ b/webkit/fileapi/transient_file_util.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2013 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/transient_file_util.h"
+
+#include <string>
+
+#include "base/bind.h"
+#include "base/files/file_path.h"
+#include "webkit/fileapi/file_system_operation_context.h"
+#include "webkit/fileapi/file_system_url.h"
+#include "webkit/fileapi/isolated_context.h"
+
+using webkit_blob::ScopedFile;
+
+namespace fileapi {
+
+namespace {
+
+void RevokeFileSystem(const std::string& filesystem_id,
+ const base::FilePath& /*path*/) {
+ IsolatedContext::GetInstance()->RevokeFileSystem(filesystem_id);
+}
+
+} // namespace
+
+ScopedFile TransientFileUtil::CreateSnapshotFile(
+ FileSystemOperationContext* context,
+ const FileSystemURL& url,
+ base::PlatformFileError* error,
+ base::PlatformFileInfo* file_info,
+ base::FilePath* platform_path) {
+ DCHECK(file_info);
+ *error = GetFileInfo(context, url, file_info, platform_path);
+ if (*error == base::PLATFORM_FILE_OK && file_info->is_directory)
+ *error = base::PLATFORM_FILE_ERROR_NOT_A_FILE;
+ if (*error != base::PLATFORM_FILE_OK)
+ return ScopedFile();
+
+ // Sets-up a transient filesystem.
+ DCHECK(!platform_path->empty());
+ DCHECK(!url.filesystem_id().empty());
+
+ ScopedFile scoped_file(
+ *platform_path,
+ ScopedFile::DELETE_ON_SCOPE_OUT,
+ context->task_runner());
+ scoped_file.AddScopeOutCallback(
+ base::Bind(&RevokeFileSystem, url.filesystem_id()), NULL);
+
+ return scoped_file.Pass();
+}
+
+} // namespace fileapi
« no previous file with comments | « webkit/fileapi/transient_file_util.h ('k') | webkit/fileapi/transient_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698