| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 base::Time delete_begin, | 59 base::Time delete_begin, |
| 60 base::Time delete_end) | 60 base::Time delete_end) |
| 61 : profile_(profile), | 61 : profile_(profile), |
| 62 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), | 62 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), |
| 63 delete_begin_(delete_begin), | 63 delete_begin_(delete_begin), |
| 64 delete_end_(delete_end), | 64 delete_end_(delete_end), |
| 65 ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_( | 65 ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_( |
| 66 this, &BrowsingDataRemover::OnClearedDatabases)), | 66 this, &BrowsingDataRemover::OnClearedDatabases)), |
| 67 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( | 67 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( |
| 68 this, &BrowsingDataRemover::DoClearCache)), | 68 this, &BrowsingDataRemover::DoClearCache)), |
| 69 appcache_service_(profile->GetAppCacheService()), | |
| 70 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_got_info_callback_( | 69 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_got_info_callback_( |
| 71 this, &BrowsingDataRemover::OnGotAppCacheInfo)), | 70 this, &BrowsingDataRemover::OnGotAppCacheInfo)), |
| 72 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( | 71 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( |
| 73 this, &BrowsingDataRemover::OnAppCacheDeleted)), | 72 this, &BrowsingDataRemover::OnAppCacheDeleted)), |
| 74 appcaches_to_be_deleted_count_(0), | 73 appcaches_to_be_deleted_count_(0), |
| 75 next_cache_state_(STATE_NONE), | 74 next_cache_state_(STATE_NONE), |
| 76 cache_(NULL), | 75 cache_(NULL), |
| 77 main_context_getter_(profile->GetRequestContext()), | 76 main_context_getter_(profile->GetRequestContext()), |
| 78 media_context_getter_(profile->GetRequestContextForMedia()), | 77 media_context_getter_(profile->GetRequestContextForMedia()), |
| 79 waiting_for_clear_databases_(false), | 78 waiting_for_clear_databases_(false), |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 database_tracker_ = profile_->GetDatabaseTracker(); | 217 database_tracker_ = profile_->GetDatabaseTracker(); |
| 219 if (database_tracker_.get()) { | 218 if (database_tracker_.get()) { |
| 220 waiting_for_clear_databases_ = true; | 219 waiting_for_clear_databases_ = true; |
| 221 BrowserThread::PostTask( | 220 BrowserThread::PostTask( |
| 222 BrowserThread::FILE, FROM_HERE, | 221 BrowserThread::FILE, FROM_HERE, |
| 223 NewRunnableMethod( | 222 NewRunnableMethod( |
| 224 this, | 223 this, |
| 225 &BrowsingDataRemover::ClearDatabasesOnFILEThread)); | 224 &BrowsingDataRemover::ClearDatabasesOnFILEThread)); |
| 226 } | 225 } |
| 227 | 226 |
| 228 waiting_for_clear_appcache_ = true; | 227 appcache_service_ = profile_->GetAppCacheService(); |
| 229 BrowserThread::PostTask( | 228 if (appcache_service_.get()) { |
| 230 BrowserThread::IO, FROM_HERE, | 229 waiting_for_clear_appcache_ = true; |
| 231 NewRunnableMethod( | 230 BrowserThread::PostTask( |
| 232 this, | 231 BrowserThread::IO, FROM_HERE, |
| 233 &BrowsingDataRemover::ClearAppCacheOnIOThread)); | 232 NewRunnableMethod( |
| 233 this, |
| 234 &BrowsingDataRemover::ClearAppCacheOnIOThread)); |
| 235 } |
| 234 | 236 |
| 235 waiting_for_clear_gears_data_ = true; | 237 waiting_for_clear_gears_data_ = true; |
| 236 BrowserThread::PostTask( | 238 BrowserThread::PostTask( |
| 237 BrowserThread::FILE, FROM_HERE, | 239 BrowserThread::FILE, FROM_HERE, |
| 238 NewRunnableMethod( | 240 NewRunnableMethod( |
| 239 this, | 241 this, |
| 240 &BrowsingDataRemover::ClearGearsDataOnFILEThread, | 242 &BrowsingDataRemover::ClearGearsDataOnFILEThread, |
| 241 profile_->GetPath())); | 243 profile_->GetPath())); |
| 242 | 244 |
| 243 waiting_for_clear_file_systems_ = true; | 245 waiting_for_clear_file_systems_ = true; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 return; | 522 return; |
| 521 } | 523 } |
| 522 waiting_for_clear_appcache_ = false; | 524 waiting_for_clear_appcache_ = false; |
| 523 NotifyAndDeleteIfDone(); | 525 NotifyAndDeleteIfDone(); |
| 524 } | 526 } |
| 525 | 527 |
| 526 void BrowsingDataRemover::ClearAppCacheOnIOThread() { | 528 void BrowsingDataRemover::ClearAppCacheOnIOThread() { |
| 527 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 529 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 528 DCHECK(waiting_for_clear_appcache_); | 530 DCHECK(waiting_for_clear_appcache_); |
| 529 appcache_info_ = new appcache::AppCacheInfoCollection; | 531 appcache_info_ = new appcache::AppCacheInfoCollection; |
| 530 if (appcache_service_) { | 532 appcache_service_->GetAllAppCacheInfo( |
| 531 appcache_service_->GetAllAppCacheInfo( | 533 appcache_info_, &appcache_got_info_callback_); |
| 532 appcache_info_, &appcache_got_info_callback_); | 534 // continues in OnGotAppCacheInfo. |
| 533 // continues in OnGotAppCacheInfo | |
| 534 } else { | |
| 535 // Couldn't get app cache service, nothing to clear. | |
| 536 OnClearedAppCache(); | |
| 537 } | |
| 538 } | 535 } |
| 539 | 536 |
| 540 void BrowsingDataRemover::OnGotAppCacheInfo(int rv) { | 537 void BrowsingDataRemover::OnGotAppCacheInfo(int rv) { |
| 541 using appcache::AppCacheInfoVector; | 538 using appcache::AppCacheInfoVector; |
| 542 typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin; | 539 typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin; |
| 543 | 540 |
| 544 for (InfoByOrigin::const_iterator origin = | 541 for (InfoByOrigin::const_iterator origin = |
| 545 appcache_info_->infos_by_origin.begin(); | 542 appcache_info_->infos_by_origin.begin(); |
| 546 origin != appcache_info_->infos_by_origin.end(); ++origin) { | 543 origin != appcache_info_->infos_by_origin.end(); ++origin) { |
| 547 if (special_storage_policy_->IsStorageProtected(origin->first)) | 544 if (special_storage_policy_->IsStorageProtected(origin->first)) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 | 625 |
| 629 ClearGearsData(profile_dir); | 626 ClearGearsData(profile_dir); |
| 630 OnClearedGearsData(); | 627 OnClearedGearsData(); |
| 631 } | 628 } |
| 632 | 629 |
| 633 void BrowsingDataRemover::OnWaitableEventSignaled( | 630 void BrowsingDataRemover::OnWaitableEventSignaled( |
| 634 base::WaitableEvent* waitable_event) { | 631 base::WaitableEvent* waitable_event) { |
| 635 waiting_for_clear_lso_data_ = false; | 632 waiting_for_clear_lso_data_ = false; |
| 636 NotifyAndDeleteIfDone(); | 633 NotifyAndDeleteIfDone(); |
| 637 } | 634 } |
| OLD | NEW |