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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 const QueryURLCallback& callback) { | 579 const QueryURLCallback& callback) { |
580 return Schedule(PRIORITY_UI, &HistoryBackend::QueryURL, consumer, | 580 return Schedule(PRIORITY_UI, &HistoryBackend::QueryURL, consumer, |
581 new history::QueryURLRequest(callback), url, want_visits); | 581 new history::QueryURLRequest(callback), url, want_visits); |
582 } | 582 } |
583 | 583 |
584 // Downloads ------------------------------------------------------------------- | 584 // Downloads ------------------------------------------------------------------- |
585 | 585 |
586 // Handle creation of a download by creating an entry in the history service's | 586 // Handle creation of a download by creating an entry in the history service's |
587 // 'downloads' table. | 587 // 'downloads' table. |
588 HistoryService::Handle HistoryService::CreateDownload( | 588 HistoryService::Handle HistoryService::CreateDownload( |
589 int32 id, | 589 const DownloadPersistentStoreInfo& create_info, |
590 const content::DownloadPersistentStoreInfo& create_info, | |
591 CancelableRequestConsumerBase* consumer, | 590 CancelableRequestConsumerBase* consumer, |
592 const HistoryService::DownloadCreateCallback& callback) { | 591 const HistoryService::DownloadCreateCallback& callback) { |
593 return Schedule(PRIORITY_NORMAL, &HistoryBackend::CreateDownload, consumer, | 592 return Schedule(PRIORITY_NORMAL, &HistoryBackend::CreateDownload, consumer, |
594 new history::DownloadCreateRequest(callback), id, | 593 new history::DownloadCreateRequest(callback), |
595 create_info); | 594 create_info); |
596 } | 595 } |
597 | 596 |
598 HistoryService::Handle HistoryService::GetNextDownloadId( | 597 HistoryService::Handle HistoryService::GetNextDownloadId( |
599 CancelableRequestConsumerBase* consumer, | 598 CancelableRequestConsumerBase* consumer, |
600 const DownloadNextIdCallback& callback) { | 599 const DownloadNextIdCallback& callback) { |
601 return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetNextDownloadId, consumer, | 600 return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetNextDownloadId, consumer, |
602 new history::DownloadNextIdRequest(callback)); | 601 new history::DownloadNextIdRequest(callback)); |
603 } | 602 } |
604 | 603 |
605 // Handle queries for a list of all downloads in the history database's | 604 // Handle queries for a list of all downloads in the history database's |
606 // 'downloads' table. | 605 // 'downloads' table. |
607 HistoryService::Handle HistoryService::QueryDownloads( | 606 HistoryService::Handle HistoryService::QueryDownloads( |
608 CancelableRequestConsumerBase* consumer, | 607 CancelableRequestConsumerBase* consumer, |
609 const DownloadQueryCallback& callback) { | 608 const DownloadQueryCallback& callback) { |
610 return Schedule(PRIORITY_NORMAL, &HistoryBackend::QueryDownloads, consumer, | 609 return Schedule(PRIORITY_NORMAL, &HistoryBackend::QueryDownloads, consumer, |
611 new history::DownloadQueryRequest(callback)); | 610 new history::DownloadQueryRequest(callback)); |
612 } | 611 } |
613 | 612 |
614 // Changes all IN_PROGRESS in the database entries to CANCELED. | 613 // Changes all IN_PROGRESS in the database entries to CANCELED. |
615 // IN_PROGRESS entries are the corrupted entries, not updated by next function | 614 // IN_PROGRESS entries are the corrupted entries, not updated by next function |
616 // because of the crash or some other extremal exit. | 615 // because of the crash or some other extremal exit. |
617 void HistoryService::CleanUpInProgressEntries() { | 616 void HistoryService::CleanUpInProgressEntries() { |
618 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CleanUpInProgressEntries); | 617 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CleanUpInProgressEntries); |
619 } | 618 } |
620 | 619 |
621 // Handle updates for a particular download. This is a 'fire and forget' | 620 // Handle updates for a particular download. This is a 'fire and forget' |
622 // operation, so we don't need to be called back. | 621 // operation, so we don't need to be called back. |
623 void HistoryService::UpdateDownload( | 622 void HistoryService::UpdateDownload(const DownloadPersistentStoreInfo& data) { |
624 const content::DownloadPersistentStoreInfo& data) { | |
625 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data); | 623 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data); |
626 } | 624 } |
627 | 625 |
628 void HistoryService::UpdateDownloadPath(const FilePath& path, | 626 void HistoryService::RemoveDownloads(const std::set<int64>& db_handles) { |
629 int64 db_handle) { | |
630 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownloadPath, | |
631 path, db_handle); | |
632 } | |
633 | |
634 void HistoryService::RemoveDownload(int64 db_handle) { | |
635 ScheduleAndForget(PRIORITY_NORMAL, | 627 ScheduleAndForget(PRIORITY_NORMAL, |
636 &HistoryBackend::RemoveDownload, db_handle); | 628 &HistoryBackend::RemoveDownloads, db_handles); |
637 } | |
638 | |
639 void HistoryService::RemoveDownloadsBetween(Time remove_begin, | |
640 Time remove_end) { | |
641 ScheduleAndForget(PRIORITY_NORMAL, | |
642 &HistoryBackend::RemoveDownloadsBetween, | |
643 remove_begin, | |
644 remove_end); | |
645 } | 629 } |
646 | 630 |
647 HistoryService::Handle HistoryService::QueryHistory( | 631 HistoryService::Handle HistoryService::QueryHistory( |
648 const string16& text_query, | 632 const string16& text_query, |
649 const history::QueryOptions& options, | 633 const history::QueryOptions& options, |
650 CancelableRequestConsumerBase* consumer, | 634 CancelableRequestConsumerBase* consumer, |
651 const QueryHistoryCallback& callback) { | 635 const QueryHistoryCallback& callback) { |
652 return Schedule(PRIORITY_UI, &HistoryBackend::QueryHistory, consumer, | 636 return Schedule(PRIORITY_UI, &HistoryBackend::QueryHistory, consumer, |
653 new history::QueryHistoryRequest(callback), | 637 new history::QueryHistoryRequest(callback), |
654 text_query, options); | 638 text_query, options); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 void HistoryService::RemoveVisitDatabaseObserver( | 934 void HistoryService::RemoveVisitDatabaseObserver( |
951 history::VisitDatabaseObserver* observer) { | 935 history::VisitDatabaseObserver* observer) { |
952 visit_database_observers_->RemoveObserver(observer); | 936 visit_database_observers_->RemoveObserver(observer); |
953 } | 937 } |
954 | 938 |
955 void HistoryService::NotifyVisitDBObserversOnAddVisit( | 939 void HistoryService::NotifyVisitDBObserversOnAddVisit( |
956 const history::BriefVisitInfo& info) { | 940 const history::BriefVisitInfo& info) { |
957 visit_database_observers_->Notify( | 941 visit_database_observers_->Notify( |
958 &history::VisitDatabaseObserver::OnAddVisit, info); | 942 &history::VisitDatabaseObserver::OnAddVisit, info); |
959 } | 943 } |
OLD | NEW |