OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "chrome/browser/history/archived_database.h" | 16 #include "chrome/browser/history/archived_database.h" |
17 #include "chrome/browser/history/expire_history_backend.h" | 17 #include "chrome/browser/history/expire_history_backend.h" |
18 #include "chrome/browser/history/history_database.h" | 18 #include "chrome/browser/history/history_database.h" |
19 #include "chrome/browser/history/history_marshaling.h" | 19 #include "chrome/browser/history/history_marshaling.h" |
20 #include "chrome/browser/history/history_types.h" | 20 #include "chrome/browser/history/history_types.h" |
21 #include "chrome/browser/history/text_database_manager.h" | 21 #include "chrome/browser/history/text_database_manager.h" |
22 #include "chrome/browser/history/thumbnail_database.h" | 22 #include "chrome/browser/history/thumbnail_database.h" |
23 #include "chrome/browser/history/visit_tracker.h" | 23 #include "chrome/browser/history/visit_tracker.h" |
24 #include "chrome/browser/search_engines/template_url_id.h" | 24 #include "chrome/browser/search_engines/template_url_id.h" |
25 #include "content/browser/cancelable_request.h" | 25 #include "content/browser/cancelable_request.h" |
26 #include "sql/init_status.h" | 26 #include "sql/init_status.h" |
27 | 27 |
28 class BookmarkService; | 28 class BookmarkService; |
29 struct DownloadPersistentStoreInfo; | 29 struct DownloadPersistentStoreInfo; |
| 30 class Profile; |
30 class TestingProfile; | 31 class TestingProfile; |
31 struct ThumbnailScore; | 32 struct ThumbnailScore; |
32 | 33 |
33 namespace history { | 34 namespace history { |
34 | 35 |
35 class CommitLaterTask; | 36 class CommitLaterTask; |
36 class HistoryPublisher; | 37 class HistoryPublisher; |
37 | 38 |
38 // *See the .cc file for more information on the design.* | 39 // *See the .cc file for more information on the design.* |
39 // | 40 // |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // See the definition of BroadcastNotificationsCallback above. This function | 98 // See the definition of BroadcastNotificationsCallback above. This function |
98 // takes ownership of the callback pointer. | 99 // takes ownership of the callback pointer. |
99 // | 100 // |
100 // |id| is used to communicate with the delegate, to identify which | 101 // |id| is used to communicate with the delegate, to identify which |
101 // backend is calling the method. | 102 // backend is calling the method. |
102 // | 103 // |
103 // |bookmark_service| is used to determine bookmarked URLs when deleting and | 104 // |bookmark_service| is used to determine bookmarked URLs when deleting and |
104 // may be NULL. | 105 // may be NULL. |
105 // | 106 // |
106 // This constructor is fast and does no I/O, so can be called at any time. | 107 // This constructor is fast and does no I/O, so can be called at any time. |
107 HistoryBackend(const FilePath& history_dir, | 108 HistoryBackend(Profile* profile, |
| 109 const FilePath& history_dir, |
108 int id, | 110 int id, |
109 Delegate* delegate, | 111 Delegate* delegate, |
110 BookmarkService* bookmark_service); | 112 BookmarkService* bookmark_service); |
111 | 113 |
112 // Must be called after creation but before any objects are created. If this | 114 // 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 | 115 // fails, all other functions will fail as well. (Since this runs on another |
114 // thread, we don't bother returning failure.) | 116 // thread, we don't bother returning failure.) |
115 // | 117 // |
116 // |languages| gives a list of language encodings with which the history | 118 // |languages| gives the languages used to break search terms and history |
117 // URLs and omnibox searches are interpreted. | 119 // page titles into separate words. |force_fail| can be set during unittests |
118 // |force_fail| can be set during unittests to unconditionally fail to init. | 120 // to unconditionally fail to init. |
119 void Init(const std::string& languages, bool force_fail); | 121 void Init(const std::string& languages, bool force_fail); |
120 | 122 |
121 // Notification that the history system is shutting down. This will break | 123 // Notification that the history system is shutting down. This will break |
122 // the refs owned by the delegate and any pending transaction so it will | 124 // the refs owned by the delegate and any pending transaction so it will |
123 // actually be deleted. | 125 // actually be deleted. |
124 void Closing(); | 126 void Closing(); |
125 | 127 |
126 // See NotifyRenderProcessHostDestruction. | 128 // See NotifyRenderProcessHostDestruction. |
127 void NotifyRenderProcessHostDestruction(const void* host); | 129 void NotifyRenderProcessHostDestruction(const void* host); |
128 | 130 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 void UpdateDownload(int64 received_bytes, int32 state, int64 db_handle); | 252 void UpdateDownload(int64 received_bytes, int32 state, int64 db_handle); |
251 void UpdateDownloadPath(const FilePath& path, int64 db_handle); | 253 void UpdateDownloadPath(const FilePath& path, int64 db_handle); |
252 void CreateDownload(scoped_refptr<DownloadCreateRequest> request, | 254 void CreateDownload(scoped_refptr<DownloadCreateRequest> request, |
253 int32 id, | 255 int32 id, |
254 const DownloadPersistentStoreInfo& info); | 256 const DownloadPersistentStoreInfo& info); |
255 void RemoveDownload(int64 db_handle); | 257 void RemoveDownload(int64 db_handle); |
256 void RemoveDownloadsBetween(const base::Time remove_begin, | 258 void RemoveDownloadsBetween(const base::Time remove_begin, |
257 const base::Time remove_end); | 259 const base::Time remove_end); |
258 void RemoveDownloads(const base::Time remove_end); | 260 void RemoveDownloads(const base::Time remove_end); |
259 | 261 |
| 262 // InMemoryURLIndex ---------------------------------------------------------- |
| 263 |
| 264 // Returns the quick history index. |
| 265 history::InMemoryURLIndex* InMemoryIndex() const { |
| 266 return in_memory_url_index_.get(); |
| 267 } |
| 268 |
260 // Segment usage ------------------------------------------------------------- | 269 // Segment usage ------------------------------------------------------------- |
261 | 270 |
262 void QuerySegmentUsage(scoped_refptr<QuerySegmentUsageRequest> request, | 271 void QuerySegmentUsage(scoped_refptr<QuerySegmentUsageRequest> request, |
263 const base::Time from_time, | 272 const base::Time from_time, |
264 int max_result_count); | 273 int max_result_count); |
265 void DeleteOldSegmentData(); | 274 void DeleteOldSegmentData(); |
266 void SetSegmentPresentationIndex(SegmentID segment_id, int index); | 275 void SetSegmentPresentationIndex(SegmentID segment_id, int index); |
267 | 276 |
268 // Keyword search terms ------------------------------------------------------ | 277 // Keyword search terms ------------------------------------------------------ |
269 | 278 |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 scoped_ptr<HistoryDatabase> db_; | 571 scoped_ptr<HistoryDatabase> db_; |
563 scoped_ptr<ThumbnailDatabase> thumbnail_db_; | 572 scoped_ptr<ThumbnailDatabase> thumbnail_db_; |
564 | 573 |
565 // Stores old history in a larger, slower database. | 574 // Stores old history in a larger, slower database. |
566 scoped_ptr<ArchivedDatabase> archived_db_; | 575 scoped_ptr<ArchivedDatabase> archived_db_; |
567 | 576 |
568 // Full text database manager, possibly NULL if the database could not be | 577 // Full text database manager, possibly NULL if the database could not be |
569 // created. | 578 // created. |
570 scoped_ptr<TextDatabaseManager> text_database_; | 579 scoped_ptr<TextDatabaseManager> text_database_; |
571 | 580 |
| 581 // The index used for quick history lookups. |
| 582 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; |
| 583 |
572 // Manages expiration between the various databases. | 584 // Manages expiration between the various databases. |
573 ExpireHistoryBackend expirer_; | 585 ExpireHistoryBackend expirer_; |
574 | 586 |
575 // A commit has been scheduled to occur sometime in the future. We can check | 587 // A commit has been scheduled to occur sometime in the future. We can check |
576 // non-null-ness to see if there is a commit scheduled in the future, and we | 588 // non-null-ness to see if there is a commit scheduled in the future, and we |
577 // can use the pointer to cancel the scheduled commit. There can be only one | 589 // can use the pointer to cancel the scheduled commit. There can be only one |
578 // scheduled commit at a time (see ScheduleCommit). | 590 // scheduled commit at a time (see ScheduleCommit). |
579 scoped_refptr<CommitLaterTask> scheduled_commit_; | 591 scoped_refptr<CommitLaterTask> scheduled_commit_; |
580 | 592 |
581 // Maps recent redirect destination pages to the chain of redirects that | 593 // Maps recent redirect destination pages to the chain of redirects that |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 // Publishes the history to all indexers which are registered to receive | 643 // Publishes the history to all indexers which are registered to receive |
632 // history data from us. Can be NULL if there are no listeners. | 644 // history data from us. Can be NULL if there are no listeners. |
633 scoped_ptr<HistoryPublisher> history_publisher_; | 645 scoped_ptr<HistoryPublisher> history_publisher_; |
634 | 646 |
635 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 647 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
636 }; | 648 }; |
637 | 649 |
638 } // namespace history | 650 } // namespace history |
639 | 651 |
640 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 652 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
OLD | NEW |