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 20 matching lines...) Expand all Loading... |
31 #include "base/message_loop.h" | 31 #include "base/message_loop.h" |
32 #include "base/path_service.h" | 32 #include "base/path_service.h" |
33 #include "base/sequenced_task_runner.h" | 33 #include "base/sequenced_task_runner.h" |
34 #include "base/string_util.h" | 34 #include "base/string_util.h" |
35 #include "base/thread_task_runner_handle.h" | 35 #include "base/thread_task_runner_handle.h" |
36 #include "base/threading/thread.h" | 36 #include "base/threading/thread.h" |
37 #include "chrome/browser/autocomplete/history_url_provider.h" | 37 #include "chrome/browser/autocomplete/history_url_provider.h" |
38 #include "chrome/browser/bookmarks/bookmark_model.h" | 38 #include "chrome/browser/bookmarks/bookmark_model.h" |
39 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 39 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
40 #include "chrome/browser/browser_process.h" | 40 #include "chrome/browser/browser_process.h" |
| 41 #include "chrome/browser/history/download_persistent_store_info.h" |
41 #include "chrome/browser/history/history_backend.h" | 42 #include "chrome/browser/history/history_backend.h" |
42 #include "chrome/browser/history/history_notifications.h" | 43 #include "chrome/browser/history/history_notifications.h" |
43 #include "chrome/browser/history/history_types.h" | 44 #include "chrome/browser/history/history_types.h" |
44 #include "chrome/browser/history/in_memory_database.h" | 45 #include "chrome/browser/history/in_memory_database.h" |
45 #include "chrome/browser/history/in_memory_history_backend.h" | 46 #include "chrome/browser/history/in_memory_history_backend.h" |
46 #include "chrome/browser/history/in_memory_url_index.h" | 47 #include "chrome/browser/history/in_memory_url_index.h" |
47 #include "chrome/browser/history/top_sites.h" | 48 #include "chrome/browser/history/top_sites.h" |
48 #include "chrome/browser/history/visit_database.h" | 49 #include "chrome/browser/history/visit_database.h" |
49 #include "chrome/browser/history/visit_filter.h" | 50 #include "chrome/browser/history/visit_filter.h" |
50 #include "chrome/browser/prefs/pref_service.h" | 51 #include "chrome/browser/prefs/pref_service.h" |
51 #include "chrome/browser/profiles/profile.h" | 52 #include "chrome/browser/profiles/profile.h" |
52 #include "chrome/browser/ui/profile_error_dialog.h" | 53 #include "chrome/browser/ui/profile_error_dialog.h" |
53 #include "chrome/browser/visitedlink/visitedlink_master.h" | 54 #include "chrome/browser/visitedlink/visitedlink_master.h" |
54 #include "chrome/common/chrome_constants.h" | 55 #include "chrome/common/chrome_constants.h" |
55 #include "chrome/common/chrome_notification_types.h" | 56 #include "chrome/common/chrome_notification_types.h" |
56 #include "chrome/common/chrome_switches.h" | 57 #include "chrome/common/chrome_switches.h" |
57 #include "chrome/common/pref_names.h" | 58 #include "chrome/common/pref_names.h" |
58 #include "chrome/common/thumbnail_score.h" | 59 #include "chrome/common/thumbnail_score.h" |
59 #include "chrome/common/url_constants.h" | 60 #include "chrome/common/url_constants.h" |
60 #include "content/public/browser/browser_thread.h" | 61 #include "content/public/browser/browser_thread.h" |
61 #include "content/public/browser/download_persistent_store_info.h" | |
62 #include "content/public/browser/notification_service.h" | 62 #include "content/public/browser/notification_service.h" |
63 #include "grit/chromium_strings.h" | 63 #include "grit/chromium_strings.h" |
64 #include "grit/generated_resources.h" | 64 #include "grit/generated_resources.h" |
65 #include "sync/api/sync_change.h" | 65 #include "sync/api/sync_change.h" |
66 #include "sync/api/sync_data.h" | 66 #include "sync/api/sync_data.h" |
67 #include "sync/api/sync_error_factory.h" | 67 #include "sync/api/sync_error_factory.h" |
68 #include "sync/protocol/sync.pb.h" | 68 #include "sync/protocol/sync.pb.h" |
69 #include "third_party/skia/include/core/SkBitmap.h" | 69 #include "third_party/skia/include/core/SkBitmap.h" |
70 | 70 |
71 using base::Time; | 71 using base::Time; |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 DCHECK(thread_checker_.CalledOnValidThread()); | 656 DCHECK(thread_checker_.CalledOnValidThread()); |
657 return Schedule(PRIORITY_UI, &HistoryBackend::QueryURL, consumer, | 657 return Schedule(PRIORITY_UI, &HistoryBackend::QueryURL, consumer, |
658 new history::QueryURLRequest(callback), url, want_visits); | 658 new history::QueryURLRequest(callback), url, want_visits); |
659 } | 659 } |
660 | 660 |
661 // Downloads ------------------------------------------------------------------- | 661 // Downloads ------------------------------------------------------------------- |
662 | 662 |
663 // Handle creation of a download by creating an entry in the history service's | 663 // Handle creation of a download by creating an entry in the history service's |
664 // 'downloads' table. | 664 // 'downloads' table. |
665 HistoryService::Handle HistoryService::CreateDownload( | 665 HistoryService::Handle HistoryService::CreateDownload( |
666 int32 id, | 666 const DownloadPersistentStoreInfo& create_info, |
667 const content::DownloadPersistentStoreInfo& create_info, | |
668 CancelableRequestConsumerBase* consumer, | 667 CancelableRequestConsumerBase* consumer, |
669 const HistoryService::DownloadCreateCallback& callback) { | 668 const HistoryService::DownloadCreateCallback& callback) { |
670 DCHECK(thread_checker_.CalledOnValidThread()); | 669 DCHECK(thread_checker_.CalledOnValidThread()); |
671 return Schedule(PRIORITY_NORMAL, &HistoryBackend::CreateDownload, consumer, | 670 return Schedule(PRIORITY_NORMAL, &HistoryBackend::CreateDownload, consumer, |
672 new history::DownloadCreateRequest(callback), id, | 671 new history::DownloadCreateRequest(callback), |
673 create_info); | 672 create_info); |
674 } | 673 } |
675 | 674 |
676 HistoryService::Handle HistoryService::GetNextDownloadId( | 675 HistoryService::Handle HistoryService::GetNextDownloadId( |
677 CancelableRequestConsumerBase* consumer, | 676 CancelableRequestConsumerBase* consumer, |
678 const DownloadNextIdCallback& callback) { | 677 const DownloadNextIdCallback& callback) { |
679 DCHECK(thread_checker_.CalledOnValidThread()); | 678 DCHECK(thread_checker_.CalledOnValidThread()); |
680 return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetNextDownloadId, consumer, | 679 return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetNextDownloadId, consumer, |
681 new history::DownloadNextIdRequest(callback)); | 680 new history::DownloadNextIdRequest(callback)); |
682 } | 681 } |
(...skipping 11 matching lines...) Expand all Loading... |
694 // Changes all IN_PROGRESS in the database entries to CANCELED. | 693 // Changes all IN_PROGRESS in the database entries to CANCELED. |
695 // IN_PROGRESS entries are the corrupted entries, not updated by next function | 694 // IN_PROGRESS entries are the corrupted entries, not updated by next function |
696 // because of the crash or some other extremal exit. | 695 // because of the crash or some other extremal exit. |
697 void HistoryService::CleanUpInProgressEntries() { | 696 void HistoryService::CleanUpInProgressEntries() { |
698 DCHECK(thread_checker_.CalledOnValidThread()); | 697 DCHECK(thread_checker_.CalledOnValidThread()); |
699 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CleanUpInProgressEntries); | 698 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CleanUpInProgressEntries); |
700 } | 699 } |
701 | 700 |
702 // Handle updates for a particular download. This is a 'fire and forget' | 701 // Handle updates for a particular download. This is a 'fire and forget' |
703 // operation, so we don't need to be called back. | 702 // operation, so we don't need to be called back. |
704 void HistoryService::UpdateDownload( | 703 void HistoryService::UpdateDownload(const DownloadPersistentStoreInfo& data) { |
705 const content::DownloadPersistentStoreInfo& data) { | |
706 DCHECK(thread_checker_.CalledOnValidThread()); | 704 DCHECK(thread_checker_.CalledOnValidThread()); |
707 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data); | 705 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data); |
708 } | 706 } |
709 | 707 |
710 void HistoryService::UpdateDownloadPath(const FilePath& path, | 708 void HistoryService::RemoveDownloads(const std::set<int64>& db_handles) { |
711 int64 db_handle) { | |
712 DCHECK(thread_checker_.CalledOnValidThread()); | |
713 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownloadPath, | |
714 path, db_handle); | |
715 } | |
716 | |
717 void HistoryService::RemoveDownload(int64 db_handle) { | |
718 DCHECK(thread_checker_.CalledOnValidThread()); | 709 DCHECK(thread_checker_.CalledOnValidThread()); |
719 ScheduleAndForget(PRIORITY_NORMAL, | 710 ScheduleAndForget(PRIORITY_NORMAL, |
720 &HistoryBackend::RemoveDownload, db_handle); | 711 &HistoryBackend::RemoveDownloads, db_handles); |
721 } | |
722 | |
723 void HistoryService::RemoveDownloadsBetween(Time remove_begin, | |
724 Time remove_end) { | |
725 DCHECK(thread_checker_.CalledOnValidThread()); | |
726 ScheduleAndForget(PRIORITY_NORMAL, | |
727 &HistoryBackend::RemoveDownloadsBetween, | |
728 remove_begin, | |
729 remove_end); | |
730 } | 712 } |
731 | 713 |
732 HistoryService::Handle HistoryService::QueryHistory( | 714 HistoryService::Handle HistoryService::QueryHistory( |
733 const string16& text_query, | 715 const string16& text_query, |
734 const history::QueryOptions& options, | 716 const history::QueryOptions& options, |
735 CancelableRequestConsumerBase* consumer, | 717 CancelableRequestConsumerBase* consumer, |
736 const QueryHistoryCallback& callback) { | 718 const QueryHistoryCallback& callback) { |
737 DCHECK(thread_checker_.CalledOnValidThread()); | 719 DCHECK(thread_checker_.CalledOnValidThread()); |
738 return Schedule(PRIORITY_UI, &HistoryBackend::QueryHistory, consumer, | 720 return Schedule(PRIORITY_UI, &HistoryBackend::QueryHistory, consumer, |
739 new history::QueryHistoryRequest(callback), | 721 new history::QueryHistoryRequest(callback), |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 } | 1116 } |
1135 | 1117 |
1136 void HistoryService::ProcessDeleteDirective( | 1118 void HistoryService::ProcessDeleteDirective( |
1137 const sync_pb::HistoryDeleteDirectiveSpecifics& delete_directive) { | 1119 const sync_pb::HistoryDeleteDirectiveSpecifics& delete_directive) { |
1138 DCHECK(thread_checker_.CalledOnValidThread()); | 1120 DCHECK(thread_checker_.CalledOnValidThread()); |
1139 // TODO(akalin): Actually process the delete directive. | 1121 // TODO(akalin): Actually process the delete directive. |
1140 // TODO(akalin): Keep track of which delete directives we've already | 1122 // TODO(akalin): Keep track of which delete directives we've already |
1141 // processed. | 1123 // processed. |
1142 NOTREACHED(); | 1124 NOTREACHED(); |
1143 } | 1125 } |
OLD | NEW |