| OLD | NEW |
| 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 // OnGotQuotaManagedOrigins(). | 482 // OnGotQuotaManagedOrigins(). |
| 483 quota_managed_origins_to_delete_count_ = 0; | 483 quota_managed_origins_to_delete_count_ = 0; |
| 484 quota_managed_storage_types_to_delete_count_ = 2; | 484 quota_managed_storage_types_to_delete_count_ = 2; |
| 485 | 485 |
| 486 if (delete_begin_ == base::Time()) { | 486 if (delete_begin_ == base::Time()) { |
| 487 // If we're deleting since the beginning of time, ask the QuotaManager for | 487 // If we're deleting since the beginning of time, ask the QuotaManager for |
| 488 // all origins with persistent quota modified within the user-specified | 488 // all origins with persistent quota modified within the user-specified |
| 489 // timeframe, and deal with the resulting set in | 489 // timeframe, and deal with the resulting set in |
| 490 // OnGotPersistentQuotaManagedOrigins. | 490 // OnGotPersistentQuotaManagedOrigins. |
| 491 profile_->GetQuotaManager()->GetOriginsModifiedSince( | 491 profile_->GetQuotaManager()->GetOriginsModifiedSince( |
| 492 quota::kStorageTypePersistent, delete_begin_, NewCallback(this, | 492 quota::kStorageTypePersistent, delete_begin_, |
| 493 &BrowsingDataRemover::OnGotQuotaManagedOrigins)); | 493 base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins, |
| 494 base::Unretained(this))); |
| 494 } else { | 495 } else { |
| 495 // Otherwise, we don't need to deal with persistent storage. | 496 // Otherwise, we don't need to deal with persistent storage. |
| 496 --quota_managed_storage_types_to_delete_count_; | 497 --quota_managed_storage_types_to_delete_count_; |
| 497 } | 498 } |
| 498 | 499 |
| 499 // Do the same for temporary quota, regardless, passing the resulting set into | 500 // Do the same for temporary quota, regardless, passing the resulting set into |
| 500 // OnGotTemporaryQuotaManagedOrigins. | 501 // OnGotTemporaryQuotaManagedOrigins. |
| 501 profile_->GetQuotaManager()->GetOriginsModifiedSince( | 502 profile_->GetQuotaManager()->GetOriginsModifiedSince( |
| 502 quota::kStorageTypeTemporary, delete_begin_, NewCallback(this, | 503 quota::kStorageTypeTemporary, delete_begin_, |
| 503 &BrowsingDataRemover::OnGotQuotaManagedOrigins)); | 504 base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins, |
| 505 base::Unretained(this))); |
| 504 } | 506 } |
| 505 | 507 |
| 506 void BrowsingDataRemover::OnGotQuotaManagedOrigins( | 508 void BrowsingDataRemover::OnGotQuotaManagedOrigins( |
| 507 const std::set<GURL>& origins, quota::StorageType type) { | 509 const std::set<GURL>& origins, quota::StorageType type) { |
| 508 DCHECK_GT(quota_managed_storage_types_to_delete_count_, 0); | 510 DCHECK_GT(quota_managed_storage_types_to_delete_count_, 0); |
| 509 // Walk through the origins passed in, delete quota of |type| from each that | 511 // Walk through the origins passed in, delete quota of |type| from each that |
| 510 // isn't protected. | 512 // isn't protected. |
| 511 std::set<GURL>::const_iterator origin; | 513 std::set<GURL>::const_iterator origin; |
| 512 for (origin = origins.begin(); origin != origins.end(); ++origin) { | 514 for (origin = origins.begin(); origin != origins.end(); ++origin) { |
| 513 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) | 515 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) |
| 514 continue; | 516 continue; |
| 515 ++quota_managed_origins_to_delete_count_; | 517 ++quota_managed_origins_to_delete_count_; |
| 516 quota_manager_->DeleteOriginData(origin->GetOrigin(), | 518 quota_manager_->DeleteOriginData( |
| 517 type, NewCallback(this, | 519 origin->GetOrigin(), type, |
| 518 &BrowsingDataRemover::OnQuotaManagedOriginDeletion)); | 520 base::Bind(&BrowsingDataRemover::OnQuotaManagedOriginDeletion, |
| 521 base::Unretained(this))); |
| 519 } | 522 } |
| 520 | 523 |
| 521 --quota_managed_storage_types_to_delete_count_; | 524 --quota_managed_storage_types_to_delete_count_; |
| 522 CheckQuotaManagedDataDeletionStatus(); | 525 CheckQuotaManagedDataDeletionStatus(); |
| 523 } | 526 } |
| 524 | 527 |
| 525 void BrowsingDataRemover::OnQuotaManagedOriginDeletion( | 528 void BrowsingDataRemover::OnQuotaManagedOriginDeletion( |
| 526 quota::QuotaStatusCode status) { | 529 quota::QuotaStatusCode status) { |
| 527 DCHECK_GT(quota_managed_origins_to_delete_count_, 0); | 530 DCHECK_GT(quota_managed_origins_to_delete_count_, 0); |
| 528 if (status != quota::kQuotaStatusOk) { | 531 if (status != quota::kQuotaStatusOk) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 GetURLRequestContext()->cookie_store()->GetCookieMonster(); | 583 GetURLRequestContext()->cookie_store()->GetCookieMonster(); |
| 581 if (cookie_monster) { | 584 if (cookie_monster) { |
| 582 cookie_monster->DeleteAllCreatedBetweenAsync( | 585 cookie_monster->DeleteAllCreatedBetweenAsync( |
| 583 delete_begin_, delete_end_, | 586 delete_begin_, delete_end_, |
| 584 base::Bind(&BrowsingDataRemover::OnClearedCookies, | 587 base::Bind(&BrowsingDataRemover::OnClearedCookies, |
| 585 base::Unretained(this))); | 588 base::Unretained(this))); |
| 586 } else { | 589 } else { |
| 587 OnClearedCookies(0); | 590 OnClearedCookies(0); |
| 588 } | 591 } |
| 589 } | 592 } |
| OLD | NEW |