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

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

Issue 10067018: Add PrerenderLocalPredictor, which will eventually perform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « chrome/browser/history/history.h ('k') | chrome/browser/history/history_backend.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/threading/thread.h" 33 #include "base/threading/thread.h"
34 #include "chrome/browser/autocomplete/history_url_provider.h" 34 #include "chrome/browser/autocomplete/history_url_provider.h"
35 #include "chrome/browser/browser_process.h" 35 #include "chrome/browser/browser_process.h"
36 #include "chrome/browser/history/history_backend.h" 36 #include "chrome/browser/history/history_backend.h"
37 #include "chrome/browser/history/history_notifications.h" 37 #include "chrome/browser/history/history_notifications.h"
38 #include "chrome/browser/history/history_types.h" 38 #include "chrome/browser/history/history_types.h"
39 #include "chrome/browser/history/in_memory_database.h" 39 #include "chrome/browser/history/in_memory_database.h"
40 #include "chrome/browser/history/in_memory_history_backend.h" 40 #include "chrome/browser/history/in_memory_history_backend.h"
41 #include "chrome/browser/history/in_memory_url_index.h" 41 #include "chrome/browser/history/in_memory_url_index.h"
42 #include "chrome/browser/history/top_sites.h" 42 #include "chrome/browser/history/top_sites.h"
43 #include "chrome/browser/history/visit_database.h"
43 #include "chrome/browser/history/visit_filter.h" 44 #include "chrome/browser/history/visit_filter.h"
44 #include "chrome/browser/prefs/pref_service.h" 45 #include "chrome/browser/prefs/pref_service.h"
45 #include "chrome/browser/profiles/profile.h" 46 #include "chrome/browser/profiles/profile.h"
46 #include "chrome/browser/ui/profile_error_dialog.h" 47 #include "chrome/browser/ui/profile_error_dialog.h"
47 #include "chrome/browser/visitedlink/visitedlink_master.h" 48 #include "chrome/browser/visitedlink/visitedlink_master.h"
48 #include "chrome/common/chrome_constants.h" 49 #include "chrome/common/chrome_constants.h"
49 #include "chrome/common/chrome_notification_types.h" 50 #include "chrome/common/chrome_notification_types.h"
50 #include "chrome/common/chrome_switches.h" 51 #include "chrome/common/chrome_switches.h"
51 #include "chrome/common/pref_names.h" 52 #include "chrome/common/pref_names.h"
52 #include "chrome/common/thumbnail_score.h" 53 #include "chrome/common/thumbnail_score.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 backend_id)); 121 backend_id));
121 } 122 }
122 123
123 virtual void StartTopSitesMigration(int backend_id) OVERRIDE { 124 virtual void StartTopSitesMigration(int backend_id) OVERRIDE {
124 message_loop_->PostTask( 125 message_loop_->PostTask(
125 FROM_HERE, 126 FROM_HERE,
126 base::Bind(&HistoryService::StartTopSitesMigration, 127 base::Bind(&HistoryService::StartTopSitesMigration,
127 history_service_.get(), backend_id)); 128 history_service_.get(), backend_id));
128 } 129 }
129 130
131 virtual void NotifyVisitDBObserversOnAddVisit(
132 const history::BriefVisitInfo& info) OVERRIDE {
133 // Since the notification method can be run on any thread, we can
134 // call it right away.
135 history_service_->NotifyVisitDBObserversOnAddVisit(info);
136 }
137
130 private: 138 private:
131 scoped_refptr<HistoryService> history_service_; 139 scoped_refptr<HistoryService> history_service_;
132 MessageLoop* message_loop_; 140 MessageLoop* message_loop_;
133 Profile* profile_; 141 Profile* profile_;
134 }; 142 };
135 143
136 // The history thread is intentionally not a BrowserThread because the 144 // The history thread is intentionally not a BrowserThread because the
137 // sync integration unit tests depend on being able to create more than one 145 // sync integration unit tests depend on being able to create more than one
138 // history thread. 146 // history thread.
139 HistoryService::HistoryService() 147 HistoryService::HistoryService()
140 : thread_(new base::Thread(kHistoryThreadName)), 148 : thread_(new base::Thread(kHistoryThreadName)),
141 profile_(NULL), 149 profile_(NULL),
142 backend_loaded_(false), 150 backend_loaded_(false),
143 current_backend_id_(-1), 151 current_backend_id_(-1),
144 bookmark_service_(NULL), 152 bookmark_service_(NULL),
145 no_db_(false), 153 no_db_(false),
146 needs_top_sites_migration_(false) { 154 needs_top_sites_migration_(false),
155 visit_database_observers_(
156 new ObserverListThreadSafe<history::VisitDatabaseObserver>()) {
147 } 157 }
148 158
149 HistoryService::HistoryService(Profile* profile) 159 HistoryService::HistoryService(Profile* profile)
150 : thread_(new base::Thread(kHistoryThreadName)), 160 : thread_(new base::Thread(kHistoryThreadName)),
151 profile_(profile), 161 profile_(profile),
152 backend_loaded_(false), 162 backend_loaded_(false),
153 current_backend_id_(-1), 163 current_backend_id_(-1),
154 bookmark_service_(NULL), 164 bookmark_service_(NULL),
155 no_db_(false), 165 no_db_(false),
156 needs_top_sites_migration_(false) { 166 needs_top_sites_migration_(false),
167 visit_database_observers_(
168 new ObserverListThreadSafe<history::VisitDatabaseObserver>()) {
157 DCHECK(profile_); 169 DCHECK(profile_);
158 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, 170 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED,
159 content::Source<Profile>(profile_)); 171 content::Source<Profile>(profile_));
160 registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_REMOVED, 172 registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_REMOVED,
161 content::Source<Profile>(profile_)); 173 content::Source<Profile>(profile_));
162 } 174 }
163 175
164 HistoryService::~HistoryService() { 176 HistoryService::~HistoryService() {
165 // Shutdown the backend. This does nothing if Cleanup was already invoked. 177 // Shutdown the backend. This does nothing if Cleanup was already invoked.
166 Cleanup(); 178 Cleanup();
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 history::TopSites* ts = profile_->GetTopSitesWithoutCreating(); 897 history::TopSites* ts = profile_->GetTopSitesWithoutCreating();
886 if (ts) 898 if (ts)
887 ts->MigrateFromHistory(); 899 ts->MigrateFromHistory();
888 } 900 }
889 } 901 }
890 902
891 void HistoryService::OnTopSitesReady() { 903 void HistoryService::OnTopSitesReady() {
892 ScheduleAndForget(PRIORITY_NORMAL, 904 ScheduleAndForget(PRIORITY_NORMAL,
893 &HistoryBackend::MigrateThumbnailsDatabase); 905 &HistoryBackend::MigrateThumbnailsDatabase);
894 } 906 }
907
908 void HistoryService::AddVisitDatabaseObserver(
909 history::VisitDatabaseObserver* observer) {
910 visit_database_observers_->AddObserver(observer);
911 }
912
913 void HistoryService::RemoveVisitDatabaseObserver(
914 history::VisitDatabaseObserver* observer) {
915 visit_database_observers_->RemoveObserver(observer);
916 }
917
918 void HistoryService::NotifyVisitDBObserversOnAddVisit(
919 const history::BriefVisitInfo& info) {
920 visit_database_observers_->Notify(
921 &history::VisitDatabaseObserver::OnAddVisit, info);
922 }
OLDNEW
« no previous file with comments | « chrome/browser/history/history.h ('k') | chrome/browser/history/history_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698