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