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/callback.h" | 10 #include "base/callback.h" |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 quota_managed_origins_to_delete_count_ = 0; | 458 quota_managed_origins_to_delete_count_ = 0; |
459 quota_managed_storage_types_to_delete_count_ = 2; | 459 quota_managed_storage_types_to_delete_count_ = 2; |
460 | 460 |
461 if (delete_begin_ == base::Time()) { | 461 if (delete_begin_ == base::Time()) { |
462 // If we're deleting since the beginning of time, ask the QuotaManager for | 462 // If we're deleting since the beginning of time, ask the QuotaManager for |
463 // all origins with persistent quota modified within the user-specified | 463 // all origins with persistent quota modified within the user-specified |
464 // timeframe, and deal with the resulting set in | 464 // timeframe, and deal with the resulting set in |
465 // OnGotPersistentQuotaManagedOrigins. | 465 // OnGotPersistentQuotaManagedOrigins. |
466 profile_->GetQuotaManager()->GetOriginsModifiedSince( | 466 profile_->GetQuotaManager()->GetOriginsModifiedSince( |
467 quota::kStorageTypePersistent, delete_begin_, NewCallback(this, | 467 quota::kStorageTypePersistent, delete_begin_, NewCallback(this, |
468 &BrowsingDataRemover::OnGotPersistentQuotaManagedOrigins)); | 468 &BrowsingDataRemover::OnGotQuotaManagedOrigins)); |
469 } else { | 469 } else { |
470 // Otherwise, we don't need to deal with persistent storage. | 470 // Otherwise, we don't need to deal with persistent storage. |
471 --quota_managed_storage_types_to_delete_count_; | 471 --quota_managed_storage_types_to_delete_count_; |
472 } | 472 } |
473 | 473 |
474 // Do the same for temporary quota, regardless, passing the resulting set into | 474 // Do the same for temporary quota, regardless, passing the resulting set into |
475 // OnGotTemporaryQuotaManagedOrigins. | 475 // OnGotTemporaryQuotaManagedOrigins. |
476 profile_->GetQuotaManager()->GetOriginsModifiedSince( | 476 profile_->GetQuotaManager()->GetOriginsModifiedSince( |
477 quota::kStorageTypeTemporary, delete_begin_, NewCallback(this, | 477 quota::kStorageTypeTemporary, delete_begin_, NewCallback(this, |
478 &BrowsingDataRemover::OnGotTemporaryQuotaManagedOrigins)); | 478 &BrowsingDataRemover::OnGotQuotaManagedOrigins)); |
479 } | 479 } |
480 | 480 |
481 void BrowsingDataRemover::OnGotTemporaryQuotaManagedOrigins( | 481 void BrowsingDataRemover::OnGotQuotaManagedOrigins( |
482 const std::set<GURL>& origins) { | 482 const std::set<GURL>& origins, quota::StorageType type) { |
483 DCHECK_GT(quota_managed_storage_types_to_delete_count_, 0); | 483 DCHECK_GT(quota_managed_storage_types_to_delete_count_, 0); |
484 // Walk through the origins passed in, delete temporary quota from each that | 484 // Walk through the origins passed in, delete quota of |type| from each that |
485 // isn't protected. | 485 // isn't protected. |
486 std::set<GURL>::const_iterator origin; | 486 std::set<GURL>::const_iterator origin; |
487 for (origin = origins.begin(); origin != origins.end(); ++origin) { | 487 for (origin = origins.begin(); origin != origins.end(); ++origin) { |
488 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) | 488 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) |
489 continue; | 489 continue; |
490 ++quota_managed_origins_to_delete_count_; | 490 ++quota_managed_origins_to_delete_count_; |
491 quota_manager_->DeleteOriginData(origin->GetOrigin(), | 491 quota_manager_->DeleteOriginData(origin->GetOrigin(), |
492 quota::kStorageTypeTemporary, NewCallback(this, | 492 type, NewCallback(this, |
493 &BrowsingDataRemover::OnQuotaManagedOriginDeletion)); | 493 &BrowsingDataRemover::OnQuotaManagedOriginDeletion)); |
494 } | 494 } |
495 | 495 |
496 --quota_managed_storage_types_to_delete_count_; | 496 --quota_managed_storage_types_to_delete_count_; |
497 if (quota_managed_storage_types_to_delete_count_ == 0 && | |
498 quota_managed_origins_to_delete_count_ == 0) | |
499 CheckQuotaManagedDataDeletionStatus(); | |
500 } | |
501 | |
502 void BrowsingDataRemover::OnGotPersistentQuotaManagedOrigins( | |
503 const std::set<GURL>& origins) { | |
504 DCHECK_GT(quota_managed_storage_types_to_delete_count_, 0); | |
505 // Walk through the origins passed in, delete persistent quota from each that | |
506 // isn't protected. | |
507 std::set<GURL>::const_iterator origin; | |
508 for (origin = origins.begin(); origin != origins.end(); ++origin) { | |
509 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) | |
510 continue; | |
511 ++quota_managed_origins_to_delete_count_; | |
512 quota_manager_->DeleteOriginData(origin->GetOrigin(), | |
513 quota::kStorageTypePersistent, NewCallback(this, | |
514 &BrowsingDataRemover::OnQuotaManagedOriginDeletion)); | |
515 } | |
516 | |
517 --quota_managed_storage_types_to_delete_count_; | |
518 if (quota_managed_storage_types_to_delete_count_ == 0 && | 497 if (quota_managed_storage_types_to_delete_count_ == 0 && |
519 quota_managed_origins_to_delete_count_ == 0) | 498 quota_managed_origins_to_delete_count_ == 0) |
520 CheckQuotaManagedDataDeletionStatus(); | 499 CheckQuotaManagedDataDeletionStatus(); |
521 } | 500 } |
522 | 501 |
523 void BrowsingDataRemover::OnQuotaManagedOriginDeletion( | 502 void BrowsingDataRemover::OnQuotaManagedOriginDeletion( |
524 quota::QuotaStatusCode status) { | 503 quota::QuotaStatusCode status) { |
525 DCHECK_GT(quota_managed_origins_to_delete_count_, 0); | 504 DCHECK_GT(quota_managed_origins_to_delete_count_, 0); |
526 if (status != quota::kQuotaStatusOk) { | 505 if (status != quota::kQuotaStatusOk) { |
527 // TODO(mkwst): We should add the GURL to StatusCallback; this is a pretty | 506 // TODO(mkwst): We should add the GURL to StatusCallback; this is a pretty |
(...skipping 18 matching lines...) Expand all Loading... |
546 NewRunnableMethod( | 525 NewRunnableMethod( |
547 this, | 526 this, |
548 &BrowsingDataRemover::NotifyAndDeleteIfDone)); | 527 &BrowsingDataRemover::NotifyAndDeleteIfDone)); |
549 } | 528 } |
550 | 529 |
551 void BrowsingDataRemover::OnWaitableEventSignaled( | 530 void BrowsingDataRemover::OnWaitableEventSignaled( |
552 base::WaitableEvent* waitable_event) { | 531 base::WaitableEvent* waitable_event) { |
553 waiting_for_clear_lso_data_ = false; | 532 waiting_for_clear_lso_data_ = false; |
554 NotifyAndDeleteIfDone(); | 533 NotifyAndDeleteIfDone(); |
555 } | 534 } |
OLD | NEW |