Chromium Code Reviews| 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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 570 CancelableRequestConsumerBase* consumer, | 570 CancelableRequestConsumerBase* consumer, |
| 571 const QueryURLCallback& callback) { | 571 const QueryURLCallback& callback) { |
| 572 return Schedule(PRIORITY_UI, &HistoryBackend::QueryURL, consumer, | 572 return Schedule(PRIORITY_UI, &HistoryBackend::QueryURL, consumer, |
| 573 new history::QueryURLRequest(callback), url, want_visits); | 573 new history::QueryURLRequest(callback), url, want_visits); |
| 574 } | 574 } |
| 575 | 575 |
| 576 // Downloads ------------------------------------------------------------------- | 576 // Downloads ------------------------------------------------------------------- |
| 577 | 577 |
| 578 // Handle creation of a download by creating an entry in the history service's | 578 // Handle creation of a download by creating an entry in the history service's |
| 579 // 'downloads' table. | 579 // 'downloads' table. |
| 580 HistoryService::Handle HistoryService::CreateDownload( | 580 void HistoryService::CreateDownload( |
| 581 int32 id, | 581 const DownloadPersistentStoreInfo& info, |
| 582 const content::DownloadPersistentStoreInfo& create_info, | |
| 583 CancelableRequestConsumerBase* consumer, | |
| 584 const HistoryService::DownloadCreateCallback& callback) { | 582 const HistoryService::DownloadCreateCallback& callback) { |
| 585 return Schedule(PRIORITY_NORMAL, &HistoryBackend::CreateDownload, consumer, | 583 LoadBackendIfNecessary(); |
| 586 new history::DownloadCreateRequest(callback), id, | 584 ScheduleTask(PRIORITY_NORMAL, base::Bind( |
| 587 create_info); | 585 &HistoryBackend::CreateDownload, history_backend_.get(), info, callback)); |
| 586 } | |
| 587 | |
| 588 void HistoryService::GetVisibleVisitCountToHostSimple( | |
| 589 const GURL& url, | |
| 590 const GetVisibleVisitCountToHostSimpleCallback& callback) { | |
| 591 LoadBackendIfNecessary(); | |
| 592 ScheduleTask(PRIORITY_NORMAL, base::Bind( | |
| 593 &HistoryBackend::GetVisibleVisitCountToHostSimple, history_backend_.get(), | |
| 594 url, callback)); | |
| 588 } | 595 } |
| 589 | 596 |
| 590 HistoryService::Handle HistoryService::GetNextDownloadId( | 597 HistoryService::Handle HistoryService::GetNextDownloadId( |
| 591 CancelableRequestConsumerBase* consumer, | 598 CancelableRequestConsumerBase* consumer, |
| 592 const DownloadNextIdCallback& callback) { | 599 const DownloadNextIdCallback& callback) { |
| 593 return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetNextDownloadId, consumer, | 600 return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetNextDownloadId, consumer, |
| 594 new history::DownloadNextIdRequest(callback)); | 601 new history::DownloadNextIdRequest(callback)); |
| 595 } | 602 } |
| 596 | 603 |
| 597 // 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 |
| 598 // 'downloads' table. | 605 // 'downloads' table. |
| 599 HistoryService::Handle HistoryService::QueryDownloads( | 606 void HistoryService::QueryDownloads( |
|
Randy Smith (Not in Mondays)
2012/09/11 18:36:53
nit: This and next line look like they could fit o
benjhayden
2012/09/13 15:18:16
Done.
| |
| 600 CancelableRequestConsumerBase* consumer, | |
| 601 const DownloadQueryCallback& callback) { | 607 const DownloadQueryCallback& callback) { |
| 602 return Schedule(PRIORITY_NORMAL, &HistoryBackend::QueryDownloads, consumer, | 608 LoadBackendIfNecessary(); |
| 603 new history::DownloadQueryRequest(callback)); | 609 ScheduleTask(PRIORITY_NORMAL, base::Bind( |
| 610 &HistoryBackend::QueryDownloads, history_backend_.get(), callback)); | |
| 604 } | 611 } |
| 605 | 612 |
| 606 // Changes all IN_PROGRESS in the database entries to CANCELED. | 613 // Changes all IN_PROGRESS in the database entries to CANCELED. |
| 607 // 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 |
| 608 // because of the crash or some other extremal exit. | 615 // because of the crash or some other extremal exit. |
| 609 void HistoryService::CleanUpInProgressEntries() { | 616 void HistoryService::CleanUpInProgressEntries() { |
| 610 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CleanUpInProgressEntries); | 617 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CleanUpInProgressEntries); |
| 611 } | 618 } |
| 612 | 619 |
| 613 // 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' |
| 614 // operation, so we don't need to be called back. | 621 // operation, so we don't need to be called back. |
| 615 void HistoryService::UpdateDownload( | 622 void HistoryService::UpdateDownload( |
| 616 const content::DownloadPersistentStoreInfo& data) { | 623 const DownloadPersistentStoreInfo& data) { |
| 617 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data); | 624 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data); |
| 618 } | 625 } |
| 619 | 626 |
| 620 void HistoryService::UpdateDownloadPath(const FilePath& path, | 627 void HistoryService::RemoveDownloads(const std::set<int64>& handles) { |
| 621 int64 db_handle) { | |
| 622 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownloadPath, | |
| 623 path, db_handle); | |
| 624 } | |
| 625 | |
| 626 void HistoryService::RemoveDownload(int64 db_handle) { | |
| 627 ScheduleAndForget(PRIORITY_NORMAL, | 628 ScheduleAndForget(PRIORITY_NORMAL, |
| 628 &HistoryBackend::RemoveDownload, db_handle); | 629 &HistoryBackend::RemoveDownloads, handles); |
| 629 } | |
| 630 | |
| 631 void HistoryService::RemoveDownloadsBetween(Time remove_begin, | |
| 632 Time remove_end) { | |
| 633 ScheduleAndForget(PRIORITY_NORMAL, | |
| 634 &HistoryBackend::RemoveDownloadsBetween, | |
| 635 remove_begin, | |
| 636 remove_end); | |
| 637 } | 630 } |
| 638 | 631 |
| 639 HistoryService::Handle HistoryService::QueryHistory( | 632 HistoryService::Handle HistoryService::QueryHistory( |
| 640 const string16& text_query, | 633 const string16& text_query, |
| 641 const history::QueryOptions& options, | 634 const history::QueryOptions& options, |
| 642 CancelableRequestConsumerBase* consumer, | 635 CancelableRequestConsumerBase* consumer, |
| 643 const QueryHistoryCallback& callback) { | 636 const QueryHistoryCallback& callback) { |
| 644 return Schedule(PRIORITY_UI, &HistoryBackend::QueryHistory, consumer, | 637 return Schedule(PRIORITY_UI, &HistoryBackend::QueryHistory, consumer, |
| 645 new history::QueryHistoryRequest(callback), | 638 new history::QueryHistoryRequest(callback), |
| 646 text_query, options); | 639 text_query, options); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 947 void HistoryService::RemoveVisitDatabaseObserver( | 940 void HistoryService::RemoveVisitDatabaseObserver( |
| 948 history::VisitDatabaseObserver* observer) { | 941 history::VisitDatabaseObserver* observer) { |
| 949 visit_database_observers_->RemoveObserver(observer); | 942 visit_database_observers_->RemoveObserver(observer); |
| 950 } | 943 } |
| 951 | 944 |
| 952 void HistoryService::NotifyVisitDBObserversOnAddVisit( | 945 void HistoryService::NotifyVisitDBObserversOnAddVisit( |
| 953 const history::BriefVisitInfo& info) { | 946 const history::BriefVisitInfo& info) { |
| 954 visit_database_observers_->Notify( | 947 visit_database_observers_->Notify( |
| 955 &history::VisitDatabaseObserver::OnAddVisit, info); | 948 &history::VisitDatabaseObserver::OnAddVisit, info); |
| 956 } | 949 } |
| OLD | NEW |