| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 } | 272 } |
| 273 | 273 |
| 274 // Delete the thread, which joins with the background thread. We defensively | 274 // Delete the thread, which joins with the background thread. We defensively |
| 275 // NULL the pointer before deleting it in case somebody tries to use it | 275 // NULL the pointer before deleting it in case somebody tries to use it |
| 276 // during shutdown, but this shouldn't happen. | 276 // during shutdown, but this shouldn't happen. |
| 277 base::Thread* thread = thread_; | 277 base::Thread* thread = thread_; |
| 278 thread_ = NULL; | 278 thread_ = NULL; |
| 279 delete thread; | 279 delete thread; |
| 280 } | 280 } |
| 281 | 281 |
| 282 void HistoryService::NotifyRenderProcessHostDestruction(const void* host) { | 282 void HistoryService::ClearCachedDataForContextID( |
| 283 history::ContextID context_id) { |
| 283 DCHECK(thread_checker_.CalledOnValidThread()); | 284 DCHECK(thread_checker_.CalledOnValidThread()); |
| 284 ScheduleAndForget(PRIORITY_NORMAL, | 285 ScheduleAndForget(PRIORITY_NORMAL, |
| 285 &HistoryBackend::NotifyRenderProcessHostDestruction, host); | 286 &HistoryBackend::ClearCachedDataForContextID, context_id); |
| 286 } | 287 } |
| 287 | 288 |
| 288 history::URLDatabase* HistoryService::InMemoryDatabase() { | 289 history::URLDatabase* HistoryService::InMemoryDatabase() { |
| 289 DCHECK(thread_checker_.CalledOnValidThread()); | 290 DCHECK(thread_checker_.CalledOnValidThread()); |
| 290 return in_memory_backend_ ? in_memory_backend_->db() : NULL; | 291 return in_memory_backend_ ? in_memory_backend_->db() : NULL; |
| 291 } | 292 } |
| 292 | 293 |
| 293 bool HistoryService::GetTypedCountForURL(const GURL& url, int* typed_count) { | 294 bool HistoryService::GetTypedCountForURL(const GURL& url, int* typed_count) { |
| 294 DCHECK(thread_checker_.CalledOnValidThread()); | 295 DCHECK(thread_checker_.CalledOnValidThread()); |
| 295 history::URLRow url_row; | 296 history::URLRow url_row; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 } | 404 } |
| 404 | 405 |
| 405 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) { | 406 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) { |
| 406 DCHECK(thread_checker_.CalledOnValidThread()); | 407 DCHECK(thread_checker_.CalledOnValidThread()); |
| 407 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetOnBackendDestroyTask, | 408 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetOnBackendDestroyTask, |
| 408 base::MessageLoop::current(), task); | 409 base::MessageLoop::current(), task); |
| 409 } | 410 } |
| 410 | 411 |
| 411 void HistoryService::AddPage(const GURL& url, | 412 void HistoryService::AddPage(const GURL& url, |
| 412 Time time, | 413 Time time, |
| 413 const void* id_scope, | 414 history::ContextID context_id, |
| 414 int32 page_id, | 415 int32 page_id, |
| 415 const GURL& referrer, | 416 const GURL& referrer, |
| 416 const history::RedirectList& redirects, | 417 const history::RedirectList& redirects, |
| 417 content::PageTransition transition, | 418 content::PageTransition transition, |
| 418 history::VisitSource visit_source, | 419 history::VisitSource visit_source, |
| 419 bool did_replace_entry) { | 420 bool did_replace_entry) { |
| 420 DCHECK(thread_checker_.CalledOnValidThread()); | 421 DCHECK(thread_checker_.CalledOnValidThread()); |
| 421 AddPage( | 422 AddPage( |
| 422 history::HistoryAddPageArgs(url, time, id_scope, page_id, referrer, | 423 history::HistoryAddPageArgs(url, time, context_id, page_id, referrer, |
| 423 redirects, transition, visit_source, | 424 redirects, transition, visit_source, |
| 424 did_replace_entry)); | 425 did_replace_entry)); |
| 425 } | 426 } |
| 426 | 427 |
| 427 void HistoryService::AddPage(const GURL& url, | 428 void HistoryService::AddPage(const GURL& url, |
| 428 base::Time time, | 429 base::Time time, |
| 429 history::VisitSource visit_source) { | 430 history::VisitSource visit_source) { |
| 430 DCHECK(thread_checker_.CalledOnValidThread()); | 431 DCHECK(thread_checker_.CalledOnValidThread()); |
| 431 AddPage( | 432 AddPage( |
| 432 history::HistoryAddPageArgs(url, time, NULL, 0, GURL(), | 433 history::HistoryAddPageArgs(url, time, NULL, 0, GURL(), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 ScheduleAndForget(PRIORITY_NORMAL, | 475 ScheduleAndForget(PRIORITY_NORMAL, |
| 475 &HistoryBackend::AddPageNoVisitForBookmark, url, title); | 476 &HistoryBackend::AddPageNoVisitForBookmark, url, title); |
| 476 } | 477 } |
| 477 | 478 |
| 478 void HistoryService::SetPageTitle(const GURL& url, | 479 void HistoryService::SetPageTitle(const GURL& url, |
| 479 const base::string16& title) { | 480 const base::string16& title) { |
| 480 DCHECK(thread_checker_.CalledOnValidThread()); | 481 DCHECK(thread_checker_.CalledOnValidThread()); |
| 481 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetPageTitle, url, title); | 482 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetPageTitle, url, title); |
| 482 } | 483 } |
| 483 | 484 |
| 484 void HistoryService::UpdateWithPageEndTime(const void* host, | 485 void HistoryService::UpdateWithPageEndTime(history::ContextID context_id, |
| 485 int32 page_id, | 486 int32 page_id, |
| 486 const GURL& url, | 487 const GURL& url, |
| 487 Time end_ts) { | 488 Time end_ts) { |
| 488 DCHECK(thread_checker_.CalledOnValidThread()); | 489 DCHECK(thread_checker_.CalledOnValidThread()); |
| 489 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateWithPageEndTime, | 490 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateWithPageEndTime, |
| 490 host, page_id, url, end_ts); | 491 context_id, page_id, url, end_ts); |
| 491 } | 492 } |
| 492 | 493 |
| 493 void HistoryService::AddPageWithDetails(const GURL& url, | 494 void HistoryService::AddPageWithDetails(const GURL& url, |
| 494 const base::string16& title, | 495 const base::string16& title, |
| 495 int visit_count, | 496 int visit_count, |
| 496 int typed_count, | 497 int typed_count, |
| 497 Time last_visit, | 498 Time last_visit, |
| 498 bool hidden, | 499 bool hidden, |
| 499 history::VisitSource visit_source) { | 500 history::VisitSource visit_source) { |
| 500 DCHECK(thread_checker_.CalledOnValidThread()); | 501 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 DCHECK(thread_checker_.CalledOnValidThread()); | 1168 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1168 visit_database_observers_.RemoveObserver(observer); | 1169 visit_database_observers_.RemoveObserver(observer); |
| 1169 } | 1170 } |
| 1170 | 1171 |
| 1171 void HistoryService::NotifyVisitDBObserversOnAddVisit( | 1172 void HistoryService::NotifyVisitDBObserversOnAddVisit( |
| 1172 const history::BriefVisitInfo& info) { | 1173 const history::BriefVisitInfo& info) { |
| 1173 DCHECK(thread_checker_.CalledOnValidThread()); | 1174 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1174 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, | 1175 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, |
| 1175 OnAddVisit(info)); | 1176 OnAddVisit(info)); |
| 1176 } | 1177 } |
| OLD | NEW |