Remove support for GICE in CRD host and client
[chromium-blink-merge.git] / storage / browser / fileapi / transient_file_util.cc
blobc0c2a6b57309d1bceba1f3e5e575c18e1a73d206
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "storage/browser/fileapi/transient_file_util.h"
7 #include <string>
9 #include "base/bind.h"
10 #include "base/files/file_path.h"
11 #include "storage/browser/fileapi/file_system_operation_context.h"
12 #include "storage/browser/fileapi/file_system_url.h"
13 #include "storage/browser/fileapi/isolated_context.h"
15 using storage::ScopedFile;
17 namespace storage {
19 namespace {
21 void RevokeFileSystem(const std::string& filesystem_id,
22 const base::FilePath& /*path*/) {
23 IsolatedContext::GetInstance()->RevokeFileSystem(filesystem_id);
26 } // namespace
28 ScopedFile TransientFileUtil::CreateSnapshotFile(
29 FileSystemOperationContext* context,
30 const FileSystemURL& url,
31 base::File::Error* error,
32 base::File::Info* file_info,
33 base::FilePath* platform_path) {
34 DCHECK(file_info);
35 *error = GetFileInfo(context, url, file_info, platform_path);
36 if (*error == base::File::FILE_OK && file_info->is_directory)
37 *error = base::File::FILE_ERROR_NOT_A_FILE;
38 if (*error != base::File::FILE_OK)
39 return ScopedFile();
41 // Sets-up a transient filesystem.
42 DCHECK(!platform_path->empty());
43 DCHECK(!url.filesystem_id().empty());
45 ScopedFile scoped_file(
46 *platform_path,
47 ScopedFile::DELETE_ON_SCOPE_OUT,
48 context->task_runner());
49 scoped_file.AddScopeOutCallback(
50 base::Bind(&RevokeFileSystem, url.filesystem_id()), NULL);
52 return scoped_file.Pass();
55 } // namespace storage