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

Side by Side Diff: webkit/browser/fileapi/isolated_file_system_backend.cc

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.
4
5 #include "webkit/browser/fileapi/isolated_file_system_backend.h"
6
7 #include <string>
8
9 #include "base/bind.h"
10 #include "base/files/file_path.h"
11 #include "base/files/file_util_proxy.h"
12 #include "base/logging.h"
13 #include "base/message_loop/message_loop_proxy.h"
14 #include "base/sequenced_task_runner.h"
15 #include "webkit/browser/blob/file_stream_reader.h"
16 #include "webkit/browser/fileapi/async_file_util_adapter.h"
17 #include "webkit/browser/fileapi/copy_or_move_file_validator.h"
18 #include "webkit/browser/fileapi/dragged_file_util.h"
19 #include "webkit/browser/fileapi/file_stream_writer.h"
20 #include "webkit/browser/fileapi/file_system_context.h"
21 #include "webkit/browser/fileapi/file_system_operation.h"
22 #include "webkit/browser/fileapi/file_system_operation_context.h"
23 #include "webkit/browser/fileapi/isolated_context.h"
24 #include "webkit/browser/fileapi/native_file_util.h"
25 #include "webkit/browser/fileapi/transient_file_util.h"
26 #include "webkit/common/fileapi/file_system_types.h"
27 #include "webkit/common/fileapi/file_system_util.h"
28
29 namespace fileapi {
30
31 IsolatedFileSystemBackend::IsolatedFileSystemBackend()
32 : isolated_file_util_(new AsyncFileUtilAdapter(new LocalFileUtil())),
33 dragged_file_util_(new AsyncFileUtilAdapter(new DraggedFileUtil())),
34 transient_file_util_(new AsyncFileUtilAdapter(new TransientFileUtil())) {
35 }
36
37 IsolatedFileSystemBackend::~IsolatedFileSystemBackend() {
38 }
39
40 bool IsolatedFileSystemBackend::CanHandleType(FileSystemType type) const {
41 switch (type) {
42 case kFileSystemTypeIsolated:
43 case kFileSystemTypeDragged:
44 case kFileSystemTypeForTransientFile:
45 return true;
46 #if !defined(OS_CHROMEOS)
47 case kFileSystemTypeNativeLocal:
48 case kFileSystemTypeNativeForPlatformApp:
49 return true;
50 #endif
51 default:
52 return false;
53 }
54 }
55
56 void IsolatedFileSystemBackend::Initialize(FileSystemContext* context) {
57 }
58
59 void IsolatedFileSystemBackend::ResolveURL(
60 const FileSystemURL& url,
61 OpenFileSystemMode mode,
62 const OpenFileSystemCallback& callback) {
63 // We never allow opening a new isolated FileSystem via usual ResolveURL.
64 base::MessageLoopProxy::current()->PostTask(
65 FROM_HERE,
66 base::Bind(callback,
67 GURL(),
68 std::string(),
69 base::File::FILE_ERROR_SECURITY));
70 }
71
72 AsyncFileUtil* IsolatedFileSystemBackend::GetAsyncFileUtil(
73 FileSystemType type) {
74 switch (type) {
75 case kFileSystemTypeNativeLocal:
76 return isolated_file_util_.get();
77 case kFileSystemTypeDragged:
78 return dragged_file_util_.get();
79 case kFileSystemTypeForTransientFile:
80 return transient_file_util_.get();
81 default:
82 NOTREACHED();
83 }
84 return NULL;
85 }
86
87 CopyOrMoveFileValidatorFactory*
88 IsolatedFileSystemBackend::GetCopyOrMoveFileValidatorFactory(
89 FileSystemType type, base::File::Error* error_code) {
90 DCHECK(error_code);
91 *error_code = base::File::FILE_OK;
92 return NULL;
93 }
94
95 FileSystemOperation* IsolatedFileSystemBackend::CreateFileSystemOperation(
96 const FileSystemURL& url,
97 FileSystemContext* context,
98 base::File::Error* error_code) const {
99 return FileSystemOperation::Create(
100 url, context, make_scoped_ptr(new FileSystemOperationContext(context)));
101 }
102
103 bool IsolatedFileSystemBackend::SupportsStreaming(
104 const fileapi::FileSystemURL& url) const {
105 return false;
106 }
107
108 scoped_ptr<webkit_blob::FileStreamReader>
109 IsolatedFileSystemBackend::CreateFileStreamReader(
110 const FileSystemURL& url,
111 int64 offset,
112 const base::Time& expected_modification_time,
113 FileSystemContext* context) const {
114 return scoped_ptr<webkit_blob::FileStreamReader>(
115 webkit_blob::FileStreamReader::CreateForLocalFile(
116 context->default_file_task_runner(),
117 url.path(), offset, expected_modification_time));
118 }
119
120 scoped_ptr<FileStreamWriter> IsolatedFileSystemBackend::CreateFileStreamWriter(
121 const FileSystemURL& url,
122 int64 offset,
123 FileSystemContext* context) const {
124 return scoped_ptr<FileStreamWriter>(
125 FileStreamWriter::CreateForLocalFile(
126 context->default_file_task_runner(),
127 url.path(),
128 offset,
129 FileStreamWriter::OPEN_EXISTING_FILE));
130 }
131
132 FileSystemQuotaUtil* IsolatedFileSystemBackend::GetQuotaUtil() {
133 // No quota support.
134 return NULL;
135 }
136
137 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/isolated_file_system_backend.h ('k') | webkit/browser/fileapi/local_file_stream_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698