| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 history_service_, init_status)); | 109 history_service_, init_status)); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void SetInMemoryBackend(scoped_ptr<InMemoryHistoryBackend> backend) override { | 112 void SetInMemoryBackend(scoped_ptr<InMemoryHistoryBackend> backend) override { |
| 113 // Send the backend to the history service on the main thread. | 113 // Send the backend to the history service on the main thread. |
| 114 service_task_runner_->PostTask( | 114 service_task_runner_->PostTask( |
| 115 FROM_HERE, base::Bind(&HistoryService::SetInMemoryBackend, | 115 FROM_HERE, base::Bind(&HistoryService::SetInMemoryBackend, |
| 116 history_service_, base::Passed(&backend))); | 116 history_service_, base::Passed(&backend))); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void NotifyAddVisit(const BriefVisitInfo& info) override { | |
| 120 service_task_runner_->PostTask( | |
| 121 FROM_HERE, | |
| 122 base::Bind(&HistoryService::NotifyAddVisit, history_service_, info)); | |
| 123 } | |
| 124 | |
| 125 void NotifyFaviconChanged(const std::set<GURL>& urls) override { | 119 void NotifyFaviconChanged(const std::set<GURL>& urls) override { |
| 126 // Send the notification to the history service on the main thread. | 120 // Send the notification to the history service on the main thread. |
| 127 service_task_runner_->PostTask( | 121 service_task_runner_->PostTask( |
| 128 FROM_HERE, base::Bind(&HistoryService::NotifyFaviconChanged, | 122 FROM_HERE, base::Bind(&HistoryService::NotifyFaviconChanged, |
| 129 history_service_, urls)); | 123 history_service_, urls)); |
| 130 } | 124 } |
| 131 | 125 |
| 132 void NotifyURLVisited(ui::PageTransition transition, | 126 void NotifyURLVisited(ui::PageTransition transition, |
| 133 const URLRow& row, | 127 const URLRow& row, |
| 134 const RedirectList& redirects, | 128 const RedirectList& redirects, |
| (...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 backend_loaded_ = true; | 1024 backend_loaded_ = true; |
| 1031 NotifyHistoryServiceLoaded(); | 1025 NotifyHistoryServiceLoaded(); |
| 1032 } | 1026 } |
| 1033 | 1027 |
| 1034 bool HistoryService::GetRowForURL(const GURL& url, URLRow* url_row) { | 1028 bool HistoryService::GetRowForURL(const GURL& url, URLRow* url_row) { |
| 1035 DCHECK(thread_checker_.CalledOnValidThread()); | 1029 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1036 URLDatabase* db = InMemoryDatabase(); | 1030 URLDatabase* db = InMemoryDatabase(); |
| 1037 return db && (db->GetRowForURL(url, url_row) != 0); | 1031 return db && (db->GetRowForURL(url, url_row) != 0); |
| 1038 } | 1032 } |
| 1039 | 1033 |
| 1040 void HistoryService::NotifyAddVisit(const BriefVisitInfo& info) { | |
| 1041 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 1042 FOR_EACH_OBSERVER(HistoryServiceObserver, observers_, OnAddVisit(this, info)); | |
| 1043 } | |
| 1044 | |
| 1045 void HistoryService::NotifyURLVisited(ui::PageTransition transition, | 1034 void HistoryService::NotifyURLVisited(ui::PageTransition transition, |
| 1046 const URLRow& row, | 1035 const URLRow& row, |
| 1047 const RedirectList& redirects, | 1036 const RedirectList& redirects, |
| 1048 base::Time visit_time) { | 1037 base::Time visit_time) { |
| 1049 DCHECK(thread_checker_.CalledOnValidThread()); | 1038 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1050 FOR_EACH_OBSERVER(HistoryServiceObserver, observers_, | 1039 FOR_EACH_OBSERVER(HistoryServiceObserver, observers_, |
| 1051 OnURLVisited(this, transition, row, redirects, visit_time)); | 1040 OnURLVisited(this, transition, row, redirects, visit_time)); |
| 1052 } | 1041 } |
| 1053 | 1042 |
| 1054 void HistoryService::NotifyURLsModified(const URLRows& changed_urls) { | 1043 void HistoryService::NotifyURLsModified(const URLRows& changed_urls) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 return favicon_changed_callback_list_.Add(callback); | 1113 return favicon_changed_callback_list_.Add(callback); |
| 1125 } | 1114 } |
| 1126 | 1115 |
| 1127 void HistoryService::NotifyFaviconChanged( | 1116 void HistoryService::NotifyFaviconChanged( |
| 1128 const std::set<GURL>& changed_favicons) { | 1117 const std::set<GURL>& changed_favicons) { |
| 1129 DCHECK(thread_checker_.CalledOnValidThread()); | 1118 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1130 favicon_changed_callback_list_.Notify(changed_favicons); | 1119 favicon_changed_callback_list_.Notify(changed_favicons); |
| 1131 } | 1120 } |
| 1132 | 1121 |
| 1133 } // namespace history | 1122 } // namespace history |
| OLD | NEW |