OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // The history system runs on a background thread so that potentially slow | 5 // The history system runs on a background thread so that potentially slow |
6 // database operations don't delay the browser. This backend processing is | 6 // database operations don't delay the browser. This backend processing is |
7 // represented by HistoryBackend. The HistoryService's job is to dispatch to | 7 // represented by HistoryBackend. The HistoryService's job is to dispatch to |
8 // that thread. | 8 // that thread. |
9 // | 9 // |
10 // Main thread History thread | 10 // Main thread History thread |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "base/memory/ref_counted.h" | 26 #include "base/memory/ref_counted.h" |
27 #include "base/message_loop/message_loop.h" | 27 #include "base/message_loop/message_loop.h" |
28 #include "base/prefs/pref_service.h" | 28 #include "base/prefs/pref_service.h" |
29 #include "base/thread_task_runner_handle.h" | 29 #include "base/thread_task_runner_handle.h" |
30 #include "base/threading/thread.h" | 30 #include "base/threading/thread.h" |
31 #include "base/time/time.h" | 31 #include "base/time/time.h" |
32 #include "chrome/browser/browser_process.h" | 32 #include "chrome/browser/browser_process.h" |
33 #include "chrome/browser/history/history_backend.h" | 33 #include "chrome/browser/history/history_backend.h" |
34 #include "chrome/browser/history/in_memory_history_backend.h" | 34 #include "chrome/browser/history/in_memory_history_backend.h" |
35 #include "chrome/browser/history/in_memory_url_index.h" | 35 #include "chrome/browser/history/in_memory_url_index.h" |
36 #include "chrome/browser/history/web_history_service_factory.h" | |
37 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
38 #include "chrome/common/chrome_constants.h" | 37 #include "chrome/common/chrome_constants.h" |
39 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
40 #include "chrome/common/importer/imported_favicon_usage.h" | 39 #include "chrome/common/importer/imported_favicon_usage.h" |
41 #include "chrome/common/pref_names.h" | 40 #include "chrome/common/pref_names.h" |
42 #include "chrome/common/url_constants.h" | 41 #include "chrome/common/url_constants.h" |
43 #include "components/dom_distiller/core/url_constants.h" | 42 #include "components/dom_distiller/core/url_constants.h" |
44 #include "components/history/core/browser/download_row.h" | 43 #include "components/history/core/browser/download_row.h" |
45 #include "components/history/core/browser/history_client.h" | 44 #include "components/history/core/browser/history_client.h" |
46 #include "components/history/core/browser/history_database_params.h" | 45 #include "components/history/core/browser/history_database_params.h" |
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 DCHECK(thread_) << "History service being called after cleanup"; | 1158 DCHECK(thread_) << "History service being called after cleanup"; |
1160 DCHECK(thread_checker_.CalledOnValidThread()); | 1159 DCHECK(thread_checker_.CalledOnValidThread()); |
1161 tracker->PostTaskAndReply( | 1160 tracker->PostTaskAndReply( |
1162 thread_->message_loop_proxy().get(), | 1161 thread_->message_loop_proxy().get(), |
1163 FROM_HERE, | 1162 FROM_HERE, |
1164 base::Bind(&HistoryBackend::ExpireHistory, history_backend_, expire_list), | 1163 base::Bind(&HistoryBackend::ExpireHistory, history_backend_, expire_list), |
1165 callback); | 1164 callback); |
1166 } | 1165 } |
1167 | 1166 |
1168 void HistoryService::ExpireLocalAndRemoteHistoryBetween( | 1167 void HistoryService::ExpireLocalAndRemoteHistoryBetween( |
| 1168 history::WebHistoryService* web_history, |
1169 const std::set<GURL>& restrict_urls, | 1169 const std::set<GURL>& restrict_urls, |
1170 Time begin_time, | 1170 Time begin_time, |
1171 Time end_time, | 1171 Time end_time, |
1172 const base::Closure& callback, | 1172 const base::Closure& callback, |
1173 base::CancelableTaskTracker* tracker) { | 1173 base::CancelableTaskTracker* tracker) { |
1174 // TODO(dubroy): This should be factored out into a separate class that | 1174 // TODO(dubroy): This should be factored out into a separate class that |
1175 // dispatches deletions to the proper places. | 1175 // dispatches deletions to the proper places. |
1176 | 1176 |
1177 history::WebHistoryService* web_history = | |
1178 WebHistoryServiceFactory::GetForProfile(profile_); | |
1179 if (web_history) { | 1177 if (web_history) { |
1180 // TODO(dubroy): This API does not yet support deletion of specific URLs. | 1178 // TODO(dubroy): This API does not yet support deletion of specific URLs. |
1181 DCHECK(restrict_urls.empty()); | 1179 DCHECK(restrict_urls.empty()); |
1182 | 1180 |
1183 delete_directive_handler_.CreateDeleteDirectives( | 1181 delete_directive_handler_.CreateDeleteDirectives( |
1184 std::set<int64>(), begin_time, end_time); | 1182 std::set<int64>(), begin_time, end_time); |
1185 | 1183 |
1186 // Attempt online deletion from the history server, but ignore the result. | 1184 // Attempt online deletion from the history server, but ignore the result. |
1187 // Deletion directives ensure that the results will eventually be deleted. | 1185 // Deletion directives ensure that the results will eventually be deleted. |
1188 // | 1186 // |
1189 // TODO(davidben): |callback| should not run until this operation completes | 1187 // TODO(davidben): |callback| should not run until this operation completes |
1190 // too. | 1188 // too. |
1191 web_history->ExpireHistoryBetween( | 1189 web_history->ExpireHistoryBetween(restrict_urls, begin_time, end_time, |
1192 restrict_urls, begin_time, end_time, | 1190 base::Bind(&ExpireWebHistoryComplete)); |
1193 base::Bind(&ExpireWebHistoryComplete)); | |
1194 } | 1191 } |
1195 ExpireHistoryBetween(restrict_urls, begin_time, end_time, callback, tracker); | 1192 ExpireHistoryBetween(restrict_urls, begin_time, end_time, callback, tracker); |
1196 } | 1193 } |
1197 | 1194 |
1198 void HistoryService::OnDBLoaded() { | 1195 void HistoryService::OnDBLoaded() { |
1199 DCHECK(thread_checker_.CalledOnValidThread()); | 1196 DCHECK(thread_checker_.CalledOnValidThread()); |
1200 backend_loaded_ = true; | 1197 backend_loaded_ = true; |
1201 NotifyHistoryServiceLoaded(); | 1198 NotifyHistoryServiceLoaded(); |
1202 } | 1199 } |
1203 | 1200 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 const HistoryService::OnFaviconChangedCallback& callback) { | 1290 const HistoryService::OnFaviconChangedCallback& callback) { |
1294 DCHECK(thread_checker_.CalledOnValidThread()); | 1291 DCHECK(thread_checker_.CalledOnValidThread()); |
1295 return favicon_changed_callback_list_.Add(callback); | 1292 return favicon_changed_callback_list_.Add(callback); |
1296 } | 1293 } |
1297 | 1294 |
1298 void HistoryService::NotifyFaviconChanged( | 1295 void HistoryService::NotifyFaviconChanged( |
1299 const std::set<GURL>& changed_favicons) { | 1296 const std::set<GURL>& changed_favicons) { |
1300 DCHECK(thread_checker_.CalledOnValidThread()); | 1297 DCHECK(thread_checker_.CalledOnValidThread()); |
1301 favicon_changed_callback_list_.Notify(changed_favicons); | 1298 favicon_changed_callback_list_.Notify(changed_favicons); |
1302 } | 1299 } |
OLD | NEW |