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/browser_process.h" | |
9 #include "chrome/browser/download/download_manager.h" | 8 #include "chrome/browser/download/download_manager.h" |
10 #include "chrome/browser/history/history.h" | 9 #include "chrome/browser/history/history.h" |
11 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
12 #include "chrome/browser/metrics/user_metrics.h" | 11 #include "chrome/browser/metrics/user_metrics.h" |
13 #include "chrome/browser/net/url_request_context_getter.h" | 12 #include "chrome/browser/net/url_request_context_getter.h" |
14 #include "chrome/browser/password_manager/password_store.h" | 13 #include "chrome/browser/password_manager/password_store.h" |
15 #include "chrome/browser/search_engines/template_url_model.h" | 14 #include "chrome/browser/search_engines/template_url_model.h" |
16 #include "chrome/browser/sessions/session_service.h" | 15 #include "chrome/browser/sessions/session_service.h" |
17 #include "chrome/browser/sessions/tab_restore_service.h" | 16 #include "chrome/browser/sessions/tab_restore_service.h" |
18 #include "chrome/browser/webdata/web_data_service.h" | 17 #include "chrome/browser/webdata/web_data_service.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 UserMetrics::RecordAction(L"ClearBrowsingData_Autofill", profile_); | 125 UserMetrics::RecordAction(L"ClearBrowsingData_Autofill", profile_); |
127 WebDataService* web_data_service = | 126 WebDataService* web_data_service = |
128 profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); | 127 profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); |
129 | 128 |
130 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, | 129 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, |
131 delete_end_); | 130 delete_end_); |
132 } | 131 } |
133 | 132 |
134 if (remove_mask & REMOVE_CACHE) { | 133 if (remove_mask & REMOVE_CACHE) { |
135 // Invoke ClearBrowsingDataView::ClearCache on the IO thread. | 134 // Invoke ClearBrowsingDataView::ClearCache on the IO thread. |
136 base::Thread* thread = g_browser_process->io_thread(); | 135 waiting_for_clear_cache_ = true; |
137 if (thread) { | 136 UserMetrics::RecordAction(L"ClearBrowsingData_Cache", profile_); |
138 waiting_for_clear_cache_ = true; | 137 ChromeThread::PostTask( |
139 UserMetrics::RecordAction(L"ClearBrowsingData_Cache", profile_); | 138 ChromeThread::IO, FROM_HERE, |
140 thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 139 NewRunnableMethod( |
141 this, | 140 this, |
142 &BrowsingDataRemover::ClearCacheOnIOThread, | 141 &BrowsingDataRemover::ClearCacheOnIOThread, |
143 profile_->GetRequestContext(), | 142 profile_->GetRequestContext(), |
144 delete_begin_, | 143 delete_begin_, |
145 delete_end_, | 144 delete_end_, |
146 MessageLoop::current())); | 145 MessageLoop::current())); |
147 } | |
148 } | 146 } |
149 | 147 |
150 NotifyAndDeleteIfDone(); | 148 NotifyAndDeleteIfDone(); |
151 } | 149 } |
152 | 150 |
153 void BrowsingDataRemover::AddObserver(Observer* observer) { | 151 void BrowsingDataRemover::AddObserver(Observer* observer) { |
154 observer_list_.AddObserver(observer); | 152 observer_list_.AddObserver(observer); |
155 } | 153 } |
156 | 154 |
157 void BrowsingDataRemover::RemoveObserver(Observer* observer) { | 155 void BrowsingDataRemover::RemoveObserver(Observer* observer) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 if (delete_begin.is_null()) | 252 if (delete_begin.is_null()) |
255 cache->DoomAllEntries(); | 253 cache->DoomAllEntries(); |
256 else | 254 else |
257 cache->DoomEntriesBetween(delete_begin, delete_end); | 255 cache->DoomEntriesBetween(delete_begin, delete_end); |
258 } | 256 } |
259 | 257 |
260 // Notify the UI thread that we are done. | 258 // Notify the UI thread that we are done. |
261 ui_loop->PostTask(FROM_HERE, NewRunnableMethod( | 259 ui_loop->PostTask(FROM_HERE, NewRunnableMethod( |
262 this, &BrowsingDataRemover::ClearedCache)); | 260 this, &BrowsingDataRemover::ClearedCache)); |
263 } | 261 } |
OLD | NEW |