| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 bool BrowsingDataRemover::removing_ = false; | 66 bool BrowsingDataRemover::removing_ = false; |
| 67 | 67 |
| 68 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, | 68 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
| 69 base::Time delete_begin, | 69 base::Time delete_begin, |
| 70 base::Time delete_end) | 70 base::Time delete_end) |
| 71 : profile_(profile), | 71 : profile_(profile), |
| 72 quota_manager_(NULL), | 72 quota_manager_(NULL), |
| 73 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), | 73 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), |
| 74 delete_begin_(delete_begin), | 74 delete_begin_(delete_begin), |
| 75 delete_end_(delete_end), | 75 delete_end_(delete_end), |
| 76 ALLOW_THIS_IN_INITIALIZER_LIST(old_cache_callback_( |
| 77 this, &BrowsingDataRemover::DoClearCache)), |
| 76 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( | 78 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( |
| 77 this, &BrowsingDataRemover::DoClearCache)), | 79 base::Bind(&BrowsingDataRemover::DoClearCache, |
| 80 base::Unretained(this)))), |
| 78 next_cache_state_(STATE_NONE), | 81 next_cache_state_(STATE_NONE), |
| 79 cache_(NULL), | 82 cache_(NULL), |
| 80 main_context_getter_(profile->GetRequestContext()), | 83 main_context_getter_(profile->GetRequestContext()), |
| 81 media_context_getter_(profile->GetRequestContextForMedia()), | 84 media_context_getter_(profile->GetRequestContextForMedia()), |
| 82 waiting_for_clear_history_(false), | 85 waiting_for_clear_history_(false), |
| 83 waiting_for_clear_quota_managed_data_(false), | 86 waiting_for_clear_quota_managed_data_(false), |
| 84 waiting_for_clear_networking_history_(false), | 87 waiting_for_clear_networking_history_(false), |
| 85 waiting_for_clear_cookies_(false), | 88 waiting_for_clear_cookies_(false), |
| 86 waiting_for_clear_cache_(false), | 89 waiting_for_clear_cache_(false), |
| 87 waiting_for_clear_lso_data_(false) { | 90 waiting_for_clear_lso_data_(false) { |
| 88 DCHECK(profile); | 91 DCHECK(profile); |
| 89 } | 92 } |
| 90 | 93 |
| 91 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, | 94 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
| 92 TimePeriod time_period, | 95 TimePeriod time_period, |
| 93 base::Time delete_end) | 96 base::Time delete_end) |
| 94 : profile_(profile), | 97 : profile_(profile), |
| 95 quota_manager_(NULL), | 98 quota_manager_(NULL), |
| 96 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), | 99 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), |
| 97 delete_begin_(CalculateBeginDeleteTime(time_period)), | 100 delete_begin_(CalculateBeginDeleteTime(time_period)), |
| 98 delete_end_(delete_end), | 101 delete_end_(delete_end), |
| 102 ALLOW_THIS_IN_INITIALIZER_LIST(old_cache_callback_( |
| 103 this, &BrowsingDataRemover::DoClearCache)), |
| 99 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( | 104 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( |
| 100 this, &BrowsingDataRemover::DoClearCache)), | 105 base::Bind(&BrowsingDataRemover::DoClearCache, |
| 106 base::Unretained(this)))), |
| 101 next_cache_state_(STATE_NONE), | 107 next_cache_state_(STATE_NONE), |
| 102 cache_(NULL), | 108 cache_(NULL), |
| 103 main_context_getter_(profile->GetRequestContext()), | 109 main_context_getter_(profile->GetRequestContext()), |
| 104 media_context_getter_(profile->GetRequestContextForMedia()), | 110 media_context_getter_(profile->GetRequestContextForMedia()), |
| 105 waiting_for_clear_history_(false), | 111 waiting_for_clear_history_(false), |
| 106 waiting_for_clear_quota_managed_data_(false), | 112 waiting_for_clear_quota_managed_data_(false), |
| 107 waiting_for_clear_networking_history_(false), | 113 waiting_for_clear_networking_history_(false), |
| 108 waiting_for_clear_cookies_(false), | 114 waiting_for_clear_cookies_(false), |
| 109 waiting_for_clear_cache_(false), | 115 waiting_for_clear_cache_(false), |
| 110 waiting_for_clear_lso_data_(false) { | 116 waiting_for_clear_lso_data_(false) { |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 switch (next_cache_state_) { | 435 switch (next_cache_state_) { |
| 430 case STATE_CREATE_MAIN: | 436 case STATE_CREATE_MAIN: |
| 431 case STATE_CREATE_MEDIA: { | 437 case STATE_CREATE_MEDIA: { |
| 432 // Get a pointer to the cache. | 438 // Get a pointer to the cache. |
| 433 net::URLRequestContextGetter* getter = | 439 net::URLRequestContextGetter* getter = |
| 434 (next_cache_state_ == STATE_CREATE_MAIN) ? | 440 (next_cache_state_ == STATE_CREATE_MAIN) ? |
| 435 main_context_getter_ : media_context_getter_; | 441 main_context_getter_ : media_context_getter_; |
| 436 net::HttpTransactionFactory* factory = | 442 net::HttpTransactionFactory* factory = |
| 437 getter->GetURLRequestContext()->http_transaction_factory(); | 443 getter->GetURLRequestContext()->http_transaction_factory(); |
| 438 | 444 |
| 439 rv = factory->GetCache()->GetBackend(&cache_, &cache_callback_); | 445 rv = factory->GetCache()->GetBackend(&cache_, cache_callback_); |
| 440 next_cache_state_ = (next_cache_state_ == STATE_CREATE_MAIN) ? | 446 next_cache_state_ = (next_cache_state_ == STATE_CREATE_MAIN) ? |
| 441 STATE_DELETE_MAIN : STATE_DELETE_MEDIA; | 447 STATE_DELETE_MAIN : STATE_DELETE_MEDIA; |
| 442 break; | 448 break; |
| 443 } | 449 } |
| 444 case STATE_DELETE_MAIN: | 450 case STATE_DELETE_MAIN: |
| 445 case STATE_DELETE_MEDIA: { | 451 case STATE_DELETE_MEDIA: { |
| 446 // |cache_| can be null if it cannot be initialized. | 452 // |cache_| can be null if it cannot be initialized. |
| 447 if (cache_) { | 453 if (cache_) { |
| 448 if (delete_begin_.is_null()) { | 454 if (delete_begin_.is_null()) { |
| 449 rv = cache_->DoomAllEntries(&cache_callback_); | 455 rv = cache_->DoomAllEntries(&old_cache_callback_); |
| 450 } else { | 456 } else { |
| 451 rv = cache_->DoomEntriesBetween(delete_begin_, delete_end_, | 457 rv = cache_->DoomEntriesBetween(delete_begin_, delete_end_, |
| 452 &cache_callback_); | 458 &old_cache_callback_); |
| 453 } | 459 } |
| 454 cache_ = NULL; | 460 cache_ = NULL; |
| 455 } | 461 } |
| 456 next_cache_state_ = (next_cache_state_ == STATE_DELETE_MAIN) ? | 462 next_cache_state_ = (next_cache_state_ == STATE_DELETE_MAIN) ? |
| 457 STATE_CREATE_MEDIA : STATE_DONE; | 463 STATE_CREATE_MEDIA : STATE_DONE; |
| 458 break; | 464 break; |
| 459 } | 465 } |
| 460 case STATE_DONE: { | 466 case STATE_DONE: { |
| 461 cache_ = NULL; | 467 cache_ = NULL; |
| 462 | 468 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 GetURLRequestContext()->cookie_store()->GetCookieMonster(); | 592 GetURLRequestContext()->cookie_store()->GetCookieMonster(); |
| 587 if (cookie_monster) { | 593 if (cookie_monster) { |
| 588 cookie_monster->DeleteAllCreatedBetweenAsync( | 594 cookie_monster->DeleteAllCreatedBetweenAsync( |
| 589 delete_begin_, delete_end_, | 595 delete_begin_, delete_end_, |
| 590 base::Bind(&BrowsingDataRemover::OnClearedCookies, | 596 base::Bind(&BrowsingDataRemover::OnClearedCookies, |
| 591 base::Unretained(this))); | 597 base::Unretained(this))); |
| 592 } else { | 598 } else { |
| 593 OnClearedCookies(0); | 599 OnClearedCookies(0); |
| 594 } | 600 } |
| 595 } | 601 } |
| OLD | NEW |