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 17 matching lines...) Expand all Loading... |
28 #include "base/command_line.h" | 28 #include "base/command_line.h" |
29 #include "base/memory/ref_counted.h" | 29 #include "base/memory/ref_counted.h" |
30 #include "base/message_loop.h" | 30 #include "base/message_loop.h" |
31 #include "base/path_service.h" | 31 #include "base/path_service.h" |
32 #include "base/string_util.h" | 32 #include "base/string_util.h" |
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/bookmarks/bookmark_model.h" | 35 #include "chrome/browser/bookmarks/bookmark_model.h" |
36 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 36 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
37 #include "chrome/browser/browser_process.h" | 37 #include "chrome/browser/browser_process.h" |
| 38 #include "chrome/browser/history/download_persistent_store_info.h" |
38 #include "chrome/browser/history/history_backend.h" | 39 #include "chrome/browser/history/history_backend.h" |
39 #include "chrome/browser/history/history_notifications.h" | 40 #include "chrome/browser/history/history_notifications.h" |
40 #include "chrome/browser/history/history_types.h" | 41 #include "chrome/browser/history/history_types.h" |
41 #include "chrome/browser/history/in_memory_database.h" | 42 #include "chrome/browser/history/in_memory_database.h" |
42 #include "chrome/browser/history/in_memory_history_backend.h" | 43 #include "chrome/browser/history/in_memory_history_backend.h" |
43 #include "chrome/browser/history/in_memory_url_index.h" | 44 #include "chrome/browser/history/in_memory_url_index.h" |
44 #include "chrome/browser/history/top_sites.h" | 45 #include "chrome/browser/history/top_sites.h" |
45 #include "chrome/browser/history/visit_database.h" | 46 #include "chrome/browser/history/visit_database.h" |
46 #include "chrome/browser/history/visit_filter.h" | 47 #include "chrome/browser/history/visit_filter.h" |
47 #include "chrome/browser/prefs/pref_service.h" | 48 #include "chrome/browser/prefs/pref_service.h" |
48 #include "chrome/browser/profiles/profile.h" | 49 #include "chrome/browser/profiles/profile.h" |
49 #include "chrome/browser/ui/profile_error_dialog.h" | 50 #include "chrome/browser/ui/profile_error_dialog.h" |
50 #include "chrome/browser/visitedlink/visitedlink_master.h" | 51 #include "chrome/browser/visitedlink/visitedlink_master.h" |
51 #include "chrome/common/chrome_constants.h" | 52 #include "chrome/common/chrome_constants.h" |
52 #include "chrome/common/chrome_notification_types.h" | 53 #include "chrome/common/chrome_notification_types.h" |
53 #include "chrome/common/chrome_switches.h" | 54 #include "chrome/common/chrome_switches.h" |
54 #include "chrome/common/pref_names.h" | 55 #include "chrome/common/pref_names.h" |
55 #include "chrome/common/thumbnail_score.h" | 56 #include "chrome/common/thumbnail_score.h" |
56 #include "chrome/common/url_constants.h" | 57 #include "chrome/common/url_constants.h" |
57 #include "content/public/browser/browser_thread.h" | 58 #include "content/public/browser/browser_thread.h" |
58 #include "content/public/browser/download_persistent_store_info.h" | |
59 #include "content/public/browser/notification_service.h" | 59 #include "content/public/browser/notification_service.h" |
60 #include "grit/chromium_strings.h" | 60 #include "grit/chromium_strings.h" |
61 #include "grit/generated_resources.h" | 61 #include "grit/generated_resources.h" |
62 #include "third_party/skia/include/core/SkBitmap.h" | 62 #include "third_party/skia/include/core/SkBitmap.h" |
63 | 63 |
64 using base::Time; | 64 using base::Time; |
65 using history::HistoryBackend; | 65 using history::HistoryBackend; |
66 | 66 |
67 namespace { | 67 namespace { |
68 | 68 |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 const QueryURLCallback& callback) { | 604 const QueryURLCallback& callback) { |
605 return Schedule(PRIORITY_UI, &HistoryBackend::QueryURL, consumer, | 605 return Schedule(PRIORITY_UI, &HistoryBackend::QueryURL, consumer, |
606 new history::QueryURLRequest(callback), url, want_visits); | 606 new history::QueryURLRequest(callback), url, want_visits); |
607 } | 607 } |
608 | 608 |
609 // Downloads ------------------------------------------------------------------- | 609 // Downloads ------------------------------------------------------------------- |
610 | 610 |
611 // Handle creation of a download by creating an entry in the history service's | 611 // Handle creation of a download by creating an entry in the history service's |
612 // 'downloads' table. | 612 // 'downloads' table. |
613 HistoryService::Handle HistoryService::CreateDownload( | 613 HistoryService::Handle HistoryService::CreateDownload( |
614 int32 id, | 614 const DownloadPersistentStoreInfo& create_info, |
615 const content::DownloadPersistentStoreInfo& create_info, | |
616 CancelableRequestConsumerBase* consumer, | 615 CancelableRequestConsumerBase* consumer, |
617 const HistoryService::DownloadCreateCallback& callback) { | 616 const HistoryService::DownloadCreateCallback& callback) { |
618 return Schedule(PRIORITY_NORMAL, &HistoryBackend::CreateDownload, consumer, | 617 return Schedule(PRIORITY_NORMAL, &HistoryBackend::CreateDownload, consumer, |
619 new history::DownloadCreateRequest(callback), id, | 618 new history::DownloadCreateRequest(callback), |
620 create_info); | 619 create_info); |
621 } | 620 } |
622 | 621 |
623 HistoryService::Handle HistoryService::GetNextDownloadId( | 622 HistoryService::Handle HistoryService::GetNextDownloadId( |
624 CancelableRequestConsumerBase* consumer, | 623 CancelableRequestConsumerBase* consumer, |
625 const DownloadNextIdCallback& callback) { | 624 const DownloadNextIdCallback& callback) { |
626 return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetNextDownloadId, consumer, | 625 return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetNextDownloadId, consumer, |
627 new history::DownloadNextIdRequest(callback)); | 626 new history::DownloadNextIdRequest(callback)); |
628 } | 627 } |
629 | 628 |
630 // Handle queries for a list of all downloads in the history database's | 629 // Handle queries for a list of all downloads in the history database's |
631 // 'downloads' table. | 630 // 'downloads' table. |
632 HistoryService::Handle HistoryService::QueryDownloads( | 631 HistoryService::Handle HistoryService::QueryDownloads( |
633 CancelableRequestConsumerBase* consumer, | 632 CancelableRequestConsumerBase* consumer, |
634 const DownloadQueryCallback& callback) { | 633 const DownloadQueryCallback& callback) { |
635 return Schedule(PRIORITY_NORMAL, &HistoryBackend::QueryDownloads, consumer, | 634 return Schedule(PRIORITY_NORMAL, &HistoryBackend::QueryDownloads, consumer, |
636 new history::DownloadQueryRequest(callback)); | 635 new history::DownloadQueryRequest(callback)); |
637 } | 636 } |
638 | 637 |
639 // Changes all IN_PROGRESS in the database entries to CANCELED. | 638 // Changes all IN_PROGRESS in the database entries to CANCELED. |
640 // IN_PROGRESS entries are the corrupted entries, not updated by next function | 639 // IN_PROGRESS entries are the corrupted entries, not updated by next function |
641 // because of the crash or some other extremal exit. | 640 // because of the crash or some other extremal exit. |
642 void HistoryService::CleanUpInProgressEntries() { | 641 void HistoryService::CleanUpInProgressEntries() { |
643 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CleanUpInProgressEntries); | 642 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CleanUpInProgressEntries); |
644 } | 643 } |
645 | 644 |
646 // Handle updates for a particular download. This is a 'fire and forget' | 645 // Handle updates for a particular download. This is a 'fire and forget' |
647 // operation, so we don't need to be called back. | 646 // operation, so we don't need to be called back. |
648 void HistoryService::UpdateDownload( | 647 void HistoryService::UpdateDownload(const DownloadPersistentStoreInfo& data) { |
649 const content::DownloadPersistentStoreInfo& data) { | |
650 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data); | 648 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data); |
651 } | 649 } |
652 | 650 |
653 void HistoryService::UpdateDownloadPath(const FilePath& path, | 651 void HistoryService::RemoveDownloads(const std::set<int64>& db_handles) { |
654 int64 db_handle) { | |
655 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownloadPath, | |
656 path, db_handle); | |
657 } | |
658 | |
659 void HistoryService::RemoveDownload(int64 db_handle) { | |
660 ScheduleAndForget(PRIORITY_NORMAL, | 652 ScheduleAndForget(PRIORITY_NORMAL, |
661 &HistoryBackend::RemoveDownload, db_handle); | 653 &HistoryBackend::RemoveDownloads, db_handles); |
662 } | |
663 | |
664 void HistoryService::RemoveDownloadsBetween(Time remove_begin, | |
665 Time remove_end) { | |
666 ScheduleAndForget(PRIORITY_NORMAL, | |
667 &HistoryBackend::RemoveDownloadsBetween, | |
668 remove_begin, | |
669 remove_end); | |
670 } | 654 } |
671 | 655 |
672 HistoryService::Handle HistoryService::QueryHistory( | 656 HistoryService::Handle HistoryService::QueryHistory( |
673 const string16& text_query, | 657 const string16& text_query, |
674 const history::QueryOptions& options, | 658 const history::QueryOptions& options, |
675 CancelableRequestConsumerBase* consumer, | 659 CancelableRequestConsumerBase* consumer, |
676 const QueryHistoryCallback& callback) { | 660 const QueryHistoryCallback& callback) { |
677 return Schedule(PRIORITY_UI, &HistoryBackend::QueryHistory, consumer, | 661 return Schedule(PRIORITY_UI, &HistoryBackend::QueryHistory, consumer, |
678 new history::QueryHistoryRequest(callback), | 662 new history::QueryHistoryRequest(callback), |
679 text_query, options); | 663 text_query, options); |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 void HistoryService::RemoveVisitDatabaseObserver( | 964 void HistoryService::RemoveVisitDatabaseObserver( |
981 history::VisitDatabaseObserver* observer) { | 965 history::VisitDatabaseObserver* observer) { |
982 visit_database_observers_->RemoveObserver(observer); | 966 visit_database_observers_->RemoveObserver(observer); |
983 } | 967 } |
984 | 968 |
985 void HistoryService::NotifyVisitDBObserversOnAddVisit( | 969 void HistoryService::NotifyVisitDBObserversOnAddVisit( |
986 const history::BriefVisitInfo& info) { | 970 const history::BriefVisitInfo& info) { |
987 visit_database_observers_->Notify( | 971 visit_database_observers_->Notify( |
988 &history::VisitDatabaseObserver::OnAddVisit, info); | 972 &history::VisitDatabaseObserver::OnAddVisit, info); |
989 } | 973 } |
OLD | NEW |