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