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

Side by Side Diff: webkit/fileapi/isolated_mount_point_provider.cc

Issue 14895013: Move webkit/fileapi/file_system_mount_point_provider.h to webkit/browser/fileapi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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/fileapi/isolated_mount_point_provider.h"
6
7 #include <string>
8
9 #include "base/bind.h"
10 #include "base/files/file_path.h"
11 #include "base/logging.h"
12 #include "base/message_loop_proxy.h"
13 #include "base/platform_file.h"
14 #include "base/sequenced_task_runner.h"
15 #include "webkit/blob/local_file_stream_reader.h"
16 #include "webkit/fileapi/async_file_util_adapter.h"
17 #include "webkit/fileapi/copy_or_move_file_validator.h"
18 #include "webkit/fileapi/file_system_callback_dispatcher.h"
19 #include "webkit/fileapi/file_system_context.h"
20 #include "webkit/fileapi/file_system_file_stream_reader.h"
21 #include "webkit/fileapi/file_system_operation_context.h"
22 #include "webkit/fileapi/file_system_task_runners.h"
23 #include "webkit/fileapi/file_system_types.h"
24 #include "webkit/fileapi/file_system_util.h"
25 #include "webkit/fileapi/isolated_context.h"
26 #include "webkit/fileapi/isolated_file_util.h"
27 #include "webkit/fileapi/local_file_stream_writer.h"
28 #include "webkit/fileapi/local_file_system_operation.h"
29 #include "webkit/fileapi/native_file_util.h"
30
31 namespace fileapi {
32
33 IsolatedMountPointProvider::IsolatedMountPointProvider()
34 : isolated_file_util_(new AsyncFileUtilAdapter(new IsolatedFileUtil())),
35 dragged_file_util_(new AsyncFileUtilAdapter(new DraggedFileUtil())) {
36 }
37
38 IsolatedMountPointProvider::~IsolatedMountPointProvider() {
39 }
40
41 bool IsolatedMountPointProvider::CanHandleType(FileSystemType type) const {
42 switch (type) {
43 case kFileSystemTypeIsolated:
44 case kFileSystemTypeDragged:
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 IsolatedMountPointProvider::ValidateFileSystemRoot(
57 const GURL& origin_url,
58 FileSystemType type,
59 bool create,
60 const ValidateFileSystemCallback& callback) {
61 // We never allow opening a new isolated FileSystem via usual OpenFileSystem.
62 base::MessageLoopProxy::current()->PostTask(
63 FROM_HERE,
64 base::Bind(callback, base::PLATFORM_FILE_ERROR_SECURITY));
65 }
66
67 base::FilePath IsolatedMountPointProvider::GetFileSystemRootPathOnFileThread(
68 const FileSystemURL& url,
69 bool create) {
70 // This is not supposed to be used.
71 NOTREACHED();
72 return base::FilePath();
73 }
74
75 FileSystemFileUtil* IsolatedMountPointProvider::GetFileUtil(
76 FileSystemType type) {
77 switch (type) {
78 case kFileSystemTypeNativeLocal:
79 return isolated_file_util_->sync_file_util();
80 case kFileSystemTypeDragged:
81 return dragged_file_util_->sync_file_util();
82 default:
83 NOTREACHED();
84 }
85 return NULL;
86 }
87
88 AsyncFileUtil* IsolatedMountPointProvider::GetAsyncFileUtil(
89 FileSystemType type) {
90 switch (type) {
91 case kFileSystemTypeNativeLocal:
92 return isolated_file_util_.get();
93 case kFileSystemTypeDragged:
94 return dragged_file_util_.get();
95 default:
96 NOTREACHED();
97 }
98 return NULL;
99 }
100
101 CopyOrMoveFileValidatorFactory*
102 IsolatedMountPointProvider::GetCopyOrMoveFileValidatorFactory(
103 FileSystemType type, base::PlatformFileError* error_code) {
104 DCHECK(error_code);
105 *error_code = base::PLATFORM_FILE_OK;
106 return NULL;
107 }
108
109 void IsolatedMountPointProvider::InitializeCopyOrMoveFileValidatorFactory(
110 FileSystemType type,
111 scoped_ptr<CopyOrMoveFileValidatorFactory> factory) {
112 DCHECK(!factory);
113 }
114
115 FilePermissionPolicy IsolatedMountPointProvider::GetPermissionPolicy(
116 const FileSystemURL& url, int permissions) const {
117 if (url.type() == kFileSystemTypeDragged && url.path().empty()) {
118 // The root directory of the dragged filesystem must be always read-only.
119 if (permissions & ~fileapi::kReadFilePermissions)
120 return FILE_PERMISSION_ALWAYS_DENY;
121 }
122 // Access to isolated file systems should be checked using per-filesystem
123 // access permission.
124 return FILE_PERMISSION_USE_FILESYSTEM_PERMISSION;
125 }
126
127 FileSystemOperation* IsolatedMountPointProvider::CreateFileSystemOperation(
128 const FileSystemURL& url,
129 FileSystemContext* context,
130 base::PlatformFileError* error_code) const {
131 return new LocalFileSystemOperation(
132 context, make_scoped_ptr(new FileSystemOperationContext(context)));
133 }
134
135 scoped_ptr<webkit_blob::FileStreamReader>
136 IsolatedMountPointProvider::CreateFileStreamReader(
137 const FileSystemURL& url,
138 int64 offset,
139 const base::Time& expected_modification_time,
140 FileSystemContext* context) const {
141 return scoped_ptr<webkit_blob::FileStreamReader>(
142 new webkit_blob::LocalFileStreamReader(
143 context->task_runners()->file_task_runner(),
144 url.path(), offset, expected_modification_time));
145 }
146
147 scoped_ptr<FileStreamWriter> IsolatedMountPointProvider::CreateFileStreamWriter(
148 const FileSystemURL& url,
149 int64 offset,
150 FileSystemContext* context) const {
151 return scoped_ptr<FileStreamWriter>(
152 new LocalFileStreamWriter(url.path(), offset));
153 }
154
155 FileSystemQuotaUtil* IsolatedMountPointProvider::GetQuotaUtil() {
156 // No quota support.
157 return NULL;
158 }
159
160 void IsolatedMountPointProvider::DeleteFileSystem(
161 const GURL& origin_url,
162 FileSystemType type,
163 FileSystemContext* context,
164 const DeleteFileSystemCallback& callback) {
165 NOTREACHED();
166 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
167 }
168
169 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698