Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(551)

Side by Side Diff: chrome/browser/history/history_service.cc

Issue 15275004: bookmarks: Get rid of the dependency on history_notifications.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more android fixes Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 22 matching lines...) Expand all
33 #include "base/message_loop.h" 33 #include "base/message_loop.h"
34 #include "base/path_service.h" 34 #include "base/path_service.h"
35 #include "base/prefs/pref_service.h" 35 #include "base/prefs/pref_service.h"
36 #include "base/thread_task_runner_handle.h" 36 #include "base/thread_task_runner_handle.h"
37 #include "base/threading/thread.h" 37 #include "base/threading/thread.h"
38 #include "base/time.h" 38 #include "base/time.h"
39 #include "chrome/browser/autocomplete/history_url_provider.h" 39 #include "chrome/browser/autocomplete/history_url_provider.h"
40 #include "chrome/browser/bookmarks/bookmark_model.h" 40 #include "chrome/browser/bookmarks/bookmark_model.h"
41 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 41 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
42 #include "chrome/browser/browser_process.h" 42 #include "chrome/browser/browser_process.h"
43 #include "chrome/browser/favicon/favicon_changed_details.h"
43 #include "chrome/browser/favicon/imported_favicon_usage.h" 44 #include "chrome/browser/favicon/imported_favicon_usage.h"
44 #include "chrome/browser/history/download_row.h" 45 #include "chrome/browser/history/download_row.h"
45 #include "chrome/browser/history/history_backend.h" 46 #include "chrome/browser/history/history_backend.h"
46 #include "chrome/browser/history/history_notifications.h" 47 #include "chrome/browser/history/history_notifications.h"
47 #include "chrome/browser/history/history_types.h" 48 #include "chrome/browser/history/history_types.h"
48 #include "chrome/browser/history/in_memory_database.h" 49 #include "chrome/browser/history/in_memory_database.h"
49 #include "chrome/browser/history/in_memory_history_backend.h" 50 #include "chrome/browser/history/in_memory_history_backend.h"
50 #include "chrome/browser/history/in_memory_url_index.h" 51 #include "chrome/browser/history/in_memory_url_index.h"
51 #include "chrome/browser/history/top_sites.h" 52 #include "chrome/browser/history/top_sites.h"
52 #include "chrome/browser/history/visit_database.h" 53 #include "chrome/browser/history/visit_database.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 155
155 virtual void SetInMemoryBackend(int backend_id, 156 virtual void SetInMemoryBackend(int backend_id,
156 history::InMemoryHistoryBackend* backend) OVERRIDE { 157 history::InMemoryHistoryBackend* backend) OVERRIDE {
157 // Send the backend to the history service on the main thread. 158 // Send the backend to the history service on the main thread.
158 service_task_runner_->PostTask( 159 service_task_runner_->PostTask(
159 FROM_HERE, 160 FROM_HERE,
160 base::Bind(&HistoryService::SetInMemoryBackend, history_service_, 161 base::Bind(&HistoryService::SetInMemoryBackend, history_service_,
161 backend_id, backend)); 162 backend_id, backend));
162 } 163 }
163 164
165 virtual void SendFaviconChangedNotification(
166 chrome::FaviconChangedDetails* details) OVERRIDE {
167 // Send the notification on the history thread.
168 if (content::NotificationService::current()) {
169 content::NotificationService::current()->Notify(
170 chrome::NOTIFICATION_FAVICON_CHANGED,
171 content::Source<Profile>(profile_),
172 content::Details<chrome::FaviconChangedDetails>(details));
173 }
174 // Send the notification to the history service on the main thread.
175 service_task_runner_->PostTask(
176 FROM_HERE,
177 base::Bind(&HistoryService::SendFaviconChangedNotificationHelper,
178 history_service_, base::Owned(details)));
179 }
180
164 virtual void BroadcastNotifications( 181 virtual void BroadcastNotifications(
165 int type, 182 int type,
166 history::HistoryDetails* details) OVERRIDE { 183 history::HistoryDetails* details) OVERRIDE {
167 // Send the notification on the history thread. 184 // Send the notification on the history thread.
168 if (content::NotificationService::current()) { 185 if (content::NotificationService::current()) {
169 content::Details<history::HistoryDetails> det(details); 186 content::Details<history::HistoryDetails> det(details);
170 content::NotificationService::current()->Notify( 187 content::NotificationService::current()->Notify(
171 type, content::Source<Profile>(profile_), det); 188 type, content::Source<Profile>(profile_), det);
172 } 189 }
173 // Send the notification to the history service on the main thread. 190 // Send the notification to the history service on the main thread.
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 web_history->ExpireHistoryBetween( 1174 web_history->ExpireHistoryBetween(
1158 restrict_urls, begin_time, end_time, 1175 restrict_urls, begin_time, end_time,
1159 base::Bind(&ExpireWebHistoryComplete)); 1176 base::Bind(&ExpireWebHistoryComplete));
1160 1177
1161 // The request will be freed when the callback is called. 1178 // The request will be freed when the callback is called.
1162 CHECK(request.release()); 1179 CHECK(request.release());
1163 } 1180 }
1164 ExpireHistoryBetween(restrict_urls, begin_time, end_time, callback, tracker); 1181 ExpireHistoryBetween(restrict_urls, begin_time, end_time, callback, tracker);
1165 } 1182 }
1166 1183
1184 void HistoryService::SendFaviconChangedNotificationHelper(
1185 chrome::FaviconChangedDetails* details) {
1186 DCHECK(thread_checker_.CalledOnValidThread());
1187 // TODO(evanm): this is currently necessitated by generate_profile, which
1188 // runs without a browser process. generate_profile should really create
1189 // a browser process, at which point this check can then be nuked.
1190 if (!g_browser_process)
1191 return;
1192
1193 if (!thread_)
1194 return;
1195
1196 // The source of all of our notifications is the profile. Note that this
1197 // pointer is NULL in unit tests.
1198 content::Source<Profile> source(profile_);
1199
1200 // The details object just contains the pointer to the object that the
1201 // backend has allocated for us. The receiver of the notification will cast
1202 // this to the proper type.
1203 content::Details<chrome::FaviconChangedDetails> det(details);
1204
1205 content::NotificationService::current()->Notify(
1206 chrome::NOTIFICATION_FAVICON_CHANGED, source, det);
1207 }
1208
1167 void HistoryService::BroadcastNotificationsHelper( 1209 void HistoryService::BroadcastNotificationsHelper(
1168 int type, 1210 int type,
1169 history::HistoryDetails* details) { 1211 history::HistoryDetails* details) {
1170 DCHECK(thread_checker_.CalledOnValidThread()); 1212 DCHECK(thread_checker_.CalledOnValidThread());
1171 // TODO(evanm): this is currently necessitated by generate_profile, which 1213 // TODO(evanm): this is currently necessitated by generate_profile, which
1172 // runs without a browser process. generate_profile should really create 1214 // runs without a browser process. generate_profile should really create
1173 // a browser process, at which point this check can then be nuked. 1215 // a browser process, at which point this check can then be nuked.
1174 if (!g_browser_process) 1216 if (!g_browser_process)
1175 return; 1217 return;
1176 1218
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 DCHECK(thread_checker_.CalledOnValidThread()); 1313 DCHECK(thread_checker_.CalledOnValidThread());
1272 visit_database_observers_.RemoveObserver(observer); 1314 visit_database_observers_.RemoveObserver(observer);
1273 } 1315 }
1274 1316
1275 void HistoryService::NotifyVisitDBObserversOnAddVisit( 1317 void HistoryService::NotifyVisitDBObserversOnAddVisit(
1276 const history::BriefVisitInfo& info) { 1318 const history::BriefVisitInfo& info) {
1277 DCHECK(thread_checker_.CalledOnValidThread()); 1319 DCHECK(thread_checker_.CalledOnValidThread());
1278 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, 1320 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_,
1279 OnAddVisit(info)); 1321 OnAddVisit(info));
1280 } 1322 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698