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

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

Issue 10407115: Always pass FileSystemContext to ObfuscatedFileUtil operations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix Created 8 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
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/sandbox_mount_point_provider.h" 5 #include "webkit/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/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 FilePath SandboxMountPointProvider::GetBaseDirectoryForOriginAndType( 491 FilePath SandboxMountPointProvider::GetBaseDirectoryForOriginAndType(
492 const GURL& origin_url, fileapi::FileSystemType type, bool create) const { 492 const GURL& origin_url, fileapi::FileSystemType type, bool create) const {
493 493
494 MigrateIfNeeded(sandbox_file_util_, old_base_path()); 494 MigrateIfNeeded(sandbox_file_util_, old_base_path());
495 495
496 return sandbox_file_util_->GetDirectoryForOriginAndType( 496 return sandbox_file_util_->GetDirectoryForOriginAndType(
497 origin_url, type, create); 497 origin_url, type, create);
498 } 498 }
499 499
500 bool SandboxMountPointProvider::DeleteOriginDataOnFileThread( 500 bool SandboxMountPointProvider::DeleteOriginDataOnFileThread(
501 QuotaManagerProxy* proxy, const GURL& origin_url, 501 FileSystemContext* file_system_context,
502 QuotaManagerProxy* proxy,
503 const GURL& origin_url,
502 fileapi::FileSystemType type) { 504 fileapi::FileSystemType type) {
503 MigrateIfNeeded(sandbox_file_util_, old_base_path()); 505 MigrateIfNeeded(sandbox_file_util_, old_base_path());
504 506
505 int64 usage = GetOriginUsageOnFileThread(origin_url, type); 507 int64 usage = GetOriginUsageOnFileThread(file_system_context,
508 origin_url, type);
506 509
507 bool result = 510 bool result =
508 sandbox_file_util_->DeleteDirectoryForOriginAndType(origin_url, type); 511 sandbox_file_util_->DeleteDirectoryForOriginAndType(origin_url, type);
509 if (result && proxy) { 512 if (result && proxy) {
510 proxy->NotifyStorageModified( 513 proxy->NotifyStorageModified(
511 quota::QuotaClient::kFileSystem, 514 quota::QuotaClient::kFileSystem,
512 origin_url, 515 origin_url,
513 FileSystemTypeToQuotaStorageType(type), 516 FileSystemTypeToQuotaStorageType(type),
514 -usage); 517 -usage);
515 } 518 }
(...skipping 29 matching lines...) Expand all
545 scoped_ptr<OriginEnumerator> enumerator(CreateOriginEnumerator()); 548 scoped_ptr<OriginEnumerator> enumerator(CreateOriginEnumerator());
546 GURL origin; 549 GURL origin;
547 while (!(origin = enumerator->Next()).is_empty()) { 550 while (!(origin = enumerator->Next()).is_empty()) {
548 if (host == net::GetHostOrSpecFromURL(origin) && 551 if (host == net::GetHostOrSpecFromURL(origin) &&
549 enumerator->HasFileSystemType(type)) 552 enumerator->HasFileSystemType(type))
550 origins->insert(origin); 553 origins->insert(origin);
551 } 554 }
552 } 555 }
553 556
554 int64 SandboxMountPointProvider::GetOriginUsageOnFileThread( 557 int64 SandboxMountPointProvider::GetOriginUsageOnFileThread(
555 const GURL& origin_url, fileapi::FileSystemType type) { 558 FileSystemContext* file_system_context,
559 const GURL& origin_url,
560 fileapi::FileSystemType type) {
556 DCHECK(type == kFileSystemTypeTemporary || 561 DCHECK(type == kFileSystemTypeTemporary ||
557 type == kFileSystemTypePersistent); 562 type == kFileSystemTypePersistent);
558 FilePath base_path = 563 FilePath base_path =
559 GetBaseDirectoryForOriginAndType(origin_url, type, false); 564 GetBaseDirectoryForOriginAndType(origin_url, type, false);
560 if (base_path.empty() || !file_util::DirectoryExists(base_path)) return 0; 565 if (base_path.empty() || !file_util::DirectoryExists(base_path)) return 0;
561 FilePath usage_file_path = 566 FilePath usage_file_path =
562 base_path.Append(FileSystemUsageCache::kUsageFileName); 567 base_path.Append(FileSystemUsageCache::kUsageFileName);
563 568
564 bool is_valid = FileSystemUsageCache::IsValid(usage_file_path); 569 bool is_valid = FileSystemUsageCache::IsValid(usage_file_path);
565 int32 dirty_status = FileSystemUsageCache::GetDirty(usage_file_path); 570 int32 dirty_status = FileSystemUsageCache::GetDirty(usage_file_path);
566 bool visited = (visited_origins_.find(origin_url) != visited_origins_.end()); 571 bool visited = (visited_origins_.find(origin_url) != visited_origins_.end());
567 visited_origins_.insert(origin_url); 572 visited_origins_.insert(origin_url);
568 if (is_valid && (dirty_status == 0 || (dirty_status > 0 && visited))) { 573 if (is_valid && (dirty_status == 0 || (dirty_status > 0 && visited))) {
569 // The usage cache is clean (dirty == 0) or the origin is already 574 // The usage cache is clean (dirty == 0) or the origin is already
570 // initialized and running. Read the cache file to get the usage. 575 // initialized and running. Read the cache file to get the usage.
571 return FileSystemUsageCache::GetUsage(usage_file_path); 576 return FileSystemUsageCache::GetUsage(usage_file_path);
572 } 577 }
573 // The usage cache has not been initialized or the cache is dirty. 578 // The usage cache has not been initialized or the cache is dirty.
574 // Get the directory size now and update the cache. 579 // Get the directory size now and update the cache.
575 FileSystemUsageCache::Delete(usage_file_path); 580 FileSystemUsageCache::Delete(usage_file_path);
576 581
577 FileSystemOperationContext context(NULL); 582 FileSystemOperationContext context(file_system_context);
578 FileSystemPath path(origin_url, type, FilePath()); 583 FileSystemPath path(origin_url, type, FilePath());
579 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator( 584 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator(
580 sandbox_file_util_->CreateFileEnumerator(&context, path, true)); 585 sandbox_file_util_->CreateFileEnumerator(&context, path, true));
581 586
582 FilePath file_path_each; 587 FilePath file_path_each;
583 int64 usage = 0; 588 int64 usage = 0;
584 589
585 while (!(file_path_each = enumerator->Next()).empty()) { 590 while (!(file_path_each = enumerator->Next()).empty()) {
586 base::PlatformFileInfo file_info; 591 base::PlatformFileInfo file_info;
587 FilePath platform_file_path; 592 FilePath platform_file_path;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 break; 740 break;
736 case base::PLATFORM_FILE_ERROR_FAILED: 741 case base::PLATFORM_FILE_ERROR_FAILED:
737 default: 742 default:
738 REPORT(kUnknownError); 743 REPORT(kUnknownError);
739 break; 744 break;
740 } 745 }
741 #undef REPORT 746 #undef REPORT
742 } 747 }
743 748
744 } // namespace fileapi 749 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/sandbox_mount_point_provider.h ('k') | webkit/fileapi/sandbox_mount_point_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698