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/download/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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 return Schedule(PRIORITY_UI, &HistoryBackend::QueryURL, consumer, | 564 return Schedule(PRIORITY_UI, &HistoryBackend::QueryURL, consumer, |
565 new history::QueryURLRequest(callback), url, want_visits); | 565 new history::QueryURLRequest(callback), url, want_visits); |
566 } | 566 } |
567 | 567 |
568 // Downloads ------------------------------------------------------------------- | 568 // Downloads ------------------------------------------------------------------- |
569 | 569 |
570 // Handle creation of a download by creating an entry in the history service's | 570 // Handle creation of a download by creating an entry in the history service's |
571 // 'downloads' table. | 571 // 'downloads' table. |
572 HistoryService::Handle HistoryService::CreateDownload( | 572 HistoryService::Handle HistoryService::CreateDownload( |
573 int32 id, | 573 int32 id, |
574 const content::DownloadPersistentStoreInfo& create_info, | 574 const DownloadPersistentStoreInfo& create_info, |
575 CancelableRequestConsumerBase* consumer, | 575 CancelableRequestConsumerBase* consumer, |
576 const HistoryService::DownloadCreateCallback& callback) { | 576 const HistoryService::DownloadCreateCallback& callback) { |
577 return Schedule(PRIORITY_NORMAL, &HistoryBackend::CreateDownload, consumer, | 577 return Schedule(PRIORITY_NORMAL, &HistoryBackend::CreateDownload, consumer, |
578 new history::DownloadCreateRequest(callback), id, | 578 new history::DownloadCreateRequest(callback), id, |
579 create_info); | 579 create_info); |
580 } | 580 } |
581 | 581 |
582 HistoryService::Handle HistoryService::GetNextDownloadId( | 582 HistoryService::Handle HistoryService::GetNextDownloadId( |
583 CancelableRequestConsumerBase* consumer, | 583 CancelableRequestConsumerBase* consumer, |
584 const DownloadNextIdCallback& callback) { | 584 const DownloadNextIdCallback& callback) { |
(...skipping 13 matching lines...) Expand all Loading... |
598 // Changes all IN_PROGRESS in the database entries to CANCELED. | 598 // Changes all IN_PROGRESS in the database entries to CANCELED. |
599 // IN_PROGRESS entries are the corrupted entries, not updated by next function | 599 // IN_PROGRESS entries are the corrupted entries, not updated by next function |
600 // because of the crash or some other extremal exit. | 600 // because of the crash or some other extremal exit. |
601 void HistoryService::CleanUpInProgressEntries() { | 601 void HistoryService::CleanUpInProgressEntries() { |
602 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CleanUpInProgressEntries); | 602 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CleanUpInProgressEntries); |
603 } | 603 } |
604 | 604 |
605 // Handle updates for a particular download. This is a 'fire and forget' | 605 // Handle updates for a particular download. This is a 'fire and forget' |
606 // operation, so we don't need to be called back. | 606 // operation, so we don't need to be called back. |
607 void HistoryService::UpdateDownload( | 607 void HistoryService::UpdateDownload( |
608 const content::DownloadPersistentStoreInfo& data) { | 608 const DownloadPersistentStoreInfo& data) { |
609 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data); | 609 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data); |
610 } | 610 } |
611 | 611 |
612 void HistoryService::UpdateDownloadPath(const FilePath& path, | 612 void HistoryService::RemoveDownloads(const std::set<int64>& handles) { |
613 int64 db_handle) { | |
614 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownloadPath, | |
615 path, db_handle); | |
616 } | |
617 | |
618 void HistoryService::RemoveDownload(int64 db_handle) { | |
619 ScheduleAndForget(PRIORITY_NORMAL, | 613 ScheduleAndForget(PRIORITY_NORMAL, |
620 &HistoryBackend::RemoveDownload, db_handle); | 614 &HistoryBackend::RemoveDownloads, handles); |
621 } | |
622 | |
623 void HistoryService::RemoveDownloadsBetween(Time remove_begin, | |
624 Time remove_end) { | |
625 ScheduleAndForget(PRIORITY_NORMAL, | |
626 &HistoryBackend::RemoveDownloadsBetween, | |
627 remove_begin, | |
628 remove_end); | |
629 } | 615 } |
630 | 616 |
631 HistoryService::Handle HistoryService::QueryHistory( | 617 HistoryService::Handle HistoryService::QueryHistory( |
632 const string16& text_query, | 618 const string16& text_query, |
633 const history::QueryOptions& options, | 619 const history::QueryOptions& options, |
634 CancelableRequestConsumerBase* consumer, | 620 CancelableRequestConsumerBase* consumer, |
635 const QueryHistoryCallback& callback) { | 621 const QueryHistoryCallback& callback) { |
636 return Schedule(PRIORITY_UI, &HistoryBackend::QueryHistory, consumer, | 622 return Schedule(PRIORITY_UI, &HistoryBackend::QueryHistory, consumer, |
637 new history::QueryHistoryRequest(callback), | 623 new history::QueryHistoryRequest(callback), |
638 text_query, options); | 624 text_query, options); |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 void HistoryService::RemoveVisitDatabaseObserver( | 925 void HistoryService::RemoveVisitDatabaseObserver( |
940 history::VisitDatabaseObserver* observer) { | 926 history::VisitDatabaseObserver* observer) { |
941 visit_database_observers_->RemoveObserver(observer); | 927 visit_database_observers_->RemoveObserver(observer); |
942 } | 928 } |
943 | 929 |
944 void HistoryService::NotifyVisitDBObserversOnAddVisit( | 930 void HistoryService::NotifyVisitDBObserversOnAddVisit( |
945 const history::BriefVisitInfo& info) { | 931 const history::BriefVisitInfo& info) { |
946 visit_database_observers_->Notify( | 932 visit_database_observers_->Notify( |
947 &history::VisitDatabaseObserver::OnAddVisit, info); | 933 &history::VisitDatabaseObserver::OnAddVisit, info); |
948 } | 934 } |
OLD | NEW |