| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 // Extract history::URLRows into GURLs for VisitedLinkMaster. | 96 // Extract history::URLRows into GURLs for VisitedLinkMaster. |
| 97 class URLIteratorFromURLRows | 97 class URLIteratorFromURLRows |
| 98 : public visitedlink::VisitedLinkMaster::URLIterator { | 98 : public visitedlink::VisitedLinkMaster::URLIterator { |
| 99 public: | 99 public: |
| 100 explicit URLIteratorFromURLRows(const history::URLRows& url_rows) | 100 explicit URLIteratorFromURLRows(const history::URLRows& url_rows) |
| 101 : itr_(url_rows.begin()), | 101 : itr_(url_rows.begin()), |
| 102 end_(url_rows.end()) { | 102 end_(url_rows.end()) { |
| 103 } | 103 } |
| 104 | 104 |
| 105 virtual const GURL& NextURL() override { | 105 const GURL& NextURL() override { return (itr_++)->url(); } |
| 106 return (itr_++)->url(); | |
| 107 } | |
| 108 | 106 |
| 109 virtual bool HasNextURL() const override { | 107 bool HasNextURL() const override { return itr_ != end_; } |
| 110 return itr_ != end_; | |
| 111 } | |
| 112 | 108 |
| 113 private: | 109 private: |
| 114 history::URLRows::const_iterator itr_; | 110 history::URLRows::const_iterator itr_; |
| 115 history::URLRows::const_iterator end_; | 111 history::URLRows::const_iterator end_; |
| 116 | 112 |
| 117 DISALLOW_COPY_AND_ASSIGN(URLIteratorFromURLRows); | 113 DISALLOW_COPY_AND_ASSIGN(URLIteratorFromURLRows); |
| 118 }; | 114 }; |
| 119 | 115 |
| 120 // Callback from WebHistoryService::ExpireWebHistory(). | 116 // Callback from WebHistoryService::ExpireWebHistory(). |
| 121 void ExpireWebHistoryComplete(bool success) { | 117 void ExpireWebHistoryComplete(bool success) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 135 public: | 131 public: |
| 136 BackendDelegate( | 132 BackendDelegate( |
| 137 const base::WeakPtr<HistoryService>& history_service, | 133 const base::WeakPtr<HistoryService>& history_service, |
| 138 const scoped_refptr<base::SequencedTaskRunner>& service_task_runner, | 134 const scoped_refptr<base::SequencedTaskRunner>& service_task_runner, |
| 139 Profile* profile) | 135 Profile* profile) |
| 140 : history_service_(history_service), | 136 : history_service_(history_service), |
| 141 service_task_runner_(service_task_runner), | 137 service_task_runner_(service_task_runner), |
| 142 profile_(profile) { | 138 profile_(profile) { |
| 143 } | 139 } |
| 144 | 140 |
| 145 virtual void NotifyProfileError(sql::InitStatus init_status) override { | 141 void NotifyProfileError(sql::InitStatus init_status) override { |
| 146 // Send to the history service on the main thread. | 142 // Send to the history service on the main thread. |
| 147 service_task_runner_->PostTask( | 143 service_task_runner_->PostTask( |
| 148 FROM_HERE, | 144 FROM_HERE, |
| 149 base::Bind(&HistoryService::NotifyProfileError, history_service_, | 145 base::Bind(&HistoryService::NotifyProfileError, history_service_, |
| 150 init_status)); | 146 init_status)); |
| 151 } | 147 } |
| 152 | 148 |
| 153 virtual void SetInMemoryBackend( | 149 void SetInMemoryBackend( |
| 154 scoped_ptr<history::InMemoryHistoryBackend> backend) override { | 150 scoped_ptr<history::InMemoryHistoryBackend> backend) override { |
| 155 // Send the backend to the history service on the main thread. | 151 // Send the backend to the history service on the main thread. |
| 156 service_task_runner_->PostTask( | 152 service_task_runner_->PostTask( |
| 157 FROM_HERE, | 153 FROM_HERE, |
| 158 base::Bind(&HistoryService::SetInMemoryBackend, history_service_, | 154 base::Bind(&HistoryService::SetInMemoryBackend, history_service_, |
| 159 base::Passed(&backend))); | 155 base::Passed(&backend))); |
| 160 } | 156 } |
| 161 | 157 |
| 162 virtual void NotifyAddVisit(const history::BriefVisitInfo& info) override { | 158 void NotifyAddVisit(const history::BriefVisitInfo& info) override { |
| 163 service_task_runner_->PostTask( | 159 service_task_runner_->PostTask( |
| 164 FROM_HERE, | 160 FROM_HERE, |
| 165 base::Bind(&HistoryService::NotifyAddVisit, history_service_, info)); | 161 base::Bind(&HistoryService::NotifyAddVisit, history_service_, info)); |
| 166 } | 162 } |
| 167 | 163 |
| 168 virtual void NotifyFaviconChanged(const std::set<GURL>& urls) override { | 164 void NotifyFaviconChanged(const std::set<GURL>& urls) override { |
| 169 // Send the notification to the history service on the main thread. | 165 // Send the notification to the history service on the main thread. |
| 170 service_task_runner_->PostTask( | 166 service_task_runner_->PostTask( |
| 171 FROM_HERE, | 167 FROM_HERE, |
| 172 base::Bind( | 168 base::Bind( |
| 173 &HistoryService::NotifyFaviconChanged, history_service_, urls)); | 169 &HistoryService::NotifyFaviconChanged, history_service_, urls)); |
| 174 } | 170 } |
| 175 | 171 |
| 176 virtual void NotifyURLVisited(ui::PageTransition transition, | 172 void NotifyURLVisited(ui::PageTransition transition, |
| 177 const history::URLRow& row, | 173 const history::URLRow& row, |
| 178 const history::RedirectList& redirects, | 174 const history::RedirectList& redirects, |
| 179 base::Time visit_time) override { | 175 base::Time visit_time) override { |
| 180 service_task_runner_->PostTask(FROM_HERE, | 176 service_task_runner_->PostTask(FROM_HERE, |
| 181 base::Bind(&HistoryService::NotifyURLVisited, | 177 base::Bind(&HistoryService::NotifyURLVisited, |
| 182 history_service_, | 178 history_service_, |
| 183 transition, | 179 transition, |
| 184 row, | 180 row, |
| 185 redirects, | 181 redirects, |
| 186 visit_time)); | 182 visit_time)); |
| 187 } | 183 } |
| 188 | 184 |
| 189 virtual void BroadcastNotifications( | 185 void BroadcastNotifications( |
| 190 int type, | 186 int type, |
| 191 scoped_ptr<history::HistoryDetails> details) override { | 187 scoped_ptr<history::HistoryDetails> details) override { |
| 192 // Send the notification on the history thread. | 188 // Send the notification on the history thread. |
| 193 if (content::NotificationService::current()) { | 189 if (content::NotificationService::current()) { |
| 194 content::Details<history::HistoryDetails> det(details.get()); | 190 content::Details<history::HistoryDetails> det(details.get()); |
| 195 content::NotificationService::current()->Notify( | 191 content::NotificationService::current()->Notify( |
| 196 type, content::Source<Profile>(profile_), det); | 192 type, content::Source<Profile>(profile_), det); |
| 197 } | 193 } |
| 198 // Send the notification to the history service on the main thread. | 194 // Send the notification to the history service on the main thread. |
| 199 service_task_runner_->PostTask( | 195 service_task_runner_->PostTask( |
| 200 FROM_HERE, | 196 FROM_HERE, |
| 201 base::Bind(&HistoryService::BroadcastNotificationsHelper, | 197 base::Bind(&HistoryService::BroadcastNotificationsHelper, |
| 202 history_service_, type, base::Passed(&details))); | 198 history_service_, type, base::Passed(&details))); |
| 203 } | 199 } |
| 204 | 200 |
| 205 virtual void DBLoaded() override { | 201 void DBLoaded() override { |
| 206 service_task_runner_->PostTask( | 202 service_task_runner_->PostTask( |
| 207 FROM_HERE, | 203 FROM_HERE, |
| 208 base::Bind(&HistoryService::OnDBLoaded, history_service_)); | 204 base::Bind(&HistoryService::OnDBLoaded, history_service_)); |
| 209 } | 205 } |
| 210 | 206 |
| 211 private: | 207 private: |
| 212 const base::WeakPtr<HistoryService> history_service_; | 208 const base::WeakPtr<HistoryService> history_service_; |
| 213 const scoped_refptr<base::SequencedTaskRunner> service_task_runner_; | 209 const scoped_refptr<base::SequencedTaskRunner> service_task_runner_; |
| 214 Profile* const profile_; | 210 Profile* const profile_; |
| 215 }; | 211 }; |
| (...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 const HistoryService::OnFaviconChangedCallback& callback) { | 1260 const HistoryService::OnFaviconChangedCallback& callback) { |
| 1265 DCHECK(thread_checker_.CalledOnValidThread()); | 1261 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1266 return favicon_changed_callback_list_.Add(callback); | 1262 return favicon_changed_callback_list_.Add(callback); |
| 1267 } | 1263 } |
| 1268 | 1264 |
| 1269 void HistoryService::NotifyFaviconChanged( | 1265 void HistoryService::NotifyFaviconChanged( |
| 1270 const std::set<GURL>& changed_favicons) { | 1266 const std::set<GURL>& changed_favicons) { |
| 1271 DCHECK(thread_checker_.CalledOnValidThread()); | 1267 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1272 favicon_changed_callback_list_.Notify(changed_favicons); | 1268 favicon_changed_callback_list_.Notify(changed_favicons); |
| 1273 } | 1269 } |
| OLD | NEW |