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

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

Issue 9016020: Cleanup FileSystemOperation for preparing for adding FSO-factory method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix Created 8 years, 11 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/fileapi/file_system_context.h" 5 #include "webkit/fileapi/file_system_context.h"
6 6
7 #include "base/bind.h"
7 #include "base/file_util.h" 8 #include "base/file_util.h"
8 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
9 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste m.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste m.h"
12 #include "webkit/fileapi/file_system_callback_dispatcher.h"
11 #include "webkit/fileapi/file_system_file_util.h" 13 #include "webkit/fileapi/file_system_file_util.h"
12 #include "webkit/fileapi/file_system_options.h" 14 #include "webkit/fileapi/file_system_options.h"
13 #include "webkit/fileapi/file_system_quota_client.h" 15 #include "webkit/fileapi/file_system_quota_client.h"
14 #include "webkit/fileapi/file_system_util.h" 16 #include "webkit/fileapi/file_system_util.h"
15 #include "webkit/fileapi/sandbox_mount_point_provider.h" 17 #include "webkit/fileapi/sandbox_mount_point_provider.h"
16 #include "webkit/quota/quota_manager.h" 18 #include "webkit/quota/quota_manager.h"
17 #include "webkit/quota/special_storage_policy.h" 19 #include "webkit/quota/special_storage_policy.h"
18 20
19 #if defined(OS_CHROMEOS) 21 #if defined(OS_CHROMEOS)
20 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" 22 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h"
21 #endif 23 #endif
22 24
23 using quota::QuotaClient; 25 using quota::QuotaClient;
24 26
25 namespace fileapi { 27 namespace fileapi {
26 28
27 namespace { 29 namespace {
28 30
29 QuotaClient* CreateQuotaClient( 31 QuotaClient* CreateQuotaClient(
30 scoped_refptr<base::MessageLoopProxy> file_message_loop, 32 scoped_refptr<base::MessageLoopProxy> file_message_loop,
31 FileSystemContext* context, 33 FileSystemContext* context,
32 bool is_incognito) { 34 bool is_incognito) {
33 return new FileSystemQuotaClient(file_message_loop, context, is_incognito); 35 return new FileSystemQuotaClient(file_message_loop, context, is_incognito);
34 } 36 }
35 37
38 void DidOpenFileSystem(scoped_ptr<FileSystemCallbackDispatcher> dispatcher,
39 const GURL& filesystem_root,
40 const std::string& filesystem_name,
41 base::PlatformFileError error) {
42 if (error == base::PLATFORM_FILE_OK) {
43 dispatcher->DidOpenFileSystem(filesystem_name, filesystem_root);
44 } else {
45 dispatcher->DidFail(error);
46 }
47 }
48
36 } // anonymous namespace 49 } // anonymous namespace
37 50
38 FileSystemContext::FileSystemContext( 51 FileSystemContext::FileSystemContext(
39 scoped_refptr<base::MessageLoopProxy> file_message_loop, 52 scoped_refptr<base::MessageLoopProxy> file_message_loop,
40 scoped_refptr<base::MessageLoopProxy> io_message_loop, 53 scoped_refptr<base::MessageLoopProxy> io_message_loop,
41 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, 54 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy,
42 quota::QuotaManagerProxy* quota_manager_proxy, 55 quota::QuotaManagerProxy* quota_manager_proxy,
43 const FilePath& profile_path, 56 const FilePath& profile_path,
44 const FileSystemOptions& options) 57 const FileSystemOptions& options)
45 : file_message_loop_(file_message_loop), 58 : file_message_loop_(file_message_loop),
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 146 }
134 147
135 void FileSystemContext::DeleteOnCorrectThread() const { 148 void FileSystemContext::DeleteOnCorrectThread() const {
136 if (!io_message_loop_->BelongsToCurrentThread()) { 149 if (!io_message_loop_->BelongsToCurrentThread()) {
137 io_message_loop_->DeleteSoon(FROM_HERE, this); 150 io_message_loop_->DeleteSoon(FROM_HERE, this);
138 return; 151 return;
139 } 152 }
140 delete this; 153 delete this;
141 } 154 }
142 155
156 void FileSystemContext::OpenFileSystem(
157 const GURL& origin_url,
158 FileSystemType type,
159 bool create,
160 scoped_ptr<FileSystemCallbackDispatcher> dispatcher) {
161 DCHECK(dispatcher.get());
162 FileSystemMountPointProvider* mount_point_provider =
163 GetMountPointProvider(type);
164 if (!mount_point_provider) {
165 dispatcher->DidFail(base::PLATFORM_FILE_ERROR_SECURITY);
166 return;
167 }
168
169 GURL root_url = GetFileSystemRootURI(origin_url, type);
170 std::string name = GetFileSystemName(origin_url, type);
171
172 mount_point_provider->ValidateFileSystemRoot(
173 origin_url, type, create,
174 base::Bind(&DidOpenFileSystem,
175 base::Passed(&dispatcher), root_url, name));
176 }
177
143 } // namespace fileapi 178 } // namespace fileapi
144 179
145 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypeTemporary) == \ 180 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypeTemporary) == \
146 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); 181 int(fileapi::kFileSystemTypeTemporary), mismatching_enums);
147 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypePersistent) == \ 182 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypePersistent) == \
148 int(fileapi::kFileSystemTypePersistent), mismatching_enums); 183 int(fileapi::kFileSystemTypePersistent), mismatching_enums);
149 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypeExternal) == \ 184 COMPILE_ASSERT(int(WebKit::WebFileSystem::TypeExternal) == \
150 int(fileapi::kFileSystemTypeExternal), mismatching_enums); 185 int(fileapi::kFileSystemTypeExternal), mismatching_enums);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698