| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 // Extract history::URLRows into GURLs for VisitedLinkMaster. | 95 // Extract history::URLRows into GURLs for VisitedLinkMaster. |
| 96 class URLIteratorFromURLRows | 96 class URLIteratorFromURLRows |
| 97 : public visitedlink::VisitedLinkMaster::URLIterator { | 97 : public visitedlink::VisitedLinkMaster::URLIterator { |
| 98 public: | 98 public: |
| 99 explicit URLIteratorFromURLRows(const history::URLRows& url_rows) | 99 explicit URLIteratorFromURLRows(const history::URLRows& url_rows) |
| 100 : itr_(url_rows.begin()), | 100 : itr_(url_rows.begin()), |
| 101 end_(url_rows.end()) { | 101 end_(url_rows.end()) { |
| 102 } | 102 } |
| 103 | 103 |
| 104 virtual const GURL& NextURL() OVERRIDE { | 104 virtual const GURL& NextURL() override { |
| 105 return (itr_++)->url(); | 105 return (itr_++)->url(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 virtual bool HasNextURL() const OVERRIDE { | 108 virtual bool HasNextURL() const override { |
| 109 return itr_ != end_; | 109 return itr_ != end_; |
| 110 } | 110 } |
| 111 | 111 |
| 112 private: | 112 private: |
| 113 history::URLRows::const_iterator itr_; | 113 history::URLRows::const_iterator itr_; |
| 114 history::URLRows::const_iterator end_; | 114 history::URLRows::const_iterator end_; |
| 115 | 115 |
| 116 DISALLOW_COPY_AND_ASSIGN(URLIteratorFromURLRows); | 116 DISALLOW_COPY_AND_ASSIGN(URLIteratorFromURLRows); |
| 117 }; | 117 }; |
| 118 | 118 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 134 public: | 134 public: |
| 135 BackendDelegate( | 135 BackendDelegate( |
| 136 const base::WeakPtr<HistoryService>& history_service, | 136 const base::WeakPtr<HistoryService>& history_service, |
| 137 const scoped_refptr<base::SequencedTaskRunner>& service_task_runner, | 137 const scoped_refptr<base::SequencedTaskRunner>& service_task_runner, |
| 138 Profile* profile) | 138 Profile* profile) |
| 139 : history_service_(history_service), | 139 : history_service_(history_service), |
| 140 service_task_runner_(service_task_runner), | 140 service_task_runner_(service_task_runner), |
| 141 profile_(profile) { | 141 profile_(profile) { |
| 142 } | 142 } |
| 143 | 143 |
| 144 virtual void NotifyProfileError(sql::InitStatus init_status) OVERRIDE { | 144 virtual void NotifyProfileError(sql::InitStatus init_status) override { |
| 145 // Send to the history service on the main thread. | 145 // Send to the history service on the main thread. |
| 146 service_task_runner_->PostTask( | 146 service_task_runner_->PostTask( |
| 147 FROM_HERE, | 147 FROM_HERE, |
| 148 base::Bind(&HistoryService::NotifyProfileError, history_service_, | 148 base::Bind(&HistoryService::NotifyProfileError, history_service_, |
| 149 init_status)); | 149 init_status)); |
| 150 } | 150 } |
| 151 | 151 |
| 152 virtual void SetInMemoryBackend( | 152 virtual void SetInMemoryBackend( |
| 153 scoped_ptr<history::InMemoryHistoryBackend> backend) OVERRIDE { | 153 scoped_ptr<history::InMemoryHistoryBackend> backend) override { |
| 154 // Send the backend to the history service on the main thread. | 154 // Send the backend to the history service on the main thread. |
| 155 service_task_runner_->PostTask( | 155 service_task_runner_->PostTask( |
| 156 FROM_HERE, | 156 FROM_HERE, |
| 157 base::Bind(&HistoryService::SetInMemoryBackend, history_service_, | 157 base::Bind(&HistoryService::SetInMemoryBackend, history_service_, |
| 158 base::Passed(&backend))); | 158 base::Passed(&backend))); |
| 159 } | 159 } |
| 160 | 160 |
| 161 virtual void NotifyFaviconChanged(const std::set<GURL>& urls) OVERRIDE { | 161 virtual void NotifyFaviconChanged(const std::set<GURL>& urls) override { |
| 162 // Send the notification to the history service on the main thread. | 162 // Send the notification to the history service on the main thread. |
| 163 service_task_runner_->PostTask( | 163 service_task_runner_->PostTask( |
| 164 FROM_HERE, | 164 FROM_HERE, |
| 165 base::Bind( | 165 base::Bind( |
| 166 &HistoryService::NotifyFaviconChanged, history_service_, urls)); | 166 &HistoryService::NotifyFaviconChanged, history_service_, urls)); |
| 167 } | 167 } |
| 168 | 168 |
| 169 virtual void BroadcastNotifications( | 169 virtual void BroadcastNotifications( |
| 170 int type, | 170 int type, |
| 171 scoped_ptr<history::HistoryDetails> details) OVERRIDE { | 171 scoped_ptr<history::HistoryDetails> details) override { |
| 172 // Send the notification on the history thread. | 172 // Send the notification on the history thread. |
| 173 if (content::NotificationService::current()) { | 173 if (content::NotificationService::current()) { |
| 174 content::Details<history::HistoryDetails> det(details.get()); | 174 content::Details<history::HistoryDetails> det(details.get()); |
| 175 content::NotificationService::current()->Notify( | 175 content::NotificationService::current()->Notify( |
| 176 type, content::Source<Profile>(profile_), det); | 176 type, content::Source<Profile>(profile_), det); |
| 177 } | 177 } |
| 178 // Send the notification to the history service on the main thread. | 178 // Send the notification to the history service on the main thread. |
| 179 service_task_runner_->PostTask( | 179 service_task_runner_->PostTask( |
| 180 FROM_HERE, | 180 FROM_HERE, |
| 181 base::Bind(&HistoryService::BroadcastNotificationsHelper, | 181 base::Bind(&HistoryService::BroadcastNotificationsHelper, |
| 182 history_service_, type, base::Passed(&details))); | 182 history_service_, type, base::Passed(&details))); |
| 183 } | 183 } |
| 184 | 184 |
| 185 virtual void DBLoaded() OVERRIDE { | 185 virtual void DBLoaded() override { |
| 186 service_task_runner_->PostTask( | 186 service_task_runner_->PostTask( |
| 187 FROM_HERE, | 187 FROM_HERE, |
| 188 base::Bind(&HistoryService::OnDBLoaded, history_service_)); | 188 base::Bind(&HistoryService::OnDBLoaded, history_service_)); |
| 189 } | 189 } |
| 190 | 190 |
| 191 virtual void NotifyVisitDBObserversOnAddVisit( | 191 virtual void NotifyVisitDBObserversOnAddVisit( |
| 192 const history::BriefVisitInfo& info) OVERRIDE { | 192 const history::BriefVisitInfo& info) override { |
| 193 service_task_runner_->PostTask( | 193 service_task_runner_->PostTask( |
| 194 FROM_HERE, | 194 FROM_HERE, |
| 195 base::Bind(&HistoryService::NotifyVisitDBObserversOnAddVisit, | 195 base::Bind(&HistoryService::NotifyVisitDBObserversOnAddVisit, |
| 196 history_service_, info)); | 196 history_service_, info)); |
| 197 } | 197 } |
| 198 | 198 |
| 199 private: | 199 private: |
| 200 const base::WeakPtr<HistoryService> history_service_; | 200 const base::WeakPtr<HistoryService> history_service_; |
| 201 const scoped_refptr<base::SequencedTaskRunner> service_task_runner_; | 201 const scoped_refptr<base::SequencedTaskRunner> service_task_runner_; |
| 202 Profile* const profile_; | 202 Profile* const profile_; |
| (...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 const HistoryService::OnFaviconChangedCallback& callback) { | 1245 const HistoryService::OnFaviconChangedCallback& callback) { |
| 1246 DCHECK(thread_checker_.CalledOnValidThread()); | 1246 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1247 return favicon_changed_callback_list_.Add(callback); | 1247 return favicon_changed_callback_list_.Add(callback); |
| 1248 } | 1248 } |
| 1249 | 1249 |
| 1250 void HistoryService::NotifyFaviconChanged( | 1250 void HistoryService::NotifyFaviconChanged( |
| 1251 const std::set<GURL>& changed_favicons) { | 1251 const std::set<GURL>& changed_favicons) { |
| 1252 DCHECK(thread_checker_.CalledOnValidThread()); | 1252 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1253 favicon_changed_callback_list_.Notify(changed_favicons); | 1253 favicon_changed_callback_list_.Notify(changed_favicons); |
| 1254 } | 1254 } |
| OLD | NEW |