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 #ifndef CHROME_BROWSER_HISTORY_HISTORY_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_H_ |
6 #define CHROME_BROWSER_HISTORY_HISTORY_H_ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/observer_list_threadsafe.h" |
17 #include "base/string16.h" | 18 #include "base/string16.h" |
18 #include "chrome/browser/cancelable_request.h" | 19 #include "chrome/browser/cancelable_request.h" |
19 #include "chrome/browser/favicon/favicon_service.h" | 20 #include "chrome/browser/favicon/favicon_service.h" |
20 #include "chrome/browser/history/history_types.h" | 21 #include "chrome/browser/history/history_types.h" |
21 #include "chrome/browser/search_engines/template_url_id.h" | 22 #include "chrome/browser/search_engines/template_url_id.h" |
22 #include "chrome/common/ref_counted_util.h" | 23 #include "chrome/common/ref_counted_util.h" |
23 #include "content/public/browser/notification_observer.h" | 24 #include "content/public/browser/notification_observer.h" |
24 #include "content/public/browser/notification_registrar.h" | 25 #include "content/public/browser/notification_registrar.h" |
25 #include "content/public/common/page_transition_types.h" | 26 #include "content/public/common/page_transition_types.h" |
26 #include "sql/init_status.h" | 27 #include "sql/init_status.h" |
(...skipping 20 matching lines...) Expand all Loading... |
47 class InMemoryHistoryBackend; | 48 class InMemoryHistoryBackend; |
48 class InMemoryURLIndex; | 49 class InMemoryURLIndex; |
49 class InMemoryURLIndexTest; | 50 class InMemoryURLIndexTest; |
50 class HistoryAddPageArgs; | 51 class HistoryAddPageArgs; |
51 class HistoryBackend; | 52 class HistoryBackend; |
52 class HistoryDatabase; | 53 class HistoryDatabase; |
53 struct HistoryDetails; | 54 struct HistoryDetails; |
54 class HistoryQueryTest; | 55 class HistoryQueryTest; |
55 class VisitFilter; | 56 class VisitFilter; |
56 class URLDatabase; | 57 class URLDatabase; |
| 58 class VisitDatabaseObserver; |
57 } // namespace history | 59 } // namespace history |
58 | 60 |
59 | 61 |
60 // HistoryDBTask can be used to process arbitrary work on the history backend | 62 // HistoryDBTask can be used to process arbitrary work on the history backend |
61 // thread. HistoryDBTask is scheduled using HistoryService::ScheduleDBTask. | 63 // thread. HistoryDBTask is scheduled using HistoryService::ScheduleDBTask. |
62 // When HistoryBackend processes the task it invokes RunOnDBThread. Once the | 64 // When HistoryBackend processes the task it invokes RunOnDBThread. Once the |
63 // task completes and has not been canceled, DoneRunOnMainThread is invoked back | 65 // task completes and has not been canceled, DoneRunOnMainThread is invoked back |
64 // on the main thread. | 66 // on the main thread. |
65 class HistoryDBTask : public base::RefCountedThreadSafe<HistoryDBTask> { | 67 class HistoryDBTask : public base::RefCountedThreadSafe<HistoryDBTask> { |
66 public: | 68 public: |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 541 |
540 // Schedules a HistoryDBTask for running on the history backend thread. See | 542 // Schedules a HistoryDBTask for running on the history backend thread. See |
541 // HistoryDBTask for details on what this does. | 543 // HistoryDBTask for details on what this does. |
542 virtual void ScheduleDBTask(HistoryDBTask* task, | 544 virtual void ScheduleDBTask(HistoryDBTask* task, |
543 CancelableRequestConsumerBase* consumer); | 545 CancelableRequestConsumerBase* consumer); |
544 | 546 |
545 // Returns true if top sites needs to be migrated out of history into its own | 547 // Returns true if top sites needs to be migrated out of history into its own |
546 // db. | 548 // db. |
547 bool needs_top_sites_migration() const { return needs_top_sites_migration_; } | 549 bool needs_top_sites_migration() const { return needs_top_sites_migration_; } |
548 | 550 |
| 551 // Adds or removes observers for the VisitDatabase. Should be run in the |
| 552 // thread in which the observer would like to be notified. |
| 553 void AddVisitDatabaseObserver(history::VisitDatabaseObserver* observer); |
| 554 void RemoveVisitDatabaseObserver(history::VisitDatabaseObserver* observer); |
| 555 |
| 556 // This notification method may be called on any thread. |
| 557 void NotifyVisitDBObserversOnAddVisit(const history::BriefVisitInfo& info); |
| 558 |
549 // Testing ------------------------------------------------------------------- | 559 // Testing ------------------------------------------------------------------- |
550 | 560 |
551 // Designed for unit tests, this passes the given task on to the history | 561 // Designed for unit tests, this passes the given task on to the history |
552 // backend to be called once the history backend has terminated. This allows | 562 // backend to be called once the history backend has terminated. This allows |
553 // callers to know when the history thread is complete and the database files | 563 // callers to know when the history thread is complete and the database files |
554 // can be deleted and the next test run. Otherwise, the history thread may | 564 // can be deleted and the next test run. Otherwise, the history thread may |
555 // still be running, causing problems in subsequent tests. | 565 // still be running, causing problems in subsequent tests. |
556 // | 566 // |
557 // There can be only one closing task, so this will override any previously | 567 // There can be only one closing task, so this will override any previously |
558 // set task. We will take ownership of the pointer and delete it when done. | 568 // set task. We will take ownership of the pointer and delete it when done. |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 FilePath history_dir_; | 901 FilePath history_dir_; |
892 BookmarkService* bookmark_service_; | 902 BookmarkService* bookmark_service_; |
893 bool no_db_; | 903 bool no_db_; |
894 | 904 |
895 // True if needs top site migration. | 905 // True if needs top site migration. |
896 bool needs_top_sites_migration_; | 906 bool needs_top_sites_migration_; |
897 | 907 |
898 // The index used for quick history lookups. | 908 // The index used for quick history lookups. |
899 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; | 909 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; |
900 | 910 |
| 911 scoped_refptr<ObserverListThreadSafe<history::VisitDatabaseObserver> > |
| 912 visit_database_observers_; |
| 913 |
901 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 914 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
902 }; | 915 }; |
903 | 916 |
904 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ | 917 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ |
OLD | NEW |