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

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

Issue 10665049: Make DownloadHistory observe manager, items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 months 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 17 matching lines...) Expand all
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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 CancelableRequestConsumerBase* consumer, 562 CancelableRequestConsumerBase* consumer,
563 const QueryURLCallback& callback) { 563 const QueryURLCallback& callback) {
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 void HistoryService::CreateDownload(
573 int32 id, 573 const DownloadPersistentStoreInfo& info,
574 const content::DownloadPersistentStoreInfo& create_info,
575 CancelableRequestConsumerBase* consumer,
576 const HistoryService::DownloadCreateCallback& callback) { 574 const HistoryService::DownloadCreateCallback& callback) {
577 return Schedule(PRIORITY_NORMAL, &HistoryBackend::CreateDownload, consumer, 575 LoadBackendIfNecessary();
578 new history::DownloadCreateRequest(callback), id, 576 ScheduleTask(PRIORITY_NORMAL, base::Bind(
579 create_info); 577 &HistoryBackend::CreateDownload, history_backend_.get(), info, callback));
578 }
579
580 void HistoryService::GetVisibleVisitCountToHostSimple(
581 const GURL& url,
582 const GetVisibleVisitCountToHostSimpleCallback& callback) {
583 LoadBackendIfNecessary();
584 ScheduleTask(PRIORITY_NORMAL, base::Bind(
585 &HistoryBackend::GetVisibleVisitCountToHostSimple, history_backend_.get(),
586 url, callback));
580 } 587 }
581 588
582 HistoryService::Handle HistoryService::GetNextDownloadId( 589 HistoryService::Handle HistoryService::GetNextDownloadId(
583 CancelableRequestConsumerBase* consumer, 590 CancelableRequestConsumerBase* consumer,
584 const DownloadNextIdCallback& callback) { 591 const DownloadNextIdCallback& callback) {
585 return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetNextDownloadId, consumer, 592 return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetNextDownloadId, consumer,
586 new history::DownloadNextIdRequest(callback)); 593 new history::DownloadNextIdRequest(callback));
587 } 594 }
588 595
589 // Handle queries for a list of all downloads in the history database's 596 // Handle queries for a list of all downloads in the history database's
590 // 'downloads' table. 597 // 'downloads' table.
591 HistoryService::Handle HistoryService::QueryDownloads( 598 void HistoryService::QueryDownloads(
592 CancelableRequestConsumerBase* consumer,
593 const DownloadQueryCallback& callback) { 599 const DownloadQueryCallback& callback) {
594 return Schedule(PRIORITY_NORMAL, &HistoryBackend::QueryDownloads, consumer, 600 LoadBackendIfNecessary();
595 new history::DownloadQueryRequest(callback)); 601 ScheduleTask(PRIORITY_NORMAL, base::Bind(
602 &HistoryBackend::QueryDownloads, history_backend_.get(), callback));
596 } 603 }
597 604
598 // Changes all IN_PROGRESS in the database entries to CANCELED. 605 // Changes all IN_PROGRESS in the database entries to CANCELED.
599 // IN_PROGRESS entries are the corrupted entries, not updated by next function 606 // IN_PROGRESS entries are the corrupted entries, not updated by next function
600 // because of the crash or some other extremal exit. 607 // because of the crash or some other extremal exit.
601 void HistoryService::CleanUpInProgressEntries() { 608 void HistoryService::CleanUpInProgressEntries() {
602 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CleanUpInProgressEntries); 609 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CleanUpInProgressEntries);
603 } 610 }
604 611
605 // Handle updates for a particular download. This is a 'fire and forget' 612 // Handle updates for a particular download. This is a 'fire and forget'
606 // operation, so we don't need to be called back. 613 // operation, so we don't need to be called back.
607 void HistoryService::UpdateDownload( 614 void HistoryService::UpdateDownload(
608 const content::DownloadPersistentStoreInfo& data) { 615 const DownloadPersistentStoreInfo& data) {
609 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data); 616 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data);
610 } 617 }
611 618
612 void HistoryService::UpdateDownloadPath(const FilePath& path, 619 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, 620 ScheduleAndForget(PRIORITY_NORMAL,
620 &HistoryBackend::RemoveDownload, db_handle); 621 &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 } 622 }
630 623
631 HistoryService::Handle HistoryService::QueryHistory( 624 HistoryService::Handle HistoryService::QueryHistory(
632 const string16& text_query, 625 const string16& text_query,
633 const history::QueryOptions& options, 626 const history::QueryOptions& options,
634 CancelableRequestConsumerBase* consumer, 627 CancelableRequestConsumerBase* consumer,
635 const QueryHistoryCallback& callback) { 628 const QueryHistoryCallback& callback) {
636 return Schedule(PRIORITY_UI, &HistoryBackend::QueryHistory, consumer, 629 return Schedule(PRIORITY_UI, &HistoryBackend::QueryHistory, consumer,
637 new history::QueryHistoryRequest(callback), 630 new history::QueryHistoryRequest(callback),
638 text_query, options); 631 text_query, options);
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 void HistoryService::RemoveVisitDatabaseObserver( 932 void HistoryService::RemoveVisitDatabaseObserver(
940 history::VisitDatabaseObserver* observer) { 933 history::VisitDatabaseObserver* observer) {
941 visit_database_observers_->RemoveObserver(observer); 934 visit_database_observers_->RemoveObserver(observer);
942 } 935 }
943 936
944 void HistoryService::NotifyVisitDBObserversOnAddVisit( 937 void HistoryService::NotifyVisitDBObserversOnAddVisit(
945 const history::BriefVisitInfo& info) { 938 const history::BriefVisitInfo& info) {
946 visit_database_observers_->Notify( 939 visit_database_observers_->Notify(
947 &history::VisitDatabaseObserver::OnAddVisit, info); 940 &history::VisitDatabaseObserver::OnAddVisit, info);
948 } 941 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698