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

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

Issue 16043006: Rename FileSystemMountPointProvider::ValidateFileSystemRoot to OpenFileSystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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/browser/fileapi/sandbox_mount_point_provider.h" 5 #include "webkit/browser/fileapi/sandbox_mount_point_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 88
89 virtual bool HasFileSystemType(fileapi::FileSystemType type) const OVERRIDE { 89 virtual bool HasFileSystemType(fileapi::FileSystemType type) const OVERRIDE {
90 return enum_->HasFileSystemType(type); 90 return enum_->HasFileSystemType(type);
91 } 91 }
92 92
93 private: 93 private:
94 scoped_ptr<ObfuscatedFileUtil::AbstractOriginEnumerator> enum_; 94 scoped_ptr<ObfuscatedFileUtil::AbstractOriginEnumerator> enum_;
95 }; 95 };
96 96
97 void DidValidateFileSystemRoot( 97 void DidOpenFileSystem(
98 base::WeakPtr<SandboxMountPointProvider> mount_point_provider, 98 base::WeakPtr<SandboxMountPointProvider> mount_point_provider,
99 const FileSystemMountPointProvider::ValidateFileSystemCallback& callback, 99 const FileSystemMountPointProvider::OpenFileSystemCallback& callback,
100 base::PlatformFileError* error) { 100 base::PlatformFileError* error) {
101 if (mount_point_provider) 101 if (mount_point_provider)
102 mount_point_provider.get()->CollectOpenFileSystemMetrics(*error); 102 mount_point_provider.get()->CollectOpenFileSystemMetrics(*error);
103 callback.Run(*error); 103 callback.Run(*error);
104 } 104 }
105 105
106 void ValidateRootOnFileThread( 106 void OpenFileSystemOnFileThread(
107 ObfuscatedFileUtil* file_util, 107 ObfuscatedFileUtil* file_util,
108 const GURL& origin_url, 108 const GURL& origin_url,
109 FileSystemType type, 109 FileSystemType type,
110 bool create, 110 OpenFileSystemMode mode,
111 base::PlatformFileError* error_ptr) { 111 base::PlatformFileError* error_ptr) {
112 DCHECK(error_ptr); 112 DCHECK(error_ptr);
113 113
114 const bool create = (mode == OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT);
114 base::FilePath root_path = 115 base::FilePath root_path =
115 file_util->GetDirectoryForOriginAndType( 116 file_util->GetDirectoryForOriginAndType(
116 origin_url, type, create, error_ptr); 117 origin_url, type, create, error_ptr);
117 if (*error_ptr != base::PLATFORM_FILE_OK) { 118 if (*error_ptr != base::PLATFORM_FILE_OK) {
118 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, 119 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel,
119 kCreateDirectoryError, 120 kCreateDirectoryError,
120 kFileSystemErrorMax); 121 kFileSystemErrorMax);
121 } else { 122 } else {
122 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, kOK, kFileSystemErrorMax); 123 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, kOK, kFileSystemErrorMax);
123 } 124 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 delete quota_observer; 191 delete quota_observer;
191 if (!file_task_runner_->DeleteSoon(FROM_HERE, file_system_usage_cache)) 192 if (!file_task_runner_->DeleteSoon(FROM_HERE, file_system_usage_cache))
192 delete file_system_usage_cache; 193 delete file_system_usage_cache;
193 } 194 }
194 } 195 }
195 196
196 bool SandboxMountPointProvider::CanHandleType(FileSystemType type) const { 197 bool SandboxMountPointProvider::CanHandleType(FileSystemType type) const {
197 return IsSandboxType(type); 198 return IsSandboxType(type);
198 } 199 }
199 200
200 void SandboxMountPointProvider::ValidateFileSystemRoot( 201 void SandboxMountPointProvider::OpenFileSystem(
201 const GURL& origin_url, fileapi::FileSystemType type, bool create, 202 const GURL& origin_url, fileapi::FileSystemType type,
202 const ValidateFileSystemCallback& callback) { 203 OpenFileSystemMode mode,
204 const OpenFileSystemCallback& callback) {
203 if (file_system_options_.is_incognito() && 205 if (file_system_options_.is_incognito() &&
204 !(type == kFileSystemTypeTemporary && 206 !(type == kFileSystemTypeTemporary &&
205 enable_temporary_file_system_in_incognito_)) { 207 enable_temporary_file_system_in_incognito_)) {
206 // TODO(kinuko): return an isolated temporary directory. 208 // TODO(kinuko): return an isolated temporary directory.
207 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 209 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
208 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, 210 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel,
209 kIncognito, 211 kIncognito,
210 kFileSystemErrorMax); 212 kFileSystemErrorMax);
211 return; 213 return;
212 } 214 }
213 215
214 if (!IsAllowedScheme(origin_url)) { 216 if (!IsAllowedScheme(origin_url)) {
215 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 217 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
216 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, 218 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel,
217 kInvalidSchemeError, 219 kInvalidSchemeError,
218 kFileSystemErrorMax); 220 kFileSystemErrorMax);
219 return; 221 return;
220 } 222 }
221 223
222 base::PlatformFileError* error_ptr = new base::PlatformFileError; 224 base::PlatformFileError* error_ptr = new base::PlatformFileError;
223 file_task_runner_->PostTaskAndReply( 225 file_task_runner_->PostTaskAndReply(
224 FROM_HERE, 226 FROM_HERE,
225 base::Bind(&ValidateRootOnFileThread, 227 base::Bind(&OpenFileSystemOnFileThread,
226 sandbox_sync_file_util(), 228 sandbox_sync_file_util(),
227 origin_url, type, create, 229 origin_url, type, mode,
228 base::Unretained(error_ptr)), 230 base::Unretained(error_ptr)),
229 base::Bind(&DidValidateFileSystemRoot, 231 base::Bind(&DidOpenFileSystem,
230 weak_factory_.GetWeakPtr(), 232 weak_factory_.GetWeakPtr(),
231 callback, base::Owned(error_ptr))); 233 callback, base::Owned(error_ptr)));
232 234
233 if (enable_usage_tracking_) 235 if (enable_usage_tracking_)
234 return; 236 return;
235 237
236 // Schedule full usage recalculation on the next launch without 238 // Schedule full usage recalculation on the next launch without
237 // --disable-file-system-usage-tracking. 239 // --disable-file-system-usage-tracking.
238 file_task_runner_->PostTask( 240 file_task_runner_->PostTask(
239 FROM_HERE, 241 FROM_HERE,
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 676
675 while (!(file_path_each = enumerator->Next()).empty()) { 677 while (!(file_path_each = enumerator->Next()).empty()) {
676 usage += enumerator->Size(); 678 usage += enumerator->Size();
677 usage += ObfuscatedFileUtil::ComputeFilePathCost(file_path_each); 679 usage += ObfuscatedFileUtil::ComputeFilePathCost(file_path_each);
678 } 680 }
679 681
680 return usage; 682 return usage;
681 } 683 }
682 684
683 } // namespace fileapi 685 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/sandbox_mount_point_provider.h ('k') | webkit/browser/fileapi/sandbox_mount_point_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698