OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 void HistoryService::SetOnBackendDestroyTask(Task* task) { | 246 void HistoryService::SetOnBackendDestroyTask(Task* task) { |
247 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetOnBackendDestroyTask, | 247 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetOnBackendDestroyTask, |
248 MessageLoop::current(), task); | 248 MessageLoop::current(), task); |
249 } | 249 } |
250 | 250 |
251 void HistoryService::AddPage(const GURL& url, | 251 void HistoryService::AddPage(const GURL& url, |
252 const void* id_scope, | 252 const void* id_scope, |
253 int32 page_id, | 253 int32 page_id, |
254 const GURL& referrer, | 254 const GURL& referrer, |
255 PageTransition::Type transition, | 255 PageTransition::Type transition, |
256 const RedirectList& redirects) { | 256 const RedirectList& redirects, |
257 AddPage(url, Time::Now(), id_scope, page_id, referrer, transition, redirects); | 257 bool did_replace_entry) { |
| 258 AddPage(url, Time::Now(), id_scope, page_id, referrer, transition, redirects, |
| 259 did_replace_entry); |
258 } | 260 } |
259 | 261 |
260 void HistoryService::AddPage(const GURL& url, | 262 void HistoryService::AddPage(const GURL& url, |
261 Time time, | 263 Time time, |
262 const void* id_scope, | 264 const void* id_scope, |
263 int32 page_id, | 265 int32 page_id, |
264 const GURL& referrer, | 266 const GURL& referrer, |
265 PageTransition::Type transition, | 267 PageTransition::Type transition, |
266 const RedirectList& redirects) { | 268 const RedirectList& redirects, |
| 269 bool did_replace_entry) { |
267 DCHECK(history_backend_) << "History service being called after cleanup"; | 270 DCHECK(history_backend_) << "History service being called after cleanup"; |
268 | 271 |
269 // Filter out unwanted URLs. We don't add auto-subframe URLs. They are a | 272 // Filter out unwanted URLs. We don't add auto-subframe URLs. They are a |
270 // large part of history (think iframes for ads) and we never display them in | 273 // large part of history (think iframes for ads) and we never display them in |
271 // history UI. We will still add manual subframes, which are ones the user | 274 // history UI. We will still add manual subframes, which are ones the user |
272 // has clicked on to get. | 275 // has clicked on to get. |
273 if (!CanAddURL(url) || PageTransition::StripQualifier(transition) == | 276 if (!CanAddURL(url) || PageTransition::StripQualifier(transition) == |
274 PageTransition::AUTO_SUBFRAME) | 277 PageTransition::AUTO_SUBFRAME) |
275 return; | 278 return; |
276 | 279 |
277 // Add link & all redirects to visited link list. | 280 // Add link & all redirects to visited link list. |
278 VisitedLinkMaster* visited_links; | 281 VisitedLinkMaster* visited_links; |
279 if (profile_ && (visited_links = profile_->GetVisitedLinkMaster())) { | 282 if (profile_ && (visited_links = profile_->GetVisitedLinkMaster())) { |
280 visited_links->AddURL(url); | 283 visited_links->AddURL(url); |
281 | 284 |
282 if (!redirects.empty()) { | 285 if (!redirects.empty()) { |
283 // We should not be asked to add a page in the middle of a redirect chain. | 286 // We should not be asked to add a page in the middle of a redirect chain. |
284 DCHECK(redirects[redirects.size() - 1] == url); | 287 DCHECK(redirects[redirects.size() - 1] == url); |
285 | 288 |
286 // We need the !redirects.empty() condition above since size_t is unsigned | 289 // We need the !redirects.empty() condition above since size_t is unsigned |
287 // and will wrap around when we subtract one from a 0 size. | 290 // and will wrap around when we subtract one from a 0 size. |
288 for (size_t i = 0; i < redirects.size() - 1; i++) | 291 for (size_t i = 0; i < redirects.size() - 1; i++) |
289 visited_links->AddURL(redirects[i]); | 292 visited_links->AddURL(redirects[i]); |
290 } | 293 } |
291 } | 294 } |
292 | 295 |
293 scoped_refptr<history::HistoryAddPageArgs> request( | 296 scoped_refptr<history::HistoryAddPageArgs> request( |
294 new history::HistoryAddPageArgs(url, time, id_scope, page_id, | 297 new history::HistoryAddPageArgs(url, time, id_scope, page_id, |
295 referrer, redirects, transition)); | 298 referrer, redirects, transition, |
| 299 did_replace_entry)); |
296 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::AddPage, request); | 300 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::AddPage, request); |
297 } | 301 } |
298 | 302 |
299 void HistoryService::SetPageTitle(const GURL& url, | 303 void HistoryService::SetPageTitle(const GURL& url, |
300 const std::wstring& title) { | 304 const std::wstring& title) { |
301 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetPageTitle, url, title); | 305 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetPageTitle, url, title); |
302 } | 306 } |
303 | 307 |
304 void HistoryService::AddPageWithDetails(const GURL& url, | 308 void HistoryService::AddPageWithDetails(const GURL& url, |
305 const std::wstring& title, | 309 const std::wstring& title, |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 NotificationService::current()->Notify(type, source, det); | 668 NotificationService::current()->Notify(type, source, det); |
665 } | 669 } |
666 | 670 |
667 void HistoryService::OnDBLoaded() { | 671 void HistoryService::OnDBLoaded() { |
668 LOG(INFO) << "History backend finished loading"; | 672 LOG(INFO) << "History backend finished loading"; |
669 backend_loaded_ = true; | 673 backend_loaded_ = true; |
670 NotificationService::current()->Notify(NotificationType::HISTORY_LOADED, | 674 NotificationService::current()->Notify(NotificationType::HISTORY_LOADED, |
671 Source<Profile>(profile_), | 675 Source<Profile>(profile_), |
672 Details<HistoryService>(this)); | 676 Details<HistoryService>(this)); |
673 } | 677 } |
OLD | NEW |