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

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

Issue 539143002: Migrate webkit/browser/ to storage/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
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/browser/fileapi/watcher_manager.h"
27 #include "webkit/common/fileapi/file_system_types.h"
28 #include "webkit/common/fileapi/file_system_util.h"
29
30 namespace storage {
31
32 IsolatedFileSystemBackend::IsolatedFileSystemBackend()
33 : isolated_file_util_(new AsyncFileUtilAdapter(new LocalFileUtil())),
34 dragged_file_util_(new AsyncFileUtilAdapter(new DraggedFileUtil())),
35 transient_file_util_(new AsyncFileUtilAdapter(new TransientFileUtil())) {
36 }
37
38 IsolatedFileSystemBackend::~IsolatedFileSystemBackend() {
39 }
40
41 bool IsolatedFileSystemBackend::CanHandleType(FileSystemType type) const {
42 switch (type) {
43 case kFileSystemTypeIsolated:
44 case kFileSystemTypeDragged:
45 case kFileSystemTypeForTransientFile:
46 return true;
47 #if !defined(OS_CHROMEOS)
48 case kFileSystemTypeNativeLocal:
49 case kFileSystemTypeNativeForPlatformApp:
50 return true;
51 #endif
52 default:
53 return false;
54 }
55 }
56
57 void IsolatedFileSystemBackend::Initialize(FileSystemContext* context) {
58 }
59
60 void IsolatedFileSystemBackend::ResolveURL(
61 const FileSystemURL& url,
62 OpenFileSystemMode mode,
63 const OpenFileSystemCallback& callback) {
64 // We never allow opening a new isolated FileSystem via usual ResolveURL.
65 base::MessageLoopProxy::current()->PostTask(
66 FROM_HERE,
67 base::Bind(callback,
68 GURL(),
69 std::string(),
70 base::File::FILE_ERROR_SECURITY));
71 }
72
73 AsyncFileUtil* IsolatedFileSystemBackend::GetAsyncFileUtil(
74 FileSystemType type) {
75 switch (type) {
76 case kFileSystemTypeNativeLocal:
77 return isolated_file_util_.get();
78 case kFileSystemTypeDragged:
79 return dragged_file_util_.get();
80 case kFileSystemTypeForTransientFile:
81 return transient_file_util_.get();
82 default:
83 NOTREACHED();
84 }
85 return NULL;
86 }
87
88 WatcherManager* IsolatedFileSystemBackend::GetWatcherManager(
89 FileSystemType type) {
90 return NULL;
91 }
92
93 CopyOrMoveFileValidatorFactory*
94 IsolatedFileSystemBackend::GetCopyOrMoveFileValidatorFactory(
95 FileSystemType type, base::File::Error* error_code) {
96 DCHECK(error_code);
97 *error_code = base::File::FILE_OK;
98 return NULL;
99 }
100
101 FileSystemOperation* IsolatedFileSystemBackend::CreateFileSystemOperation(
102 const FileSystemURL& url,
103 FileSystemContext* context,
104 base::File::Error* error_code) const {
105 return FileSystemOperation::Create(
106 url, context, make_scoped_ptr(new FileSystemOperationContext(context)));
107 }
108
109 bool IsolatedFileSystemBackend::SupportsStreaming(
110 const storage::FileSystemURL& url) const {
111 return false;
112 }
113
114 bool IsolatedFileSystemBackend::HasInplaceCopyImplementation(
115 storage::FileSystemType type) const {
116 DCHECK(type == kFileSystemTypeNativeLocal || type == kFileSystemTypeDragged ||
117 type == kFileSystemTypeForTransientFile);
118 return false;
119 }
120
121 scoped_ptr<storage::FileStreamReader>
122 IsolatedFileSystemBackend::CreateFileStreamReader(
123 const FileSystemURL& url,
124 int64 offset,
125 const base::Time& expected_modification_time,
126 FileSystemContext* context) const {
127 return scoped_ptr<storage::FileStreamReader>(
128 storage::FileStreamReader::CreateForLocalFile(
129 context->default_file_task_runner(),
130 url.path(),
131 offset,
132 expected_modification_time));
133 }
134
135 scoped_ptr<FileStreamWriter> IsolatedFileSystemBackend::CreateFileStreamWriter(
136 const FileSystemURL& url,
137 int64 offset,
138 FileSystemContext* context) const {
139 return scoped_ptr<FileStreamWriter>(
140 FileStreamWriter::CreateForLocalFile(
141 context->default_file_task_runner(),
142 url.path(),
143 offset,
144 FileStreamWriter::OPEN_EXISTING_FILE));
145 }
146
147 FileSystemQuotaUtil* IsolatedFileSystemBackend::GetQuotaUtil() {
148 // No quota support.
149 return NULL;
150 }
151
152 } // namespace storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698