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

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

Issue 101393006: FileAPI: Rename *OnFileThread to *OnFileTaskRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
« no previous file with comments | « webkit/browser/fileapi/sandbox_file_system_backend_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_file_system_backend_delegate.h" 5 #include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 virtual bool HasFileSystemType(FileSystemType type) const OVERRIDE { 101 virtual bool HasFileSystemType(FileSystemType type) const OVERRIDE {
102 return enum_->HasTypeDirectory( 102 return enum_->HasTypeDirectory(
103 SandboxFileSystemBackendDelegate::GetTypeString(type)); 103 SandboxFileSystemBackendDelegate::GetTypeString(type));
104 } 104 }
105 105
106 private: 106 private:
107 scoped_ptr<ObfuscatedFileUtil::AbstractOriginEnumerator> enum_; 107 scoped_ptr<ObfuscatedFileUtil::AbstractOriginEnumerator> enum_;
108 }; 108 };
109 109
110 void OpenFileSystemOnFileThread( 110 void OpenFileSystemOnFileTaskRunner(
111 ObfuscatedFileUtil* file_util, 111 ObfuscatedFileUtil* file_util,
112 const GURL& origin_url, 112 const GURL& origin_url,
113 FileSystemType type, 113 FileSystemType type,
114 OpenFileSystemMode mode, 114 OpenFileSystemMode mode,
115 base::PlatformFileError* error_ptr) { 115 base::PlatformFileError* error_ptr) {
116 DCHECK(error_ptr); 116 DCHECK(error_ptr);
117 const bool create = (mode == OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT); 117 const bool create = (mode == OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT);
118 file_util->GetDirectoryForOriginAndType( 118 file_util->GetDirectoryForOriginAndType(
119 origin_url, SandboxFileSystemBackendDelegate::GetTypeString(type), 119 origin_url, SandboxFileSystemBackendDelegate::GetTypeString(type),
120 create, error_ptr); 120 create, error_ptr);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 if (!IsAllowedScheme(origin_url)) { 253 if (!IsAllowedScheme(origin_url)) {
254 callback.Run(GURL(), std::string(), base::PLATFORM_FILE_ERROR_SECURITY); 254 callback.Run(GURL(), std::string(), base::PLATFORM_FILE_ERROR_SECURITY);
255 return; 255 return;
256 } 256 }
257 257
258 std::string name = GetFileSystemName(origin_url, type); 258 std::string name = GetFileSystemName(origin_url, type);
259 259
260 base::PlatformFileError* error_ptr = new base::PlatformFileError; 260 base::PlatformFileError* error_ptr = new base::PlatformFileError;
261 file_task_runner_->PostTaskAndReply( 261 file_task_runner_->PostTaskAndReply(
262 FROM_HERE, 262 FROM_HERE,
263 base::Bind(&OpenFileSystemOnFileThread, 263 base::Bind(&OpenFileSystemOnFileTaskRunner,
264 obfuscated_file_util(), origin_url, type, mode, 264 obfuscated_file_util(), origin_url, type, mode,
265 base::Unretained(error_ptr)), 265 base::Unretained(error_ptr)),
266 base::Bind(&DidOpenFileSystem, 266 base::Bind(&DidOpenFileSystem,
267 weak_factory_.GetWeakPtr(), 267 weak_factory_.GetWeakPtr(),
268 base::Bind(callback, root_url, name), 268 base::Bind(callback, root_url, name),
269 base::Owned(error_ptr))); 269 base::Owned(error_ptr)));
270 270
271 io_thread_checker_.DetachFromThread(); 271 io_thread_checker_.DetachFromThread();
272 is_filesystem_opened_ = true; 272 is_filesystem_opened_ = true;
273 } 273 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 FileSystemType type) const { 316 FileSystemType type) const {
317 if (!IsAccessValid(url)) 317 if (!IsAccessValid(url))
318 return scoped_ptr<FileStreamWriter>(); 318 return scoped_ptr<FileStreamWriter>();
319 const UpdateObserverList* observers = GetUpdateObservers(type); 319 const UpdateObserverList* observers = GetUpdateObservers(type);
320 DCHECK(observers); 320 DCHECK(observers);
321 return scoped_ptr<FileStreamWriter>( 321 return scoped_ptr<FileStreamWriter>(
322 new SandboxFileStreamWriter(context, url, offset, *observers)); 322 new SandboxFileStreamWriter(context, url, offset, *observers));
323 } 323 }
324 324
325 base::PlatformFileError 325 base::PlatformFileError
326 SandboxFileSystemBackendDelegate::DeleteOriginDataOnFileThread( 326 SandboxFileSystemBackendDelegate::DeleteOriginDataOnFileTaskRunner(
327 FileSystemContext* file_system_context, 327 FileSystemContext* file_system_context,
328 quota::QuotaManagerProxy* proxy, 328 quota::QuotaManagerProxy* proxy,
329 const GURL& origin_url, 329 const GURL& origin_url,
330 FileSystemType type) { 330 FileSystemType type) {
331 int64 usage = GetOriginUsageOnFileThread( 331 DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
332 int64 usage = GetOriginUsageOnFileTaskRunner(
332 file_system_context, origin_url, type); 333 file_system_context, origin_url, type);
333 usage_cache()->CloseCacheFiles(); 334 usage_cache()->CloseCacheFiles();
334 bool result = obfuscated_file_util()->DeleteDirectoryForOriginAndType( 335 bool result = obfuscated_file_util()->DeleteDirectoryForOriginAndType(
335 origin_url, GetTypeString(type)); 336 origin_url, GetTypeString(type));
336 if (result && proxy) { 337 if (result && proxy) {
337 proxy->NotifyStorageModified( 338 proxy->NotifyStorageModified(
338 quota::QuotaClient::kFileSystem, 339 quota::QuotaClient::kFileSystem,
339 origin_url, 340 origin_url,
340 FileSystemTypeToQuotaStorageType(type), 341 FileSystemTypeToQuotaStorageType(type),
341 -usage); 342 -usage);
342 } 343 }
343 344
344 if (result) 345 if (result)
345 return base::PLATFORM_FILE_OK; 346 return base::PLATFORM_FILE_OK;
346 return base::PLATFORM_FILE_ERROR_FAILED; 347 return base::PLATFORM_FILE_ERROR_FAILED;
347 } 348 }
348 349
349 void SandboxFileSystemBackendDelegate::GetOriginsForTypeOnFileThread( 350 void SandboxFileSystemBackendDelegate::GetOriginsForTypeOnFileTaskRunner(
350 FileSystemType type, std::set<GURL>* origins) { 351 FileSystemType type, std::set<GURL>* origins) {
352 DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
351 DCHECK(origins); 353 DCHECK(origins);
352 scoped_ptr<OriginEnumerator> enumerator(CreateOriginEnumerator()); 354 scoped_ptr<OriginEnumerator> enumerator(CreateOriginEnumerator());
353 GURL origin; 355 GURL origin;
354 while (!(origin = enumerator->Next()).is_empty()) { 356 while (!(origin = enumerator->Next()).is_empty()) {
355 if (enumerator->HasFileSystemType(type)) 357 if (enumerator->HasFileSystemType(type))
356 origins->insert(origin); 358 origins->insert(origin);
357 } 359 }
358 switch (type) { 360 switch (type) {
359 case kFileSystemTypeTemporary: 361 case kFileSystemTypeTemporary:
360 UMA_HISTOGRAM_COUNTS(kTemporaryOriginsCountLabel, origins->size()); 362 UMA_HISTOGRAM_COUNTS(kTemporaryOriginsCountLabel, origins->size());
361 break; 363 break;
362 case kFileSystemTypePersistent: 364 case kFileSystemTypePersistent:
363 UMA_HISTOGRAM_COUNTS(kPersistentOriginsCountLabel, origins->size()); 365 UMA_HISTOGRAM_COUNTS(kPersistentOriginsCountLabel, origins->size());
364 break; 366 break;
365 default: 367 default:
366 break; 368 break;
367 } 369 }
368 } 370 }
369 371
370 void SandboxFileSystemBackendDelegate::GetOriginsForHostOnFileThread( 372 void SandboxFileSystemBackendDelegate::GetOriginsForHostOnFileTaskRunner(
371 FileSystemType type, const std::string& host, 373 FileSystemType type, const std::string& host,
372 std::set<GURL>* origins) { 374 std::set<GURL>* origins) {
375 DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
373 DCHECK(origins); 376 DCHECK(origins);
374 scoped_ptr<OriginEnumerator> enumerator(CreateOriginEnumerator()); 377 scoped_ptr<OriginEnumerator> enumerator(CreateOriginEnumerator());
375 GURL origin; 378 GURL origin;
376 while (!(origin = enumerator->Next()).is_empty()) { 379 while (!(origin = enumerator->Next()).is_empty()) {
377 if (host == net::GetHostOrSpecFromURL(origin) && 380 if (host == net::GetHostOrSpecFromURL(origin) &&
378 enumerator->HasFileSystemType(type)) 381 enumerator->HasFileSystemType(type))
379 origins->insert(origin); 382 origins->insert(origin);
380 } 383 }
381 } 384 }
382 385
383 int64 SandboxFileSystemBackendDelegate::GetOriginUsageOnFileThread( 386 int64 SandboxFileSystemBackendDelegate::GetOriginUsageOnFileTaskRunner(
384 FileSystemContext* file_system_context, 387 FileSystemContext* file_system_context,
385 const GURL& origin_url, 388 const GURL& origin_url,
386 FileSystemType type) { 389 FileSystemType type) {
390 DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
391
387 // Don't use usage cache and return recalculated usage for sticky invalidated 392 // Don't use usage cache and return recalculated usage for sticky invalidated
388 // origins. 393 // origins.
389 if (ContainsKey(sticky_dirty_origins_, std::make_pair(origin_url, type))) 394 if (ContainsKey(sticky_dirty_origins_, std::make_pair(origin_url, type)))
390 return RecalculateUsage(file_system_context, origin_url, type); 395 return RecalculateUsage(file_system_context, origin_url, type);
391 396
392 base::FilePath base_path = 397 base::FilePath base_path =
393 GetBaseDirectoryForOriginAndType(origin_url, type, false); 398 GetBaseDirectoryForOriginAndType(origin_url, type, false);
394 if (base_path.empty() || !base::DirectoryExists(base_path)) 399 if (base_path.empty() || !base::DirectoryExists(base_path))
395 return 0; 400 return 0;
396 base::FilePath usage_file_path = 401 base::FilePath usage_file_path =
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 base::SequencedTaskRunner* file_task_runner) { 663 base::SequencedTaskRunner* file_task_runner) {
659 return new ObfuscatedFileUtil(special_storage_policy, 664 return new ObfuscatedFileUtil(special_storage_policy,
660 file_system_directory, 665 file_system_directory,
661 file_task_runner, 666 file_task_runner,
662 base::Bind(&GetTypeStringForURL), 667 base::Bind(&GetTypeStringForURL),
663 GetKnownTypeStrings(), 668 GetKnownTypeStrings(),
664 NULL); 669 NULL);
665 } 670 }
666 671
667 } // namespace fileapi 672 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/sandbox_file_system_backend_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698