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