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 "sql/init_status.h" | 25 #include "sql/init_status.h" |
26 | 26 |
27 class BookmarkService; | 27 class BookmarkService; |
28 struct DownloadPersistentStoreInfo; | 28 struct DownloadPersistentStoreInfo; |
29 class Profile; | |
29 class TestingProfile; | 30 class TestingProfile; |
30 struct ThumbnailScore; | 31 struct ThumbnailScore; |
31 | 32 |
32 namespace history { | 33 namespace history { |
33 | 34 |
34 class CommitLaterTask; | 35 class CommitLaterTask; |
35 class HistoryPublisher; | 36 class HistoryPublisher; |
36 | 37 |
37 // *See the .cc file for more information on the design.* | 38 // *See the .cc file for more information on the design.* |
38 // | 39 // |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 // See the definition of BroadcastNotificationsCallback above. This function | 97 // See the definition of BroadcastNotificationsCallback above. This function |
97 // takes ownership of the callback pointer. | 98 // takes ownership of the callback pointer. |
98 // | 99 // |
99 // |id| is used to communicate with the delegate, to identify which | 100 // |id| is used to communicate with the delegate, to identify which |
100 // backend is calling the method. | 101 // backend is calling the method. |
101 // | 102 // |
102 // |bookmark_service| is used to determine bookmarked URLs when deleting and | 103 // |bookmark_service| is used to determine bookmarked URLs when deleting and |
103 // may be NULL. | 104 // may be NULL. |
104 // | 105 // |
105 // This constructor is fast and does no I/O, so can be called at any time. | 106 // This constructor is fast and does no I/O, so can be called at any time. |
106 HistoryBackend(const FilePath& history_dir, | 107 HistoryBackend(Profile* profile, |
108 const FilePath& history_dir, | |
107 int id, | 109 int id, |
108 Delegate* delegate, | 110 Delegate* delegate, |
109 BookmarkService* bookmark_service); | 111 BookmarkService* bookmark_service); |
110 | 112 |
111 // Must be called after creation but before any objects are created. If this | 113 // Must be called after creation but before any objects are created. If this |
112 // fails, all other functions will fail as well. (Since this runs on another | 114 // fails, all other functions will fail as well. (Since this runs on another |
113 // thread, we don't bother returning failure.) | 115 // thread, we don't bother returning failure.) |
114 // | 116 // |
115 // |languages| gives a list of language encodings with which the history | 117 // |languages| gives the languages used to break search terms and history |
116 // URLs and omnibox searches are interpreted. | 118 // page titles into separate words. |force_fail| can be set during unittests |
117 // |force_fail| can be set during unittests to unconditionally fail to init. | 119 // to unconditionally fail to init. |
118 void Init(const std::string& languages, bool force_fail); | 120 void Init(const std::string& languages, bool force_fail); |
119 | 121 |
120 // Notification that the history system is shutting down. This will break | 122 // Notification that the history system is shutting down. This will break |
121 // the refs owned by the delegate and any pending transaction so it will | 123 // the refs owned by the delegate and any pending transaction so it will |
122 // actually be deleted. | 124 // actually be deleted. |
123 void Closing(); | 125 void Closing(); |
124 | 126 |
125 // See NotifyRenderProcessHostDestruction. | 127 // See NotifyRenderProcessHostDestruction. |
126 void NotifyRenderProcessHostDestruction(const void* host); | 128 void NotifyRenderProcessHostDestruction(const void* host); |
127 | 129 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 void UpdateDownload(int64 received_bytes, int32 state, int64 db_handle); | 251 void UpdateDownload(int64 received_bytes, int32 state, int64 db_handle); |
250 void UpdateDownloadPath(const FilePath& path, int64 db_handle); | 252 void UpdateDownloadPath(const FilePath& path, int64 db_handle); |
251 void CreateDownload(scoped_refptr<DownloadCreateRequest> request, | 253 void CreateDownload(scoped_refptr<DownloadCreateRequest> request, |
252 int32 id, | 254 int32 id, |
253 const DownloadPersistentStoreInfo& info); | 255 const DownloadPersistentStoreInfo& info); |
254 void RemoveDownload(int64 db_handle); | 256 void RemoveDownload(int64 db_handle); |
255 void RemoveDownloadsBetween(const base::Time remove_begin, | 257 void RemoveDownloadsBetween(const base::Time remove_begin, |
256 const base::Time remove_end); | 258 const base::Time remove_end); |
257 void RemoveDownloads(const base::Time remove_end); | 259 void RemoveDownloads(const base::Time remove_end); |
258 | 260 |
261 // InMemoryURLIndex ---------------------------------------------------------- | |
262 | |
263 // Returns the quick history index. | |
264 history::InMemoryURLIndex* InMemoryIndex() const { | |
265 return in_memory_url_index_.get(); | |
266 } | |
267 | |
259 // Segment usage ------------------------------------------------------------- | 268 // Segment usage ------------------------------------------------------------- |
260 | 269 |
261 void QuerySegmentUsage(scoped_refptr<QuerySegmentUsageRequest> request, | 270 void QuerySegmentUsage(scoped_refptr<QuerySegmentUsageRequest> request, |
262 const base::Time from_time, | 271 const base::Time from_time, |
263 int max_result_count); | 272 int max_result_count); |
264 void DeleteOldSegmentData(); | 273 void DeleteOldSegmentData(); |
265 void SetSegmentPresentationIndex(SegmentID segment_id, int index); | 274 void SetSegmentPresentationIndex(SegmentID segment_id, int index); |
266 | 275 |
267 // Keyword search terms ------------------------------------------------------ | 276 // Keyword search terms ------------------------------------------------------ |
268 | 277 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
534 BookmarkService* GetBookmarkService(); | 543 BookmarkService* GetBookmarkService(); |
535 | 544 |
536 // If there is a favicon for |page_url| and one of the types in |icon_types|, | 545 // If there is a favicon for |page_url| and one of the types in |icon_types|, |
537 // |favicon| is set appropriately and true is returned. | 546 // |favicon| is set appropriately and true is returned. |
538 bool GetFaviconFromDB(const GURL& page_url, | 547 bool GetFaviconFromDB(const GURL& page_url, |
539 int icon_types, | 548 int icon_types, |
540 FaviconData* favicon); | 549 FaviconData* favicon); |
541 | 550 |
542 // Data ---------------------------------------------------------------------- | 551 // Data ---------------------------------------------------------------------- |
543 | 552 |
553 Profile* profile_; // The profile may be NULL during unittests. | |
Peter Kasting
2011/10/05 00:11:42
Where do you use this?
mrossetti
2011/10/07 17:04:14
Only for initializing the InMemoryURLIndex instanc
| |
554 | |
544 // Delegate. See the class definition above for more information. This will | 555 // Delegate. See the class definition above for more information. This will |
545 // be NULL before Init is called and after Cleanup, but is guaranteed | 556 // be NULL before Init is called and after Cleanup, but is guaranteed |
546 // non-NULL in between. | 557 // non-NULL in between. |
547 scoped_ptr<Delegate> delegate_; | 558 scoped_ptr<Delegate> delegate_; |
548 | 559 |
549 // The id of this class, given in creation and used for identifying the | 560 // The id of this class, given in creation and used for identifying the |
550 // backend when calling the delegate. | 561 // backend when calling the delegate. |
551 int id_; | 562 int id_; |
552 | 563 |
553 // Directory where database files will be stored. | 564 // Directory where database files will be stored. |
554 FilePath history_dir_; | 565 FilePath history_dir_; |
555 | 566 |
556 // The history/thumbnail databases. Either MAY BE NULL if the database could | 567 // The history/thumbnail databases. Either MAY BE NULL if the database could |
557 // not be opened, all users must first check for NULL and return immediately | 568 // not be opened, all users must first check for NULL and return immediately |
558 // if it is. The thumbnail DB may be NULL when the history one isn't, but not | 569 // if it is. The thumbnail DB may be NULL when the history one isn't, but not |
559 // vice-versa. | 570 // vice-versa. |
560 scoped_ptr<HistoryDatabase> db_; | 571 scoped_ptr<HistoryDatabase> db_; |
561 scoped_ptr<ThumbnailDatabase> thumbnail_db_; | 572 scoped_ptr<ThumbnailDatabase> thumbnail_db_; |
562 | 573 |
563 // Stores old history in a larger, slower database. | 574 // Stores old history in a larger, slower database. |
564 scoped_ptr<ArchivedDatabase> archived_db_; | 575 scoped_ptr<ArchivedDatabase> archived_db_; |
565 | 576 |
566 // 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 |
567 // created. | 578 // created. |
568 scoped_ptr<TextDatabaseManager> text_database_; | 579 scoped_ptr<TextDatabaseManager> text_database_; |
569 | 580 |
581 // The index used for quick history lookups. | |
582 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; | |
583 | |
570 // Manages expiration between the various databases. | 584 // Manages expiration between the various databases. |
571 ExpireHistoryBackend expirer_; | 585 ExpireHistoryBackend expirer_; |
572 | 586 |
573 // 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 |
574 // 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 |
575 // 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 |
576 // scheduled commit at a time (see ScheduleCommit). | 590 // scheduled commit at a time (see ScheduleCommit). |
577 scoped_refptr<CommitLaterTask> scheduled_commit_; | 591 scoped_refptr<CommitLaterTask> scheduled_commit_; |
578 | 592 |
579 // 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... | |
629 // Publishes the history to all indexers which are registered to receive | 643 // Publishes the history to all indexers which are registered to receive |
630 // 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. |
631 scoped_ptr<HistoryPublisher> history_publisher_; | 645 scoped_ptr<HistoryPublisher> history_publisher_; |
632 | 646 |
633 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 647 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
634 }; | 648 }; |
635 | 649 |
636 } // namespace history | 650 } // namespace history |
637 | 651 |
638 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 652 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
OLD | NEW |