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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
541 | 543 |
542 // Schedules a HistoryDBTask for running on the history backend thread. See | 544 // Schedules a HistoryDBTask for running on the history backend thread. See |
543 // HistoryDBTask for details on what this does. | 545 // HistoryDBTask for details on what this does. |
544 virtual void ScheduleDBTask(HistoryDBTask* task, | 546 virtual void ScheduleDBTask(HistoryDBTask* task, |
545 CancelableRequestConsumerBase* consumer); | 547 CancelableRequestConsumerBase* consumer); |
546 | 548 |
547 // Returns true if top sites needs to be migrated out of history into its own | 549 // Returns true if top sites needs to be migrated out of history into its own |
548 // db. | 550 // db. |
549 bool needs_top_sites_migration() const { return needs_top_sites_migration_; } | 551 bool needs_top_sites_migration() const { return needs_top_sites_migration_; } |
550 | 552 |
553 // Adds or removes observers for the VisitDatabase. Should be run in the | |
554 // thread in which the observer would like to be notified. | |
555 void AddVisitDatabaseObserver(history::VisitDatabaseObserver* observer); | |
556 void RemoveVisitDatabaseObserver(history::VisitDatabaseObserver* observer); | |
557 | |
558 // This notification method may be called on any thread. | |
559 void NotifyVisitDBObserversOnAddVisit(history::BriefVisitInfo info); | |
560 | |
551 // Testing ------------------------------------------------------------------- | 561 // Testing ------------------------------------------------------------------- |
552 | 562 |
553 // Designed for unit tests, this passes the given task on to the history | 563 // Designed for unit tests, this passes the given task on to the history |
554 // backend to be called once the history backend has terminated. This allows | 564 // backend to be called once the history backend has terminated. This allows |
555 // callers to know when the history thread is complete and the database files | 565 // callers to know when the history thread is complete and the database files |
556 // can be deleted and the next test run. Otherwise, the history thread may | 566 // can be deleted and the next test run. Otherwise, the history thread may |
557 // still be running, causing problems in subsequent tests. | 567 // still be running, causing problems in subsequent tests. |
558 // | 568 // |
559 // There can be only one closing task, so this will override any previously | 569 // There can be only one closing task, so this will override any previously |
560 // set task. We will take ownership of the pointer and delete it when done. | 570 // 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... | |
893 FilePath history_dir_; | 903 FilePath history_dir_; |
894 BookmarkService* bookmark_service_; | 904 BookmarkService* bookmark_service_; |
895 bool no_db_; | 905 bool no_db_; |
896 | 906 |
897 // True if needs top site migration. | 907 // True if needs top site migration. |
898 bool needs_top_sites_migration_; | 908 bool needs_top_sites_migration_; |
899 | 909 |
900 // The index used for quick history lookups. | 910 // The index used for quick history lookups. |
901 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; | 911 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; |
902 | 912 |
913 scoped_refptr<ObserverListThreadSafe<history::VisitDatabaseObserver> > | |
914 visit_database_observers_; | |
brettw
2012/04/20 22:21:50
Indent this line 4 spaces.
tburkard
2012/04/20 22:56:44
Done.
| |
915 | |
903 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 916 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
904 }; | 917 }; |
905 | 918 |
906 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ | 919 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ |
OLD | NEW |