| 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 |
| 11 // ----------- -------------- | 11 // ----------- -------------- |
| 12 // HistoryService <----------------> HistoryBackend | 12 // HistoryService <----------------> HistoryBackend |
| 13 // -> HistoryDatabase | 13 // -> HistoryDatabase |
| 14 // -> SQLite connection to History | 14 // -> SQLite connection to History |
| 15 // -> ThumbnailDatabase | 15 // -> ThumbnailDatabase |
| 16 // -> SQLite connection to Thumbnails | 16 // -> SQLite connection to Thumbnails |
| 17 // (and favicons) | 17 // (and favicons) |
| 18 | 18 |
| 19 #include "components/history/core/browser/history_service.h" | 19 #include "components/history/core/browser/history_service.h" |
| 20 | 20 |
| 21 #include "base/bind_helpers.h" | 21 #include "base/bind_helpers.h" |
| 22 #include "base/callback.h" | 22 #include "base/callback.h" |
| 23 #include "base/command_line.h" | 23 #include "base/command_line.h" |
| 24 #include "base/compiler_specific.h" | 24 #include "base/compiler_specific.h" |
| 25 #include "base/location.h" | 25 #include "base/location.h" |
| 26 #include "base/memory/ref_counted.h" | 26 #include "base/memory/ref_counted.h" |
| 27 #include "base/message_loop/message_loop.h" | |
| 28 #include "base/metrics/histogram_macros.h" | 27 #include "base/metrics/histogram_macros.h" |
| 28 #include "base/single_thread_task_runner.h" |
| 29 #include "base/thread_task_runner_handle.h" | 29 #include "base/thread_task_runner_handle.h" |
| 30 #include "base/threading/thread.h" | 30 #include "base/threading/thread.h" |
| 31 #include "base/time/time.h" | 31 #include "base/time/time.h" |
| 32 #include "base/trace_event/trace_event.h" | 32 #include "base/trace_event/trace_event.h" |
| 33 #include "components/history/core/browser/download_row.h" | 33 #include "components/history/core/browser/download_row.h" |
| 34 #include "components/history/core/browser/history_backend.h" | 34 #include "components/history/core/browser/history_backend.h" |
| 35 #include "components/history/core/browser/history_client.h" | 35 #include "components/history/core/browser/history_client.h" |
| 36 #include "components/history/core/browser/history_database_params.h" | 36 #include "components/history/core/browser/history_database_params.h" |
| 37 #include "components/history/core/browser/history_db_task.h" | 37 #include "components/history/core/browser/history_db_task.h" |
| 38 #include "components/history/core/browser/history_service_observer.h" | 38 #include "components/history/core/browser/history_service_observer.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 scoped_ptr<HistoryDBTask> task, | 327 scoped_ptr<HistoryDBTask> task, |
| 328 base::CancelableTaskTracker* tracker) { | 328 base::CancelableTaskTracker* tracker) { |
| 329 DCHECK(thread_) << "History service being called after cleanup"; | 329 DCHECK(thread_) << "History service being called after cleanup"; |
| 330 DCHECK(thread_checker_.CalledOnValidThread()); | 330 DCHECK(thread_checker_.CalledOnValidThread()); |
| 331 base::CancelableTaskTracker::IsCanceledCallback is_canceled; | 331 base::CancelableTaskTracker::IsCanceledCallback is_canceled; |
| 332 base::CancelableTaskTracker::TaskId task_id = | 332 base::CancelableTaskTracker::TaskId task_id = |
| 333 tracker->NewTrackedTaskId(&is_canceled); | 333 tracker->NewTrackedTaskId(&is_canceled); |
| 334 // Use base::ThreadTaskRunnerHandler::Get() to get a message loop proxy to | 334 // Use base::ThreadTaskRunnerHandler::Get() to get a message loop proxy to |
| 335 // the current message loop so that we can forward the call to the method | 335 // the current message loop so that we can forward the call to the method |
| 336 // HistoryDBTask::DoneRunOnMainThread() in the correct thread. | 336 // HistoryDBTask::DoneRunOnMainThread() in the correct thread. |
| 337 thread_->message_loop_proxy()->PostTask( | 337 thread_->task_runner()->PostTask( |
| 338 FROM_HERE, base::Bind(&HistoryBackend::ProcessDBTask, | 338 FROM_HERE, base::Bind(&HistoryBackend::ProcessDBTask, |
| 339 history_backend_.get(), base::Passed(&task), | 339 history_backend_.get(), base::Passed(&task), |
| 340 base::ThreadTaskRunnerHandle::Get(), is_canceled)); | 340 base::ThreadTaskRunnerHandle::Get(), is_canceled)); |
| 341 return task_id; | 341 return task_id; |
| 342 } | 342 } |
| 343 | 343 |
| 344 void HistoryService::FlushForTest(const base::Closure& flushed) { | 344 void HistoryService::FlushForTest(const base::Closure& flushed) { |
| 345 thread_->message_loop_proxy()->PostTaskAndReply( | 345 thread_->task_runner()->PostTaskAndReply( |
| 346 FROM_HERE, base::Bind(&base::DoNothing), flushed); | 346 FROM_HERE, base::Bind(&base::DoNothing), flushed); |
| 347 } | 347 } |
| 348 | 348 |
| 349 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) { | 349 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) { |
| 350 DCHECK(thread_) << "History service being called after cleanup"; | 350 DCHECK(thread_) << "History service being called after cleanup"; |
| 351 DCHECK(thread_checker_.CalledOnValidThread()); | 351 DCHECK(thread_checker_.CalledOnValidThread()); |
| 352 ScheduleTask( | 352 ScheduleTask( |
| 353 PRIORITY_NORMAL, | 353 PRIORITY_NORMAL, |
| 354 base::Bind(&HistoryBackend::SetOnBackendDestroyTask, | 354 base::Bind(&HistoryBackend::SetOnBackendDestroyTask, |
| 355 history_backend_.get(), base::MessageLoop::current(), task)); | 355 history_backend_.get(), base::MessageLoop::current(), task)); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 const std::vector<GURL>& icon_urls, | 495 const std::vector<GURL>& icon_urls, |
| 496 int icon_types, | 496 int icon_types, |
| 497 const std::vector<int>& desired_sizes, | 497 const std::vector<int>& desired_sizes, |
| 498 const favicon_base::FaviconResultsCallback& callback, | 498 const favicon_base::FaviconResultsCallback& callback, |
| 499 base::CancelableTaskTracker* tracker) { | 499 base::CancelableTaskTracker* tracker) { |
| 500 DCHECK(thread_) << "History service being called after cleanup"; | 500 DCHECK(thread_) << "History service being called after cleanup"; |
| 501 DCHECK(thread_checker_.CalledOnValidThread()); | 501 DCHECK(thread_checker_.CalledOnValidThread()); |
| 502 std::vector<favicon_base::FaviconRawBitmapResult>* results = | 502 std::vector<favicon_base::FaviconRawBitmapResult>* results = |
| 503 new std::vector<favicon_base::FaviconRawBitmapResult>(); | 503 new std::vector<favicon_base::FaviconRawBitmapResult>(); |
| 504 return tracker->PostTaskAndReply( | 504 return tracker->PostTaskAndReply( |
| 505 thread_->message_loop_proxy().get(), FROM_HERE, | 505 thread_->task_runner().get(), FROM_HERE, |
| 506 base::Bind(&HistoryBackend::GetFavicons, history_backend_.get(), | 506 base::Bind(&HistoryBackend::GetFavicons, history_backend_.get(), |
| 507 icon_urls, icon_types, desired_sizes, results), | 507 icon_urls, icon_types, desired_sizes, results), |
| 508 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); | 508 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); |
| 509 } | 509 } |
| 510 | 510 |
| 511 base::CancelableTaskTracker::TaskId HistoryService::GetFaviconsForURL( | 511 base::CancelableTaskTracker::TaskId HistoryService::GetFaviconsForURL( |
| 512 const GURL& page_url, | 512 const GURL& page_url, |
| 513 int icon_types, | 513 int icon_types, |
| 514 const std::vector<int>& desired_sizes, | 514 const std::vector<int>& desired_sizes, |
| 515 const favicon_base::FaviconResultsCallback& callback, | 515 const favicon_base::FaviconResultsCallback& callback, |
| 516 base::CancelableTaskTracker* tracker) { | 516 base::CancelableTaskTracker* tracker) { |
| 517 DCHECK(thread_) << "History service being called after cleanup"; | 517 DCHECK(thread_) << "History service being called after cleanup"; |
| 518 DCHECK(thread_checker_.CalledOnValidThread()); | 518 DCHECK(thread_checker_.CalledOnValidThread()); |
| 519 std::vector<favicon_base::FaviconRawBitmapResult>* results = | 519 std::vector<favicon_base::FaviconRawBitmapResult>* results = |
| 520 new std::vector<favicon_base::FaviconRawBitmapResult>(); | 520 new std::vector<favicon_base::FaviconRawBitmapResult>(); |
| 521 return tracker->PostTaskAndReply( | 521 return tracker->PostTaskAndReply( |
| 522 thread_->message_loop_proxy().get(), FROM_HERE, | 522 thread_->task_runner().get(), FROM_HERE, |
| 523 base::Bind(&HistoryBackend::GetFaviconsForURL, history_backend_.get(), | 523 base::Bind(&HistoryBackend::GetFaviconsForURL, history_backend_.get(), |
| 524 page_url, icon_types, desired_sizes, results), | 524 page_url, icon_types, desired_sizes, results), |
| 525 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); | 525 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); |
| 526 } | 526 } |
| 527 | 527 |
| 528 base::CancelableTaskTracker::TaskId HistoryService::GetLargestFaviconForURL( | 528 base::CancelableTaskTracker::TaskId HistoryService::GetLargestFaviconForURL( |
| 529 const GURL& page_url, | 529 const GURL& page_url, |
| 530 const std::vector<int>& icon_types, | 530 const std::vector<int>& icon_types, |
| 531 int minimum_size_in_pixels, | 531 int minimum_size_in_pixels, |
| 532 const favicon_base::FaviconRawBitmapCallback& callback, | 532 const favicon_base::FaviconRawBitmapCallback& callback, |
| 533 base::CancelableTaskTracker* tracker) { | 533 base::CancelableTaskTracker* tracker) { |
| 534 DCHECK(thread_) << "History service being called after cleanup"; | 534 DCHECK(thread_) << "History service being called after cleanup"; |
| 535 DCHECK(thread_checker_.CalledOnValidThread()); | 535 DCHECK(thread_checker_.CalledOnValidThread()); |
| 536 favicon_base::FaviconRawBitmapResult* result = | 536 favicon_base::FaviconRawBitmapResult* result = |
| 537 new favicon_base::FaviconRawBitmapResult(); | 537 new favicon_base::FaviconRawBitmapResult(); |
| 538 return tracker->PostTaskAndReply( | 538 return tracker->PostTaskAndReply( |
| 539 thread_->message_loop_proxy().get(), FROM_HERE, | 539 thread_->task_runner().get(), FROM_HERE, |
| 540 base::Bind(&HistoryBackend::GetLargestFaviconForURL, | 540 base::Bind(&HistoryBackend::GetLargestFaviconForURL, |
| 541 history_backend_.get(), page_url, icon_types, | 541 history_backend_.get(), page_url, icon_types, |
| 542 minimum_size_in_pixels, result), | 542 minimum_size_in_pixels, result), |
| 543 base::Bind(&RunWithFaviconResult, callback, base::Owned(result))); | 543 base::Bind(&RunWithFaviconResult, callback, base::Owned(result))); |
| 544 } | 544 } |
| 545 | 545 |
| 546 base::CancelableTaskTracker::TaskId HistoryService::GetFaviconForID( | 546 base::CancelableTaskTracker::TaskId HistoryService::GetFaviconForID( |
| 547 favicon_base::FaviconID favicon_id, | 547 favicon_base::FaviconID favicon_id, |
| 548 int desired_size, | 548 int desired_size, |
| 549 const favicon_base::FaviconResultsCallback& callback, | 549 const favicon_base::FaviconResultsCallback& callback, |
| 550 base::CancelableTaskTracker* tracker) { | 550 base::CancelableTaskTracker* tracker) { |
| 551 DCHECK(thread_) << "History service being called after cleanup"; | 551 DCHECK(thread_) << "History service being called after cleanup"; |
| 552 DCHECK(thread_checker_.CalledOnValidThread()); | 552 DCHECK(thread_checker_.CalledOnValidThread()); |
| 553 std::vector<favicon_base::FaviconRawBitmapResult>* results = | 553 std::vector<favicon_base::FaviconRawBitmapResult>* results = |
| 554 new std::vector<favicon_base::FaviconRawBitmapResult>(); | 554 new std::vector<favicon_base::FaviconRawBitmapResult>(); |
| 555 return tracker->PostTaskAndReply( | 555 return tracker->PostTaskAndReply( |
| 556 thread_->message_loop_proxy().get(), FROM_HERE, | 556 thread_->task_runner().get(), FROM_HERE, |
| 557 base::Bind(&HistoryBackend::GetFaviconForID, history_backend_.get(), | 557 base::Bind(&HistoryBackend::GetFaviconForID, history_backend_.get(), |
| 558 favicon_id, desired_size, results), | 558 favicon_id, desired_size, results), |
| 559 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); | 559 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); |
| 560 } | 560 } |
| 561 | 561 |
| 562 base::CancelableTaskTracker::TaskId | 562 base::CancelableTaskTracker::TaskId |
| 563 HistoryService::UpdateFaviconMappingsAndFetch( | 563 HistoryService::UpdateFaviconMappingsAndFetch( |
| 564 const GURL& page_url, | 564 const GURL& page_url, |
| 565 const std::vector<GURL>& icon_urls, | 565 const std::vector<GURL>& icon_urls, |
| 566 int icon_types, | 566 int icon_types, |
| 567 const std::vector<int>& desired_sizes, | 567 const std::vector<int>& desired_sizes, |
| 568 const favicon_base::FaviconResultsCallback& callback, | 568 const favicon_base::FaviconResultsCallback& callback, |
| 569 base::CancelableTaskTracker* tracker) { | 569 base::CancelableTaskTracker* tracker) { |
| 570 DCHECK(thread_) << "History service being called after cleanup"; | 570 DCHECK(thread_) << "History service being called after cleanup"; |
| 571 DCHECK(thread_checker_.CalledOnValidThread()); | 571 DCHECK(thread_checker_.CalledOnValidThread()); |
| 572 std::vector<favicon_base::FaviconRawBitmapResult>* results = | 572 std::vector<favicon_base::FaviconRawBitmapResult>* results = |
| 573 new std::vector<favicon_base::FaviconRawBitmapResult>(); | 573 new std::vector<favicon_base::FaviconRawBitmapResult>(); |
| 574 return tracker->PostTaskAndReply( | 574 return tracker->PostTaskAndReply( |
| 575 thread_->message_loop_proxy().get(), FROM_HERE, | 575 thread_->task_runner().get(), FROM_HERE, |
| 576 base::Bind(&HistoryBackend::UpdateFaviconMappingsAndFetch, | 576 base::Bind(&HistoryBackend::UpdateFaviconMappingsAndFetch, |
| 577 history_backend_.get(), page_url, icon_urls, icon_types, | 577 history_backend_.get(), page_url, icon_urls, icon_types, |
| 578 desired_sizes, results), | 578 desired_sizes, results), |
| 579 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); | 579 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); |
| 580 } | 580 } |
| 581 | 581 |
| 582 void HistoryService::MergeFavicon( | 582 void HistoryService::MergeFavicon( |
| 583 const GURL& page_url, | 583 const GURL& page_url, |
| 584 const GURL& icon_url, | 584 const GURL& icon_url, |
| 585 favicon_base::IconType icon_type, | 585 favicon_base::IconType icon_type, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 | 629 |
| 630 base::CancelableTaskTracker::TaskId HistoryService::QueryURL( | 630 base::CancelableTaskTracker::TaskId HistoryService::QueryURL( |
| 631 const GURL& url, | 631 const GURL& url, |
| 632 bool want_visits, | 632 bool want_visits, |
| 633 const QueryURLCallback& callback, | 633 const QueryURLCallback& callback, |
| 634 base::CancelableTaskTracker* tracker) { | 634 base::CancelableTaskTracker* tracker) { |
| 635 DCHECK(thread_) << "History service being called after cleanup"; | 635 DCHECK(thread_) << "History service being called after cleanup"; |
| 636 DCHECK(thread_checker_.CalledOnValidThread()); | 636 DCHECK(thread_checker_.CalledOnValidThread()); |
| 637 QueryURLResult* query_url_result = new QueryURLResult(); | 637 QueryURLResult* query_url_result = new QueryURLResult(); |
| 638 return tracker->PostTaskAndReply( | 638 return tracker->PostTaskAndReply( |
| 639 thread_->message_loop_proxy().get(), FROM_HERE, | 639 thread_->task_runner().get(), FROM_HERE, |
| 640 base::Bind(&HistoryBackend::QueryURL, history_backend_.get(), url, | 640 base::Bind(&HistoryBackend::QueryURL, history_backend_.get(), url, |
| 641 want_visits, base::Unretained(query_url_result)), | 641 want_visits, base::Unretained(query_url_result)), |
| 642 base::Bind(&RunWithQueryURLResult, callback, | 642 base::Bind(&RunWithQueryURLResult, callback, |
| 643 base::Owned(query_url_result))); | 643 base::Owned(query_url_result))); |
| 644 } | 644 } |
| 645 | 645 |
| 646 // Downloads ------------------------------------------------------------------- | 646 // Downloads ------------------------------------------------------------------- |
| 647 | 647 |
| 648 // Handle creation of a download by creating an entry in the history service's | 648 // Handle creation of a download by creating an entry in the history service's |
| 649 // 'downloads' table. | 649 // 'downloads' table. |
| 650 void HistoryService::CreateDownload( | 650 void HistoryService::CreateDownload( |
| 651 const DownloadRow& create_info, | 651 const DownloadRow& create_info, |
| 652 const HistoryService::DownloadCreateCallback& callback) { | 652 const HistoryService::DownloadCreateCallback& callback) { |
| 653 DCHECK(thread_) << "History service being called after cleanup"; | 653 DCHECK(thread_) << "History service being called after cleanup"; |
| 654 DCHECK(thread_checker_.CalledOnValidThread()); | 654 DCHECK(thread_checker_.CalledOnValidThread()); |
| 655 PostTaskAndReplyWithResult(thread_->message_loop_proxy().get(), FROM_HERE, | 655 PostTaskAndReplyWithResult(thread_->task_runner().get(), FROM_HERE, |
| 656 base::Bind(&HistoryBackend::CreateDownload, | 656 base::Bind(&HistoryBackend::CreateDownload, |
| 657 history_backend_.get(), create_info), | 657 history_backend_.get(), create_info), |
| 658 callback); | 658 callback); |
| 659 } | 659 } |
| 660 | 660 |
| 661 void HistoryService::GetNextDownloadId(const DownloadIdCallback& callback) { | 661 void HistoryService::GetNextDownloadId(const DownloadIdCallback& callback) { |
| 662 DCHECK(thread_) << "History service being called after cleanup"; | 662 DCHECK(thread_) << "History service being called after cleanup"; |
| 663 DCHECK(thread_checker_.CalledOnValidThread()); | 663 DCHECK(thread_checker_.CalledOnValidThread()); |
| 664 PostTaskAndReplyWithResult( | 664 PostTaskAndReplyWithResult( |
| 665 thread_->message_loop_proxy().get(), FROM_HERE, | 665 thread_->task_runner().get(), FROM_HERE, |
| 666 base::Bind(&HistoryBackend::GetNextDownloadId, history_backend_.get()), | 666 base::Bind(&HistoryBackend::GetNextDownloadId, history_backend_.get()), |
| 667 callback); | 667 callback); |
| 668 } | 668 } |
| 669 | 669 |
| 670 // Handle queries for a list of all downloads in the history database's | 670 // Handle queries for a list of all downloads in the history database's |
| 671 // 'downloads' table. | 671 // 'downloads' table. |
| 672 void HistoryService::QueryDownloads(const DownloadQueryCallback& callback) { | 672 void HistoryService::QueryDownloads(const DownloadQueryCallback& callback) { |
| 673 DCHECK(thread_) << "History service being called after cleanup"; | 673 DCHECK(thread_) << "History service being called after cleanup"; |
| 674 DCHECK(thread_checker_.CalledOnValidThread()); | 674 DCHECK(thread_checker_.CalledOnValidThread()); |
| 675 std::vector<DownloadRow>* rows = new std::vector<DownloadRow>(); | 675 std::vector<DownloadRow>* rows = new std::vector<DownloadRow>(); |
| 676 scoped_ptr<std::vector<DownloadRow>> scoped_rows(rows); | 676 scoped_ptr<std::vector<DownloadRow>> scoped_rows(rows); |
| 677 // Beware! The first Bind() does not simply |scoped_rows.get()| because | 677 // Beware! The first Bind() does not simply |scoped_rows.get()| because |
| 678 // base::Passed(&scoped_rows) nullifies |scoped_rows|, and compilers do not | 678 // base::Passed(&scoped_rows) nullifies |scoped_rows|, and compilers do not |
| 679 // guarantee that the first Bind's arguments are evaluated before the second | 679 // guarantee that the first Bind's arguments are evaluated before the second |
| 680 // Bind's arguments. | 680 // Bind's arguments. |
| 681 thread_->message_loop_proxy()->PostTaskAndReply( | 681 thread_->task_runner()->PostTaskAndReply( |
| 682 FROM_HERE, | 682 FROM_HERE, |
| 683 base::Bind(&HistoryBackend::QueryDownloads, history_backend_.get(), rows), | 683 base::Bind(&HistoryBackend::QueryDownloads, history_backend_.get(), rows), |
| 684 base::Bind(callback, base::Passed(&scoped_rows))); | 684 base::Bind(callback, base::Passed(&scoped_rows))); |
| 685 } | 685 } |
| 686 | 686 |
| 687 // Handle updates for a particular download. This is a 'fire and forget' | 687 // Handle updates for a particular download. This is a 'fire and forget' |
| 688 // operation, so we don't need to be called back. | 688 // operation, so we don't need to be called back. |
| 689 void HistoryService::UpdateDownload(const DownloadRow& data) { | 689 void HistoryService::UpdateDownload(const DownloadRow& data) { |
| 690 DCHECK(thread_) << "History service being called after cleanup"; | 690 DCHECK(thread_) << "History service being called after cleanup"; |
| 691 DCHECK(thread_checker_.CalledOnValidThread()); | 691 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 702 | 702 |
| 703 base::CancelableTaskTracker::TaskId HistoryService::QueryHistory( | 703 base::CancelableTaskTracker::TaskId HistoryService::QueryHistory( |
| 704 const base::string16& text_query, | 704 const base::string16& text_query, |
| 705 const QueryOptions& options, | 705 const QueryOptions& options, |
| 706 const QueryHistoryCallback& callback, | 706 const QueryHistoryCallback& callback, |
| 707 base::CancelableTaskTracker* tracker) { | 707 base::CancelableTaskTracker* tracker) { |
| 708 DCHECK(thread_) << "History service being called after cleanup"; | 708 DCHECK(thread_) << "History service being called after cleanup"; |
| 709 DCHECK(thread_checker_.CalledOnValidThread()); | 709 DCHECK(thread_checker_.CalledOnValidThread()); |
| 710 QueryResults* query_results = new QueryResults(); | 710 QueryResults* query_results = new QueryResults(); |
| 711 return tracker->PostTaskAndReply( | 711 return tracker->PostTaskAndReply( |
| 712 thread_->message_loop_proxy().get(), FROM_HERE, | 712 thread_->task_runner().get(), FROM_HERE, |
| 713 base::Bind(&HistoryBackend::QueryHistory, history_backend_.get(), | 713 base::Bind(&HistoryBackend::QueryHistory, history_backend_.get(), |
| 714 text_query, options, base::Unretained(query_results)), | 714 text_query, options, base::Unretained(query_results)), |
| 715 base::Bind(callback, base::Owned(query_results))); | 715 base::Bind(callback, base::Owned(query_results))); |
| 716 } | 716 } |
| 717 | 717 |
| 718 base::CancelableTaskTracker::TaskId HistoryService::QueryRedirectsFrom( | 718 base::CancelableTaskTracker::TaskId HistoryService::QueryRedirectsFrom( |
| 719 const GURL& from_url, | 719 const GURL& from_url, |
| 720 const QueryRedirectsCallback& callback, | 720 const QueryRedirectsCallback& callback, |
| 721 base::CancelableTaskTracker* tracker) { | 721 base::CancelableTaskTracker* tracker) { |
| 722 DCHECK(thread_) << "History service being called after cleanup"; | 722 DCHECK(thread_) << "History service being called after cleanup"; |
| 723 DCHECK(thread_checker_.CalledOnValidThread()); | 723 DCHECK(thread_checker_.CalledOnValidThread()); |
| 724 RedirectList* result = new RedirectList(); | 724 RedirectList* result = new RedirectList(); |
| 725 return tracker->PostTaskAndReply( | 725 return tracker->PostTaskAndReply( |
| 726 thread_->message_loop_proxy().get(), FROM_HERE, | 726 thread_->task_runner().get(), FROM_HERE, |
| 727 base::Bind(&HistoryBackend::QueryRedirectsFrom, history_backend_.get(), | 727 base::Bind(&HistoryBackend::QueryRedirectsFrom, history_backend_.get(), |
| 728 from_url, base::Unretained(result)), | 728 from_url, base::Unretained(result)), |
| 729 base::Bind(callback, base::Owned(result))); | 729 base::Bind(callback, base::Owned(result))); |
| 730 } | 730 } |
| 731 | 731 |
| 732 base::CancelableTaskTracker::TaskId HistoryService::QueryRedirectsTo( | 732 base::CancelableTaskTracker::TaskId HistoryService::QueryRedirectsTo( |
| 733 const GURL& to_url, | 733 const GURL& to_url, |
| 734 const QueryRedirectsCallback& callback, | 734 const QueryRedirectsCallback& callback, |
| 735 base::CancelableTaskTracker* tracker) { | 735 base::CancelableTaskTracker* tracker) { |
| 736 DCHECK(thread_) << "History service being called after cleanup"; | 736 DCHECK(thread_) << "History service being called after cleanup"; |
| 737 DCHECK(thread_checker_.CalledOnValidThread()); | 737 DCHECK(thread_checker_.CalledOnValidThread()); |
| 738 RedirectList* result = new RedirectList(); | 738 RedirectList* result = new RedirectList(); |
| 739 return tracker->PostTaskAndReply( | 739 return tracker->PostTaskAndReply( |
| 740 thread_->message_loop_proxy().get(), FROM_HERE, | 740 thread_->task_runner().get(), FROM_HERE, |
| 741 base::Bind(&HistoryBackend::QueryRedirectsTo, history_backend_.get(), | 741 base::Bind(&HistoryBackend::QueryRedirectsTo, history_backend_.get(), |
| 742 to_url, base::Unretained(result)), | 742 to_url, base::Unretained(result)), |
| 743 base::Bind(callback, base::Owned(result))); | 743 base::Bind(callback, base::Owned(result))); |
| 744 } | 744 } |
| 745 | 745 |
| 746 base::CancelableTaskTracker::TaskId HistoryService::GetVisibleVisitCountToHost( | 746 base::CancelableTaskTracker::TaskId HistoryService::GetVisibleVisitCountToHost( |
| 747 const GURL& url, | 747 const GURL& url, |
| 748 const GetVisibleVisitCountToHostCallback& callback, | 748 const GetVisibleVisitCountToHostCallback& callback, |
| 749 base::CancelableTaskTracker* tracker) { | 749 base::CancelableTaskTracker* tracker) { |
| 750 DCHECK(thread_) << "History service being called after cleanup"; | 750 DCHECK(thread_) << "History service being called after cleanup"; |
| 751 DCHECK(thread_checker_.CalledOnValidThread()); | 751 DCHECK(thread_checker_.CalledOnValidThread()); |
| 752 VisibleVisitCountToHostResult* result = new VisibleVisitCountToHostResult(); | 752 VisibleVisitCountToHostResult* result = new VisibleVisitCountToHostResult(); |
| 753 return tracker->PostTaskAndReply( | 753 return tracker->PostTaskAndReply( |
| 754 thread_->message_loop_proxy().get(), FROM_HERE, | 754 thread_->task_runner().get(), FROM_HERE, |
| 755 base::Bind(&HistoryBackend::GetVisibleVisitCountToHost, | 755 base::Bind(&HistoryBackend::GetVisibleVisitCountToHost, |
| 756 history_backend_.get(), url, base::Unretained(result)), | 756 history_backend_.get(), url, base::Unretained(result)), |
| 757 base::Bind(&RunWithVisibleVisitCountToHostResult, callback, | 757 base::Bind(&RunWithVisibleVisitCountToHostResult, callback, |
| 758 base::Owned(result))); | 758 base::Owned(result))); |
| 759 } | 759 } |
| 760 | 760 |
| 761 base::CancelableTaskTracker::TaskId HistoryService::QueryMostVisitedURLs( | 761 base::CancelableTaskTracker::TaskId HistoryService::QueryMostVisitedURLs( |
| 762 int result_count, | 762 int result_count, |
| 763 int days_back, | 763 int days_back, |
| 764 const QueryMostVisitedURLsCallback& callback, | 764 const QueryMostVisitedURLsCallback& callback, |
| 765 base::CancelableTaskTracker* tracker) { | 765 base::CancelableTaskTracker* tracker) { |
| 766 DCHECK(thread_) << "History service being called after cleanup"; | 766 DCHECK(thread_) << "History service being called after cleanup"; |
| 767 DCHECK(thread_checker_.CalledOnValidThread()); | 767 DCHECK(thread_checker_.CalledOnValidThread()); |
| 768 MostVisitedURLList* result = new MostVisitedURLList(); | 768 MostVisitedURLList* result = new MostVisitedURLList(); |
| 769 return tracker->PostTaskAndReply( | 769 return tracker->PostTaskAndReply( |
| 770 thread_->message_loop_proxy().get(), FROM_HERE, | 770 thread_->task_runner().get(), FROM_HERE, |
| 771 base::Bind(&HistoryBackend::QueryMostVisitedURLs, history_backend_.get(), | 771 base::Bind(&HistoryBackend::QueryMostVisitedURLs, history_backend_.get(), |
| 772 result_count, days_back, base::Unretained(result)), | 772 result_count, days_back, base::Unretained(result)), |
| 773 base::Bind(callback, base::Owned(result))); | 773 base::Bind(callback, base::Owned(result))); |
| 774 } | 774 } |
| 775 | 775 |
| 776 base::CancelableTaskTracker::TaskId HistoryService::QueryFilteredURLs( | 776 base::CancelableTaskTracker::TaskId HistoryService::QueryFilteredURLs( |
| 777 int result_count, | 777 int result_count, |
| 778 const VisitFilter& filter, | 778 const VisitFilter& filter, |
| 779 bool extended_info, | 779 bool extended_info, |
| 780 const QueryFilteredURLsCallback& callback, | 780 const QueryFilteredURLsCallback& callback, |
| 781 base::CancelableTaskTracker* tracker) { | 781 base::CancelableTaskTracker* tracker) { |
| 782 DCHECK(thread_) << "History service being called after cleanup"; | 782 DCHECK(thread_) << "History service being called after cleanup"; |
| 783 DCHECK(thread_checker_.CalledOnValidThread()); | 783 DCHECK(thread_checker_.CalledOnValidThread()); |
| 784 FilteredURLList* result = new FilteredURLList(); | 784 FilteredURLList* result = new FilteredURLList(); |
| 785 return tracker->PostTaskAndReply( | 785 return tracker->PostTaskAndReply( |
| 786 thread_->message_loop_proxy().get(), FROM_HERE, | 786 thread_->task_runner().get(), FROM_HERE, |
| 787 base::Bind(&HistoryBackend::QueryFilteredURLs, history_backend_.get(), | 787 base::Bind(&HistoryBackend::QueryFilteredURLs, history_backend_.get(), |
| 788 result_count, filter, extended_info, base::Unretained(result)), | 788 result_count, filter, extended_info, base::Unretained(result)), |
| 789 base::Bind(callback, base::Owned(result))); | 789 base::Bind(callback, base::Owned(result))); |
| 790 } | 790 } |
| 791 | 791 |
| 792 void HistoryService::Cleanup() { | 792 void HistoryService::Cleanup() { |
| 793 DCHECK(thread_checker_.CalledOnValidThread()); | 793 DCHECK(thread_checker_.CalledOnValidThread()); |
| 794 if (!thread_) { | 794 if (!thread_) { |
| 795 // We've already cleaned up. | 795 // We've already cleaned up. |
| 796 return; | 796 return; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 ScheduleTask(PRIORITY_UI, base::Bind(&HistoryBackend::ScheduleAutocomplete, | 883 ScheduleTask(PRIORITY_UI, base::Bind(&HistoryBackend::ScheduleAutocomplete, |
| 884 history_backend_.get(), callback)); | 884 history_backend_.get(), callback)); |
| 885 } | 885 } |
| 886 | 886 |
| 887 void HistoryService::ScheduleTask(SchedulePriority priority, | 887 void HistoryService::ScheduleTask(SchedulePriority priority, |
| 888 const base::Closure& task) { | 888 const base::Closure& task) { |
| 889 DCHECK(thread_checker_.CalledOnValidThread()); | 889 DCHECK(thread_checker_.CalledOnValidThread()); |
| 890 CHECK(thread_); | 890 CHECK(thread_); |
| 891 CHECK(thread_->message_loop()); | 891 CHECK(thread_->message_loop()); |
| 892 // TODO(brettw): Do prioritization. | 892 // TODO(brettw): Do prioritization. |
| 893 thread_->message_loop()->PostTask(FROM_HERE, task); | 893 thread_->task_runner()->PostTask(FROM_HERE, task); |
| 894 } | 894 } |
| 895 | 895 |
| 896 base::WeakPtr<HistoryService> HistoryService::AsWeakPtr() { | 896 base::WeakPtr<HistoryService> HistoryService::AsWeakPtr() { |
| 897 DCHECK(thread_checker_.CalledOnValidThread()); | 897 DCHECK(thread_checker_.CalledOnValidThread()); |
| 898 return weak_ptr_factory_.GetWeakPtr(); | 898 return weak_ptr_factory_.GetWeakPtr(); |
| 899 } | 899 } |
| 900 | 900 |
| 901 syncer::SyncMergeResult HistoryService::MergeDataAndStartSyncing( | 901 syncer::SyncMergeResult HistoryService::MergeDataAndStartSyncing( |
| 902 syncer::ModelType type, | 902 syncer::ModelType type, |
| 903 const syncer::SyncDataList& initial_sync_data, | 903 const syncer::SyncDataList& initial_sync_data, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 | 973 |
| 974 void HistoryService::ExpireHistoryBetween( | 974 void HistoryService::ExpireHistoryBetween( |
| 975 const std::set<GURL>& restrict_urls, | 975 const std::set<GURL>& restrict_urls, |
| 976 Time begin_time, | 976 Time begin_time, |
| 977 Time end_time, | 977 Time end_time, |
| 978 const base::Closure& callback, | 978 const base::Closure& callback, |
| 979 base::CancelableTaskTracker* tracker) { | 979 base::CancelableTaskTracker* tracker) { |
| 980 DCHECK(thread_) << "History service being called after cleanup"; | 980 DCHECK(thread_) << "History service being called after cleanup"; |
| 981 DCHECK(thread_checker_.CalledOnValidThread()); | 981 DCHECK(thread_checker_.CalledOnValidThread()); |
| 982 tracker->PostTaskAndReply( | 982 tracker->PostTaskAndReply( |
| 983 thread_->message_loop_proxy().get(), FROM_HERE, | 983 thread_->task_runner().get(), FROM_HERE, |
| 984 base::Bind(&HistoryBackend::ExpireHistoryBetween, history_backend_, | 984 base::Bind(&HistoryBackend::ExpireHistoryBetween, history_backend_, |
| 985 restrict_urls, begin_time, end_time), | 985 restrict_urls, begin_time, end_time), |
| 986 callback); | 986 callback); |
| 987 } | 987 } |
| 988 | 988 |
| 989 void HistoryService::ExpireHistory( | 989 void HistoryService::ExpireHistory( |
| 990 const std::vector<ExpireHistoryArgs>& expire_list, | 990 const std::vector<ExpireHistoryArgs>& expire_list, |
| 991 const base::Closure& callback, | 991 const base::Closure& callback, |
| 992 base::CancelableTaskTracker* tracker) { | 992 base::CancelableTaskTracker* tracker) { |
| 993 DCHECK(thread_) << "History service being called after cleanup"; | 993 DCHECK(thread_) << "History service being called after cleanup"; |
| 994 DCHECK(thread_checker_.CalledOnValidThread()); | 994 DCHECK(thread_checker_.CalledOnValidThread()); |
| 995 tracker->PostTaskAndReply( | 995 tracker->PostTaskAndReply( |
| 996 thread_->message_loop_proxy().get(), FROM_HERE, | 996 thread_->task_runner().get(), FROM_HERE, |
| 997 base::Bind(&HistoryBackend::ExpireHistory, history_backend_, expire_list), | 997 base::Bind(&HistoryBackend::ExpireHistory, history_backend_, expire_list), |
| 998 callback); | 998 callback); |
| 999 } | 999 } |
| 1000 | 1000 |
| 1001 void HistoryService::ExpireLocalAndRemoteHistoryBetween( | 1001 void HistoryService::ExpireLocalAndRemoteHistoryBetween( |
| 1002 WebHistoryService* web_history, | 1002 WebHistoryService* web_history, |
| 1003 const std::set<GURL>& restrict_urls, | 1003 const std::set<GURL>& restrict_urls, |
| 1004 Time begin_time, | 1004 Time begin_time, |
| 1005 Time end_time, | 1005 Time end_time, |
| 1006 const base::Closure& callback, | 1006 const base::Closure& callback, |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 return favicon_changed_callback_list_.Add(callback); | 1119 return favicon_changed_callback_list_.Add(callback); |
| 1120 } | 1120 } |
| 1121 | 1121 |
| 1122 void HistoryService::NotifyFaviconChanged( | 1122 void HistoryService::NotifyFaviconChanged( |
| 1123 const std::set<GURL>& changed_favicons) { | 1123 const std::set<GURL>& changed_favicons) { |
| 1124 DCHECK(thread_checker_.CalledOnValidThread()); | 1124 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1125 favicon_changed_callback_list_.Notify(changed_favicons); | 1125 favicon_changed_callback_list_.Notify(changed_favicons); |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 } // namespace history | 1128 } // namespace history |
| OLD | NEW |