| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 URLRequestContextGetter* main_context_getter, | 233 URLRequestContextGetter* main_context_getter, |
| 234 URLRequestContextGetter* media_context_getter, | 234 URLRequestContextGetter* media_context_getter, |
| 235 base::Time delete_begin, | 235 base::Time delete_begin, |
| 236 base::Time delete_end) { | 236 base::Time delete_end) { |
| 237 // This function should be called on the IO thread. | 237 // This function should be called on the IO thread. |
| 238 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 238 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 239 | 239 |
| 240 // Get a pointer to the cache. | 240 // Get a pointer to the cache. |
| 241 net::HttpTransactionFactory* factory = | 241 net::HttpTransactionFactory* factory = |
| 242 main_context_getter->GetURLRequestContext()->http_transaction_factory(); | 242 main_context_getter->GetURLRequestContext()->http_transaction_factory(); |
| 243 disk_cache::Backend* cache = factory->GetCache()->disk_cache(); | 243 disk_cache::Backend* cache = factory->GetCache()->GetBackend(); |
| 244 | 244 |
| 245 // |cache| can be null since it is lazily initialized, in this case we do | 245 // |cache| can be null if it cannot be initialized. |
| 246 // nothing. | |
| 247 if (cache) { | 246 if (cache) { |
| 248 if (delete_begin.is_null()) | 247 if (delete_begin.is_null()) |
| 249 cache->DoomAllEntries(); | 248 cache->DoomAllEntries(); |
| 250 else | 249 else |
| 251 cache->DoomEntriesBetween(delete_begin, delete_end); | 250 cache->DoomEntriesBetween(delete_begin, delete_end); |
| 252 } | 251 } |
| 253 | 252 |
| 254 // Get a pointer to the media cache. | 253 // Get a pointer to the media cache. |
| 255 factory = media_context_getter->GetURLRequestContext()-> | 254 factory = media_context_getter->GetURLRequestContext()-> |
| 256 http_transaction_factory(); | 255 http_transaction_factory(); |
| 257 cache = factory->GetCache()->disk_cache(); | 256 cache = factory->GetCache()->GetBackend(); |
| 258 | 257 |
| 259 // |cache| can be null since it is lazily initialized, in this case we do | 258 // |cache| can be null if it cannot be initialized. |
| 260 // nothing. | |
| 261 if (cache) { | 259 if (cache) { |
| 262 if (delete_begin.is_null()) | 260 if (delete_begin.is_null()) |
| 263 cache->DoomAllEntries(); | 261 cache->DoomAllEntries(); |
| 264 else | 262 else |
| 265 cache->DoomEntriesBetween(delete_begin, delete_end); | 263 cache->DoomEntriesBetween(delete_begin, delete_end); |
| 266 } | 264 } |
| 267 | 265 |
| 268 // Balance the AddRef()s done on the UI thread by Remove(). | 266 // Balance the AddRef()s done on the UI thread by Remove(). |
| 269 main_context_getter->Release(); | 267 main_context_getter->Release(); |
| 270 media_context_getter->Release(); | 268 media_context_getter->Release(); |
| 271 | 269 |
| 272 // Notify the UI thread that we are done. | 270 // Notify the UI thread that we are done. |
| 273 ChromeThread::PostTask( | 271 ChromeThread::PostTask( |
| 274 ChromeThread::UI, FROM_HERE, | 272 ChromeThread::UI, FROM_HERE, |
| 275 NewRunnableMethod(this, &BrowsingDataRemover::ClearedCache)); | 273 NewRunnableMethod(this, &BrowsingDataRemover::ClearedCache)); |
| 276 } | 274 } |
| OLD | NEW |