| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/chrome_thread.h" | 7 #include "chrome/browser/chrome_thread.h" |
| 8 #include "chrome/browser/download/download_manager.h" | 8 #include "chrome/browser/download/download_manager.h" |
| 9 #include "chrome/browser/history/history.h" | 9 #include "chrome/browser/history/history.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // Invoke ClearBrowsingDataView::ClearCache on the IO thread. | 134 // Invoke ClearBrowsingDataView::ClearCache on the IO thread. |
| 135 waiting_for_clear_cache_ = true; | 135 waiting_for_clear_cache_ = true; |
| 136 UserMetrics::RecordAction(L"ClearBrowsingData_Cache", profile_); | 136 UserMetrics::RecordAction(L"ClearBrowsingData_Cache", profile_); |
| 137 ChromeThread::PostTask( | 137 ChromeThread::PostTask( |
| 138 ChromeThread::IO, FROM_HERE, | 138 ChromeThread::IO, FROM_HERE, |
| 139 NewRunnableMethod( | 139 NewRunnableMethod( |
| 140 this, | 140 this, |
| 141 &BrowsingDataRemover::ClearCacheOnIOThread, | 141 &BrowsingDataRemover::ClearCacheOnIOThread, |
| 142 profile_->GetRequestContext(), | 142 profile_->GetRequestContext(), |
| 143 delete_begin_, | 143 delete_begin_, |
| 144 delete_end_, | 144 delete_end_)); |
| 145 MessageLoop::current())); | |
| 146 } | 145 } |
| 147 | 146 |
| 148 NotifyAndDeleteIfDone(); | 147 NotifyAndDeleteIfDone(); |
| 149 } | 148 } |
| 150 | 149 |
| 151 void BrowsingDataRemover::AddObserver(Observer* observer) { | 150 void BrowsingDataRemover::AddObserver(Observer* observer) { |
| 152 observer_list_.AddObserver(observer); | 151 observer_list_.AddObserver(observer); |
| 153 } | 152 } |
| 154 | 153 |
| 155 void BrowsingDataRemover::RemoveObserver(Observer* observer) { | 154 void BrowsingDataRemover::RemoveObserver(Observer* observer) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 214 |
| 216 void BrowsingDataRemover::ClearedCache() { | 215 void BrowsingDataRemover::ClearedCache() { |
| 217 waiting_for_clear_cache_ = false; | 216 waiting_for_clear_cache_ = false; |
| 218 | 217 |
| 219 NotifyAndDeleteIfDone(); | 218 NotifyAndDeleteIfDone(); |
| 220 } | 219 } |
| 221 | 220 |
| 222 void BrowsingDataRemover::ClearCacheOnIOThread( | 221 void BrowsingDataRemover::ClearCacheOnIOThread( |
| 223 URLRequestContextGetter* context_getter, | 222 URLRequestContextGetter* context_getter, |
| 224 base::Time delete_begin, | 223 base::Time delete_begin, |
| 225 base::Time delete_end, | 224 base::Time delete_end) { |
| 226 MessageLoop* ui_loop) { | |
| 227 // This function should be called on the IO thread. | 225 // This function should be called on the IO thread. |
| 228 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 226 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 229 | 227 |
| 230 // Get a pointer to the cache. | 228 // Get a pointer to the cache. |
| 231 net::HttpTransactionFactory* factory = | 229 net::HttpTransactionFactory* factory = |
| 232 context_getter->GetURLRequestContext()->http_transaction_factory(); | 230 context_getter->GetURLRequestContext()->http_transaction_factory(); |
| 233 disk_cache::Backend* cache = factory->GetCache()->disk_cache(); | 231 disk_cache::Backend* cache = factory->GetCache()->disk_cache(); |
| 234 | 232 |
| 235 // |cache| can be null since it is lazily initialized, in this case we do | 233 // |cache| can be null since it is lazily initialized, in this case we do |
| 236 // nothing. | 234 // nothing. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 249 // |cache| can be null since it is lazily initialized, in this case we do | 247 // |cache| can be null since it is lazily initialized, in this case we do |
| 250 // nothing. | 248 // nothing. |
| 251 if (cache) { | 249 if (cache) { |
| 252 if (delete_begin.is_null()) | 250 if (delete_begin.is_null()) |
| 253 cache->DoomAllEntries(); | 251 cache->DoomAllEntries(); |
| 254 else | 252 else |
| 255 cache->DoomEntriesBetween(delete_begin, delete_end); | 253 cache->DoomEntriesBetween(delete_begin, delete_end); |
| 256 } | 254 } |
| 257 | 255 |
| 258 // Notify the UI thread that we are done. | 256 // Notify the UI thread that we are done. |
| 259 ui_loop->PostTask(FROM_HERE, NewRunnableMethod( | 257 ChromeThread::PostTask( |
| 260 this, &BrowsingDataRemover::ClearedCache)); | 258 ChromeThread::UI, FROM_HERE, |
| 259 NewRunnableMethod(this, &BrowsingDataRemover::ClearedCache)); |
| 261 } | 260 } |
| OLD | NEW |