Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: chrome/browser/history/history.cc

Issue 10915180: Make DownloadHistory observe manager, items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r165669 Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 "third_party/skia/include/core/SkBitmap.h" 65 #include "third_party/skia/include/core/SkBitmap.h"
66 66
67 using base::Time; 67 using base::Time;
68 using history::HistoryBackend; 68 using history::HistoryBackend;
69 69
70 namespace { 70 namespace {
71 71
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 DCHECK(thread_checker_.CalledOnValidThread()); 652 DCHECK(thread_checker_.CalledOnValidThread());
653 return Schedule(PRIORITY_UI, &HistoryBackend::QueryURL, consumer, 653 return Schedule(PRIORITY_UI, &HistoryBackend::QueryURL, consumer,
654 new history::QueryURLRequest(callback), url, want_visits); 654 new history::QueryURLRequest(callback), url, want_visits);
655 } 655 }
656 656
657 // Downloads ------------------------------------------------------------------- 657 // Downloads -------------------------------------------------------------------
658 658
659 // Handle creation of a download by creating an entry in the history service's 659 // Handle creation of a download by creating an entry in the history service's
660 // 'downloads' table. 660 // 'downloads' table.
661 HistoryService::Handle HistoryService::CreateDownload( 661 HistoryService::Handle HistoryService::CreateDownload(
662 int32 id, 662 const DownloadPersistentStoreInfo& create_info,
663 const content::DownloadPersistentStoreInfo& create_info,
664 CancelableRequestConsumerBase* consumer, 663 CancelableRequestConsumerBase* consumer,
665 const HistoryService::DownloadCreateCallback& callback) { 664 const HistoryService::DownloadCreateCallback& callback) {
666 DCHECK(thread_checker_.CalledOnValidThread()); 665 DCHECK(thread_checker_.CalledOnValidThread());
667 return Schedule(PRIORITY_NORMAL, &HistoryBackend::CreateDownload, consumer, 666 return Schedule(PRIORITY_NORMAL, &HistoryBackend::CreateDownload, consumer,
668 new history::DownloadCreateRequest(callback), id, 667 new history::DownloadCreateRequest(callback),
669 create_info); 668 create_info);
670 } 669 }
671 670
672 HistoryService::Handle HistoryService::GetNextDownloadId( 671 HistoryService::Handle HistoryService::GetNextDownloadId(
673 CancelableRequestConsumerBase* consumer, 672 CancelableRequestConsumerBase* consumer,
674 const DownloadNextIdCallback& callback) { 673 const DownloadNextIdCallback& callback) {
675 DCHECK(thread_checker_.CalledOnValidThread()); 674 DCHECK(thread_checker_.CalledOnValidThread());
676 return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetNextDownloadId, consumer, 675 return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetNextDownloadId, consumer,
677 new history::DownloadNextIdRequest(callback)); 676 new history::DownloadNextIdRequest(callback));
678 } 677 }
(...skipping 11 matching lines...) Expand all
690 // Changes all IN_PROGRESS in the database entries to CANCELED. 689 // Changes all IN_PROGRESS in the database entries to CANCELED.
691 // IN_PROGRESS entries are the corrupted entries, not updated by next function 690 // IN_PROGRESS entries are the corrupted entries, not updated by next function
692 // because of the crash or some other extremal exit. 691 // because of the crash or some other extremal exit.
693 void HistoryService::CleanUpInProgressEntries() { 692 void HistoryService::CleanUpInProgressEntries() {
694 DCHECK(thread_checker_.CalledOnValidThread()); 693 DCHECK(thread_checker_.CalledOnValidThread());
695 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CleanUpInProgressEntries); 694 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CleanUpInProgressEntries);
696 } 695 }
697 696
698 // Handle updates for a particular download. This is a 'fire and forget' 697 // Handle updates for a particular download. This is a 'fire and forget'
699 // operation, so we don't need to be called back. 698 // operation, so we don't need to be called back.
700 void HistoryService::UpdateDownload( 699 void HistoryService::UpdateDownload(const DownloadPersistentStoreInfo& data) {
701 const content::DownloadPersistentStoreInfo& data) {
702 DCHECK(thread_checker_.CalledOnValidThread()); 700 DCHECK(thread_checker_.CalledOnValidThread());
703 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data); 701 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data);
704 } 702 }
705 703
706 void HistoryService::UpdateDownloadPath(const FilePath& path, 704 void HistoryService::RemoveDownloads(const std::set<int64>& db_handles) {
707 int64 db_handle) {
708 DCHECK(thread_checker_.CalledOnValidThread());
709 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownloadPath,
710 path, db_handle);
711 }
712
713 void HistoryService::RemoveDownload(int64 db_handle) {
714 DCHECK(thread_checker_.CalledOnValidThread()); 705 DCHECK(thread_checker_.CalledOnValidThread());
715 ScheduleAndForget(PRIORITY_NORMAL, 706 ScheduleAndForget(PRIORITY_NORMAL,
716 &HistoryBackend::RemoveDownload, db_handle); 707 &HistoryBackend::RemoveDownloads, db_handles);
717 }
718
719 void HistoryService::RemoveDownloadsBetween(Time remove_begin,
720 Time remove_end) {
721 DCHECK(thread_checker_.CalledOnValidThread());
722 ScheduleAndForget(PRIORITY_NORMAL,
723 &HistoryBackend::RemoveDownloadsBetween,
724 remove_begin,
725 remove_end);
726 } 708 }
727 709
728 HistoryService::Handle HistoryService::QueryHistory( 710 HistoryService::Handle HistoryService::QueryHistory(
729 const string16& text_query, 711 const string16& text_query,
730 const history::QueryOptions& options, 712 const history::QueryOptions& options,
731 CancelableRequestConsumerBase* consumer, 713 CancelableRequestConsumerBase* consumer,
732 const QueryHistoryCallback& callback) { 714 const QueryHistoryCallback& callback) {
733 DCHECK(thread_checker_.CalledOnValidThread()); 715 DCHECK(thread_checker_.CalledOnValidThread());
734 return Schedule(PRIORITY_UI, &HistoryBackend::QueryHistory, consumer, 716 return Schedule(PRIORITY_UI, &HistoryBackend::QueryHistory, consumer,
735 new history::QueryHistoryRequest(callback), 717 new history::QueryHistoryRequest(callback),
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 DCHECK(thread_checker_.CalledOnValidThread()); 1053 DCHECK(thread_checker_.CalledOnValidThread());
1072 visit_database_observers_.RemoveObserver(observer); 1054 visit_database_observers_.RemoveObserver(observer);
1073 } 1055 }
1074 1056
1075 void HistoryService::NotifyVisitDBObserversOnAddVisit( 1057 void HistoryService::NotifyVisitDBObserversOnAddVisit(
1076 const history::BriefVisitInfo& info) { 1058 const history::BriefVisitInfo& info) {
1077 DCHECK(thread_checker_.CalledOnValidThread()); 1059 DCHECK(thread_checker_.CalledOnValidThread());
1078 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, 1060 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_,
1079 OnAddVisit(info)); 1061 OnAddVisit(info));
1080 } 1062 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698