| 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 14 matching lines...) Expand all Loading... |
| 25 #include "base/location.h" | 25 #include "base/location.h" |
| 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/thread_task_runner_handle.h" | 28 #include "base/thread_task_runner_handle.h" |
| 29 #include "base/threading/thread.h" | 29 #include "base/threading/thread.h" |
| 30 #include "base/time/time.h" | 30 #include "base/time/time.h" |
| 31 #include "chrome/browser/history/history_backend.h" | 31 #include "chrome/browser/history/history_backend.h" |
| 32 #include "chrome/browser/history/in_memory_history_backend.h" | 32 #include "chrome/browser/history/in_memory_history_backend.h" |
| 33 #include "chrome/browser/history/in_memory_url_index.h" | 33 #include "chrome/browser/history/in_memory_url_index.h" |
| 34 #include "chrome/browser/history/web_history_service.h" | 34 #include "chrome/browser/history/web_history_service.h" |
| 35 #include "chrome/browser/history/web_history_service_factory.h" | |
| 36 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
| 37 #include "chrome/common/importer/imported_favicon_usage.h" | 36 #include "chrome/common/importer/imported_favicon_usage.h" |
| 38 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
| 39 #include "components/dom_distiller/core/url_constants.h" | 38 #include "components/dom_distiller/core/url_constants.h" |
| 40 #include "components/history/core/browser/download_row.h" | 39 #include "components/history/core/browser/download_row.h" |
| 41 #include "components/history/core/browser/history_client.h" | 40 #include "components/history/core/browser/history_client.h" |
| 42 #include "components/history/core/browser/history_database_params.h" | 41 #include "components/history/core/browser/history_database_params.h" |
| 43 #include "components/history/core/browser/history_service_observer.h" | 42 #include "components/history/core/browser/history_service_observer.h" |
| 44 #include "components/history/core/browser/history_types.h" | 43 #include "components/history/core/browser/history_types.h" |
| 45 #include "components/history/core/browser/in_memory_database.h" | 44 #include "components/history/core/browser/in_memory_database.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 const base::WeakPtr<HistoryService> history_service_; | 209 const base::WeakPtr<HistoryService> history_service_; |
| 211 const scoped_refptr<base::SequencedTaskRunner> service_task_runner_; | 210 const scoped_refptr<base::SequencedTaskRunner> service_task_runner_; |
| 212 }; | 211 }; |
| 213 | 212 |
| 214 // The history thread is intentionally not a BrowserThread because the | 213 // The history thread is intentionally not a BrowserThread because the |
| 215 // sync integration unit tests depend on being able to create more than one | 214 // sync integration unit tests depend on being able to create more than one |
| 216 // history thread. | 215 // history thread. |
| 217 HistoryService::HistoryService() | 216 HistoryService::HistoryService() |
| 218 : thread_(new base::Thread(kHistoryThreadName)), | 217 : thread_(new base::Thread(kHistoryThreadName)), |
| 219 history_client_(NULL), | 218 history_client_(NULL), |
| 220 profile_(NULL), | |
| 221 backend_loaded_(false), | 219 backend_loaded_(false), |
| 222 no_db_(false), | 220 no_db_(false), |
| 223 weak_ptr_factory_(this) { | 221 weak_ptr_factory_(this) { |
| 224 } | 222 } |
| 225 | 223 |
| 226 HistoryService::HistoryService( | 224 HistoryService::HistoryService( |
| 227 history::HistoryClient* history_client, Profile* profile) | 225 history::HistoryClient* history_client, Profile* profile) |
| 228 : thread_(new base::Thread(kHistoryThreadName)), | 226 : thread_(new base::Thread(kHistoryThreadName)), |
| 229 history_client_(history_client), | 227 history_client_(history_client), |
| 230 profile_(profile), | |
| 231 visitedlink_master_(new visitedlink::VisitedLinkMaster( | 228 visitedlink_master_(new visitedlink::VisitedLinkMaster( |
| 232 profile, this, true)), | 229 profile, this, true)), |
| 233 backend_loaded_(false), | 230 backend_loaded_(false), |
| 234 no_db_(false), | 231 no_db_(false), |
| 235 weak_ptr_factory_(this) { | 232 weak_ptr_factory_(this) { |
| 236 } | 233 } |
| 237 | 234 |
| 238 HistoryService::~HistoryService() { | 235 HistoryService::~HistoryService() { |
| 239 DCHECK(thread_checker_.CalledOnValidThread()); | 236 DCHECK(thread_checker_.CalledOnValidThread()); |
| 240 // Shutdown the backend. This does nothing if Cleanup was already invoked. | 237 // Shutdown the backend. This does nothing if Cleanup was already invoked. |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 DCHECK(thread_) << "History service being called after cleanup"; | 1144 DCHECK(thread_) << "History service being called after cleanup"; |
| 1148 DCHECK(thread_checker_.CalledOnValidThread()); | 1145 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1149 tracker->PostTaskAndReply( | 1146 tracker->PostTaskAndReply( |
| 1150 thread_->message_loop_proxy().get(), | 1147 thread_->message_loop_proxy().get(), |
| 1151 FROM_HERE, | 1148 FROM_HERE, |
| 1152 base::Bind(&HistoryBackend::ExpireHistory, history_backend_, expire_list), | 1149 base::Bind(&HistoryBackend::ExpireHistory, history_backend_, expire_list), |
| 1153 callback); | 1150 callback); |
| 1154 } | 1151 } |
| 1155 | 1152 |
| 1156 void HistoryService::ExpireLocalAndRemoteHistoryBetween( | 1153 void HistoryService::ExpireLocalAndRemoteHistoryBetween( |
| 1154 history::WebHistoryService* web_history, |
| 1157 const std::set<GURL>& restrict_urls, | 1155 const std::set<GURL>& restrict_urls, |
| 1158 Time begin_time, | 1156 Time begin_time, |
| 1159 Time end_time, | 1157 Time end_time, |
| 1160 const base::Closure& callback, | 1158 const base::Closure& callback, |
| 1161 base::CancelableTaskTracker* tracker) { | 1159 base::CancelableTaskTracker* tracker) { |
| 1162 // TODO(dubroy): This should be factored out into a separate class that | 1160 // TODO(dubroy): This should be factored out into a separate class that |
| 1163 // dispatches deletions to the proper places. | 1161 // dispatches deletions to the proper places. |
| 1164 | |
| 1165 history::WebHistoryService* web_history = | |
| 1166 WebHistoryServiceFactory::GetForProfile(profile_); | |
| 1167 if (web_history) { | 1162 if (web_history) { |
| 1168 // TODO(dubroy): This API does not yet support deletion of specific URLs. | 1163 // TODO(dubroy): This API does not yet support deletion of specific URLs. |
| 1169 DCHECK(restrict_urls.empty()); | 1164 DCHECK(restrict_urls.empty()); |
| 1170 | 1165 |
| 1171 delete_directive_handler_.CreateDeleteDirectives( | 1166 delete_directive_handler_.CreateDeleteDirectives( |
| 1172 std::set<int64>(), begin_time, end_time); | 1167 std::set<int64>(), begin_time, end_time); |
| 1173 | 1168 |
| 1174 // Attempt online deletion from the history server, but ignore the result. | 1169 // Attempt online deletion from the history server, but ignore the result. |
| 1175 // Deletion directives ensure that the results will eventually be deleted. | 1170 // Deletion directives ensure that the results will eventually be deleted. |
| 1176 // | 1171 // |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 const HistoryService::OnFaviconChangedCallback& callback) { | 1276 const HistoryService::OnFaviconChangedCallback& callback) { |
| 1282 DCHECK(thread_checker_.CalledOnValidThread()); | 1277 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1283 return favicon_changed_callback_list_.Add(callback); | 1278 return favicon_changed_callback_list_.Add(callback); |
| 1284 } | 1279 } |
| 1285 | 1280 |
| 1286 void HistoryService::NotifyFaviconChanged( | 1281 void HistoryService::NotifyFaviconChanged( |
| 1287 const std::set<GURL>& changed_favicons) { | 1282 const std::set<GURL>& changed_favicons) { |
| 1288 DCHECK(thread_checker_.CalledOnValidThread()); | 1283 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1289 favicon_changed_callback_list_.Notify(changed_favicons); | 1284 favicon_changed_callback_list_.Notify(changed_favicons); |
| 1290 } | 1285 } |
| OLD | NEW |