| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 // the history service (otherwise we would have to manually AddRef and | 100 // the history service (otherwise we would have to manually AddRef and |
| 101 // Release when the Backend has a reference to us). | 101 // Release when the Backend has a reference to us). |
| 102 class HistoryService::BackendDelegate : public HistoryBackend::Delegate { | 102 class HistoryService::BackendDelegate : public HistoryBackend::Delegate { |
| 103 public: | 103 public: |
| 104 BackendDelegate( | 104 BackendDelegate( |
| 105 const base::WeakPtr<HistoryService>& history_service, | 105 const base::WeakPtr<HistoryService>& history_service, |
| 106 const scoped_refptr<base::SequencedTaskRunner>& service_task_runner) | 106 const scoped_refptr<base::SequencedTaskRunner>& service_task_runner) |
| 107 : history_service_(history_service), | 107 : history_service_(history_service), |
| 108 service_task_runner_(service_task_runner) {} | 108 service_task_runner_(service_task_runner) {} |
| 109 | 109 |
| 110 void NotifyProfileError(sql::InitStatus init_status) override { | 110 void NotifyProfileError( |
| 111 sql::InitStatus init_status, |
| 112 const sql::DatabaseDiagnosticMap& diagnostics) override { |
| 111 // Send to the history service on the main thread. | 113 // Send to the history service on the main thread. |
| 112 service_task_runner_->PostTask( | 114 service_task_runner_->PostTask( |
| 113 FROM_HERE, base::Bind(&HistoryService::NotifyProfileError, | 115 FROM_HERE, base::Bind(&HistoryService::NotifyProfileError, |
| 114 history_service_, init_status)); | 116 history_service_, init_status, diagnostics)); |
| 115 } | 117 } |
| 116 | 118 |
| 117 void SetInMemoryBackend( | 119 void SetInMemoryBackend( |
| 118 std::unique_ptr<InMemoryHistoryBackend> backend) override { | 120 std::unique_ptr<InMemoryHistoryBackend> backend) override { |
| 119 // Send the backend to the history service on the main thread. | 121 // Send the backend to the history service on the main thread. |
| 120 service_task_runner_->PostTask( | 122 service_task_runner_->PostTask( |
| 121 FROM_HERE, base::Bind(&HistoryService::SetInMemoryBackend, | 123 FROM_HERE, base::Bind(&HistoryService::SetInMemoryBackend, |
| 122 history_service_, base::Passed(&backend))); | 124 history_service_, base::Passed(&backend))); |
| 123 } | 125 } |
| 124 | 126 |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 void HistoryService::SetInMemoryBackend( | 961 void HistoryService::SetInMemoryBackend( |
| 960 std::unique_ptr<InMemoryHistoryBackend> mem_backend) { | 962 std::unique_ptr<InMemoryHistoryBackend> mem_backend) { |
| 961 DCHECK(thread_checker_.CalledOnValidThread()); | 963 DCHECK(thread_checker_.CalledOnValidThread()); |
| 962 DCHECK(!in_memory_backend_) << "Setting mem DB twice"; | 964 DCHECK(!in_memory_backend_) << "Setting mem DB twice"; |
| 963 in_memory_backend_.reset(mem_backend.release()); | 965 in_memory_backend_.reset(mem_backend.release()); |
| 964 | 966 |
| 965 // The database requires additional initialization once we own it. | 967 // The database requires additional initialization once we own it. |
| 966 in_memory_backend_->AttachToHistoryService(this); | 968 in_memory_backend_->AttachToHistoryService(this); |
| 967 } | 969 } |
| 968 | 970 |
| 969 void HistoryService::NotifyProfileError(sql::InitStatus init_status) { | 971 void HistoryService::NotifyProfileError( |
| 972 sql::InitStatus init_status, |
| 973 const sql::DatabaseDiagnosticMap& diagnostics) { |
| 970 DCHECK(thread_checker_.CalledOnValidThread()); | 974 DCHECK(thread_checker_.CalledOnValidThread()); |
| 971 if (history_client_) | 975 if (history_client_) |
| 972 history_client_->NotifyProfileError(init_status); | 976 history_client_->NotifyProfileError(init_status, diagnostics); |
| 973 } | 977 } |
| 974 | 978 |
| 975 void HistoryService::DeleteURL(const GURL& url) { | 979 void HistoryService::DeleteURL(const GURL& url) { |
| 976 DCHECK(thread_) << "History service being called after cleanup"; | 980 DCHECK(thread_) << "History service being called after cleanup"; |
| 977 DCHECK(thread_checker_.CalledOnValidThread()); | 981 DCHECK(thread_checker_.CalledOnValidThread()); |
| 978 // We will update the visited links when we observe the delete notifications. | 982 // We will update the visited links when we observe the delete notifications. |
| 979 ScheduleTask(PRIORITY_NORMAL, base::Bind(&HistoryBackend::DeleteURL, | 983 ScheduleTask(PRIORITY_NORMAL, base::Bind(&HistoryBackend::DeleteURL, |
| 980 history_backend_.get(), url)); | 984 history_backend_.get(), url)); |
| 981 } | 985 } |
| 982 | 986 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 return favicon_changed_callback_list_.Add(callback); | 1136 return favicon_changed_callback_list_.Add(callback); |
| 1133 } | 1137 } |
| 1134 | 1138 |
| 1135 void HistoryService::NotifyFaviconsChanged(const std::set<GURL>& page_urls, | 1139 void HistoryService::NotifyFaviconsChanged(const std::set<GURL>& page_urls, |
| 1136 const GURL& icon_url) { | 1140 const GURL& icon_url) { |
| 1137 DCHECK(thread_checker_.CalledOnValidThread()); | 1141 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1138 favicon_changed_callback_list_.Notify(page_urls, icon_url); | 1142 favicon_changed_callback_list_.Notify(page_urls, icon_url); |
| 1139 } | 1143 } |
| 1140 | 1144 |
| 1141 } // namespace history | 1145 } // namespace history |
| OLD | NEW |