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

Side by Side Diff: chrome/browser/browsing_data_remover.cc

Issue 8070001: Use base::Callback in Quota related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pass as cref, and fix style. Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/browsing_data_remover.h" 5 #include "chrome/browser/browsing_data_remover.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 // OnGotQuotaManagedOrigins(). 481 // OnGotQuotaManagedOrigins().
482 quota_managed_origins_to_delete_count_ = 0; 482 quota_managed_origins_to_delete_count_ = 0;
483 quota_managed_storage_types_to_delete_count_ = 2; 483 quota_managed_storage_types_to_delete_count_ = 2;
484 484
485 if (delete_begin_ == base::Time()) { 485 if (delete_begin_ == base::Time()) {
486 // If we're deleting since the beginning of time, ask the QuotaManager for 486 // If we're deleting since the beginning of time, ask the QuotaManager for
487 // all origins with persistent quota modified within the user-specified 487 // all origins with persistent quota modified within the user-specified
488 // timeframe, and deal with the resulting set in 488 // timeframe, and deal with the resulting set in
489 // OnGotPersistentQuotaManagedOrigins. 489 // OnGotPersistentQuotaManagedOrigins.
490 profile_->GetQuotaManager()->GetOriginsModifiedSince( 490 profile_->GetQuotaManager()->GetOriginsModifiedSince(
491 quota::kStorageTypePersistent, delete_begin_, NewCallback(this, 491 quota::kStorageTypePersistent, delete_begin_,
492 &BrowsingDataRemover::OnGotQuotaManagedOrigins)); 492 base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins,
493 base::Unretained(this)));
493 } else { 494 } else {
494 // Otherwise, we don't need to deal with persistent storage. 495 // Otherwise, we don't need to deal with persistent storage.
495 --quota_managed_storage_types_to_delete_count_; 496 --quota_managed_storage_types_to_delete_count_;
496 } 497 }
497 498
498 // Do the same for temporary quota, regardless, passing the resulting set into 499 // Do the same for temporary quota, regardless, passing the resulting set into
499 // OnGotTemporaryQuotaManagedOrigins. 500 // OnGotTemporaryQuotaManagedOrigins.
500 profile_->GetQuotaManager()->GetOriginsModifiedSince( 501 profile_->GetQuotaManager()->GetOriginsModifiedSince(
501 quota::kStorageTypeTemporary, delete_begin_, NewCallback(this, 502 quota::kStorageTypeTemporary, delete_begin_,
502 &BrowsingDataRemover::OnGotQuotaManagedOrigins)); 503 base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins,
504 base::Unretained(this)));
503 } 505 }
504 506
505 void BrowsingDataRemover::OnGotQuotaManagedOrigins( 507 void BrowsingDataRemover::OnGotQuotaManagedOrigins(
506 const std::set<GURL>& origins, quota::StorageType type) { 508 const std::set<GURL>& origins, quota::StorageType type) {
507 DCHECK_GT(quota_managed_storage_types_to_delete_count_, 0); 509 DCHECK_GT(quota_managed_storage_types_to_delete_count_, 0);
508 // Walk through the origins passed in, delete quota of |type| from each that 510 // Walk through the origins passed in, delete quota of |type| from each that
509 // isn't protected. 511 // isn't protected.
510 std::set<GURL>::const_iterator origin; 512 std::set<GURL>::const_iterator origin;
511 for (origin = origins.begin(); origin != origins.end(); ++origin) { 513 for (origin = origins.begin(); origin != origins.end(); ++origin) {
512 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) 514 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin()))
513 continue; 515 continue;
514 ++quota_managed_origins_to_delete_count_; 516 ++quota_managed_origins_to_delete_count_;
515 quota_manager_->DeleteOriginData(origin->GetOrigin(), 517 quota_manager_->DeleteOriginData(
516 type, NewCallback(this, 518 origin->GetOrigin(), type,
517 &BrowsingDataRemover::OnQuotaManagedOriginDeletion)); 519 base::Bind(&BrowsingDataRemover::OnQuotaManagedOriginDeletion,
520 base::Unretained(this)));
518 } 521 }
519 522
520 --quota_managed_storage_types_to_delete_count_; 523 --quota_managed_storage_types_to_delete_count_;
521 CheckQuotaManagedDataDeletionStatus(); 524 CheckQuotaManagedDataDeletionStatus();
522 } 525 }
523 526
524 void BrowsingDataRemover::OnQuotaManagedOriginDeletion( 527 void BrowsingDataRemover::OnQuotaManagedOriginDeletion(
525 quota::QuotaStatusCode status) { 528 quota::QuotaStatusCode status) {
526 DCHECK_GT(quota_managed_origins_to_delete_count_, 0); 529 DCHECK_GT(quota_managed_origins_to_delete_count_, 0);
527 if (status != quota::kQuotaStatusOk) { 530 if (status != quota::kQuotaStatusOk) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 GetURLRequestContext()->cookie_store()->GetCookieMonster(); 582 GetURLRequestContext()->cookie_store()->GetCookieMonster();
580 if (cookie_monster) { 583 if (cookie_monster) {
581 cookie_monster->DeleteAllCreatedBetweenAsync( 584 cookie_monster->DeleteAllCreatedBetweenAsync(
582 delete_begin_, delete_end_, 585 delete_begin_, delete_end_,
583 base::Bind(&BrowsingDataRemover::OnClearedCookies, 586 base::Bind(&BrowsingDataRemover::OnClearedCookies,
584 base::Unretained(this))); 587 base::Unretained(this)));
585 } else { 588 } else {
586 OnClearedCookies(0); 589 OnClearedCookies(0);
587 } 590 }
588 } 591 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698