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_BACKEND_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/mru_cache.h" | 14 #include "base/memory/mru_cache.h" |
| 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "chrome/browser/cancelable_request.h" | 17 #include "chrome/browser/cancelable_request.h" |
17 #include "chrome/browser/history/archived_database.h" | 18 #include "chrome/browser/history/archived_database.h" |
18 #include "chrome/browser/history/expire_history_backend.h" | 19 #include "chrome/browser/history/expire_history_backend.h" |
19 #include "chrome/browser/history/history_database.h" | 20 #include "chrome/browser/history/history_database.h" |
20 #include "chrome/browser/history/history_marshaling.h" | 21 #include "chrome/browser/history/history_marshaling.h" |
21 #include "chrome/browser/history/history_types.h" | 22 #include "chrome/browser/history/history_types.h" |
| 23 #include "chrome/browser/history/in_memory_url_index.h" |
22 #include "chrome/browser/history/text_database_manager.h" | 24 #include "chrome/browser/history/text_database_manager.h" |
23 #include "chrome/browser/history/thumbnail_database.h" | 25 #include "chrome/browser/history/thumbnail_database.h" |
24 #include "chrome/browser/history/visit_tracker.h" | 26 #include "chrome/browser/history/visit_tracker.h" |
25 #include "chrome/browser/search_engines/template_url_id.h" | 27 #include "chrome/browser/search_engines/template_url_id.h" |
26 #include "sql/init_status.h" | 28 #include "sql/init_status.h" |
27 | 29 |
28 class BookmarkService; | 30 class BookmarkService; |
29 struct DownloadPersistentStoreInfo; | 31 struct DownloadPersistentStoreInfo; |
| 32 class Profile; |
30 class TestingProfile; | 33 class TestingProfile; |
31 struct ThumbnailScore; | 34 struct ThumbnailScore; |
32 | 35 |
33 namespace history { | 36 namespace history { |
34 | 37 |
35 class CommitLaterTask; | 38 class CommitLaterTask; |
36 class HistoryPublisher; | 39 class HistoryPublisher; |
37 | 40 |
38 // *See the .cc file for more information on the design.* | 41 // *See the .cc file for more information on the design.* |
39 // | 42 // |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // See the definition of BroadcastNotificationsCallback above. This function | 100 // See the definition of BroadcastNotificationsCallback above. This function |
98 // takes ownership of the callback pointer. | 101 // takes ownership of the callback pointer. |
99 // | 102 // |
100 // |id| is used to communicate with the delegate, to identify which | 103 // |id| is used to communicate with the delegate, to identify which |
101 // backend is calling the method. | 104 // backend is calling the method. |
102 // | 105 // |
103 // |bookmark_service| is used to determine bookmarked URLs when deleting and | 106 // |bookmark_service| is used to determine bookmarked URLs when deleting and |
104 // may be NULL. | 107 // may be NULL. |
105 // | 108 // |
106 // This constructor is fast and does no I/O, so can be called at any time. | 109 // This constructor is fast and does no I/O, so can be called at any time. |
107 HistoryBackend(const FilePath& history_dir, | 110 HistoryBackend(Profile* profile, |
| 111 const FilePath& history_dir, |
108 int id, | 112 int id, |
109 Delegate* delegate, | 113 Delegate* delegate, |
110 BookmarkService* bookmark_service); | 114 BookmarkService* bookmark_service); |
111 | 115 |
112 // Must be called after creation but before any objects are created. If this | 116 // Must be called after creation but before any objects are created. If this |
113 // fails, all other functions will fail as well. (Since this runs on another | 117 // fails, all other functions will fail as well. (Since this runs on another |
114 // thread, we don't bother returning failure.) | 118 // thread, we don't bother returning failure.) |
115 // | 119 // |
116 // |languages| gives a list of language encodings with which the history | 120 // |languages| gives a list of language encodings with which the history |
117 // URLs and omnibox searches are interpreted. | 121 // URLs and omnibox searches are interpreted. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 void UpdateDownload(const DownloadPersistentStoreInfo& data); | 256 void UpdateDownload(const DownloadPersistentStoreInfo& data); |
253 void UpdateDownloadPath(const FilePath& path, int64 db_handle); | 257 void UpdateDownloadPath(const FilePath& path, int64 db_handle); |
254 void CreateDownload(scoped_refptr<DownloadCreateRequest> request, | 258 void CreateDownload(scoped_refptr<DownloadCreateRequest> request, |
255 int32 id, | 259 int32 id, |
256 const DownloadPersistentStoreInfo& info); | 260 const DownloadPersistentStoreInfo& info); |
257 void RemoveDownload(int64 db_handle); | 261 void RemoveDownload(int64 db_handle); |
258 void RemoveDownloadsBetween(const base::Time remove_begin, | 262 void RemoveDownloadsBetween(const base::Time remove_begin, |
259 const base::Time remove_end); | 263 const base::Time remove_end); |
260 void RemoveDownloads(const base::Time remove_end); | 264 void RemoveDownloads(const base::Time remove_end); |
261 | 265 |
| 266 // InMemoryURLIndex ---------------------------------------------------------- |
| 267 |
| 268 // Returns the quick history index. |
| 269 history::InMemoryURLIndex* InMemoryIndex() const { |
| 270 return in_memory_url_index_.get(); |
| 271 } |
| 272 |
262 // Segment usage ------------------------------------------------------------- | 273 // Segment usage ------------------------------------------------------------- |
263 | 274 |
264 void QuerySegmentUsage(scoped_refptr<QuerySegmentUsageRequest> request, | 275 void QuerySegmentUsage(scoped_refptr<QuerySegmentUsageRequest> request, |
265 const base::Time from_time, | 276 const base::Time from_time, |
266 int max_result_count); | 277 int max_result_count); |
267 void DeleteOldSegmentData(); | 278 void DeleteOldSegmentData(); |
268 void SetSegmentPresentationIndex(SegmentID segment_id, int index); | 279 void SetSegmentPresentationIndex(SegmentID segment_id, int index); |
269 | 280 |
270 // Keyword search terms ------------------------------------------------------ | 281 // Keyword search terms ------------------------------------------------------ |
271 | 282 |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 scoped_ptr<HistoryDatabase> db_; | 587 scoped_ptr<HistoryDatabase> db_; |
577 scoped_ptr<ThumbnailDatabase> thumbnail_db_; | 588 scoped_ptr<ThumbnailDatabase> thumbnail_db_; |
578 | 589 |
579 // Stores old history in a larger, slower database. | 590 // Stores old history in a larger, slower database. |
580 scoped_ptr<ArchivedDatabase> archived_db_; | 591 scoped_ptr<ArchivedDatabase> archived_db_; |
581 | 592 |
582 // Full text database manager, possibly NULL if the database could not be | 593 // Full text database manager, possibly NULL if the database could not be |
583 // created. | 594 // created. |
584 scoped_ptr<TextDatabaseManager> text_database_; | 595 scoped_ptr<TextDatabaseManager> text_database_; |
585 | 596 |
| 597 // The index used for quick history lookups. |
| 598 scoped_refptr<history::InMemoryURLIndex> in_memory_url_index_; |
| 599 |
586 // Manages expiration between the various databases. | 600 // Manages expiration between the various databases. |
587 ExpireHistoryBackend expirer_; | 601 ExpireHistoryBackend expirer_; |
588 | 602 |
589 // A commit has been scheduled to occur sometime in the future. We can check | 603 // A commit has been scheduled to occur sometime in the future. We can check |
590 // non-null-ness to see if there is a commit scheduled in the future, and we | 604 // non-null-ness to see if there is a commit scheduled in the future, and we |
591 // can use the pointer to cancel the scheduled commit. There can be only one | 605 // can use the pointer to cancel the scheduled commit. There can be only one |
592 // scheduled commit at a time (see ScheduleCommit). | 606 // scheduled commit at a time (see ScheduleCommit). |
593 scoped_refptr<CommitLaterTask> scheduled_commit_; | 607 scoped_refptr<CommitLaterTask> scheduled_commit_; |
594 | 608 |
595 // Maps recent redirect destination pages to the chain of redirects that | 609 // Maps recent redirect destination pages to the chain of redirects that |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 // Publishes the history to all indexers which are registered to receive | 659 // Publishes the history to all indexers which are registered to receive |
646 // history data from us. Can be NULL if there are no listeners. | 660 // history data from us. Can be NULL if there are no listeners. |
647 scoped_ptr<HistoryPublisher> history_publisher_; | 661 scoped_ptr<HistoryPublisher> history_publisher_; |
648 | 662 |
649 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 663 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
650 }; | 664 }; |
651 | 665 |
652 } // namespace history | 666 } // namespace history |
653 | 667 |
654 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 668 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
OLD | NEW |