| 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_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> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 class Profile; | 36 class Profile; |
| 37 | 37 |
| 38 namespace base { | 38 namespace base { |
| 39 class Thread; | 39 class Thread; |
| 40 class Time; | 40 class Time; |
| 41 } | 41 } |
| 42 | 42 |
| 43 namespace history { | 43 namespace history { |
| 44 class InMemoryHistoryBackend; | 44 class InMemoryHistoryBackend; |
| 45 class InMemoryURLIndex; | 45 class InMemoryURLIndex; |
| 46 class InMemoryURLIndexTest; |
| 46 class HistoryAddPageArgs; | 47 class HistoryAddPageArgs; |
| 47 class HistoryBackend; | 48 class HistoryBackend; |
| 48 class HistoryDatabase; | 49 class HistoryDatabase; |
| 49 struct HistoryDetails; | 50 struct HistoryDetails; |
| 50 class HistoryQueryTest; | 51 class HistoryQueryTest; |
| 51 class URLDatabase; | 52 class URLDatabase; |
| 52 } // namespace history | 53 } // namespace history |
| 53 | 54 |
| 54 | 55 |
| 55 // HistoryDBTask can be used to process arbitrary work on the history backend | 56 // HistoryDBTask can be used to process arbitrary work on the history backend |
| 56 // thread. HistoryDBTask is scheduled using HistoryService::ScheduleDBTask. | 57 // thread. HistoryDBTask is scheduled using HistoryService::ScheduleDBTask. |
| 57 // When HistoryBackend processes the task it invokes RunOnDBThread. Once the | 58 // When HistoryBackend processes the task it invokes RunOnDBThread. Once the |
| 58 // task completes and has not been canceled, DoneRunOnMainThread is invoked back | 59 // task completes and has not been canceled, DoneRunOnMainThread is invoked back |
| 59 // on the main thread. | 60 // on the main thread. |
| 60 class HistoryDBTask : public base::RefCountedThreadSafe<HistoryDBTask> { | 61 class HistoryDBTask : public base::RefCountedThreadSafe<HistoryDBTask> { |
| 61 public: | 62 public: |
| 62 // Invoked on the database thread. The return value indicates whether the | 63 // Invoked on the database thread. The return value indicates whether the |
| 63 // task is done. A return value of true signals the task is done and | 64 // task is done. A return value of true signals the task is done and |
| 64 // RunOnDBThread should NOT be invoked again. A return value of false | 65 // RunOnDBThread should NOT be invoked again. A return value of false |
| 65 // indicates the task is not done, and should be run again after other | 66 // indicates the task is not done, and should be run again after other |
| 66 // tasks are given a chance to be processed. | 67 // tasks are given a chance to be processed. |
| 67 virtual bool RunOnDBThread(history::HistoryBackend* backend, | 68 virtual bool RunOnDBThread(history::HistoryBackend* backend, |
| 68 history::HistoryDatabase* db) = 0; | 69 history::HistoryDatabase* db) = 0; |
| 69 | 70 |
| 70 // Invoked on the main thread once RunOnDBThread has returned false. This is | 71 // Invoked on the main thread once RunOnDBThread has returned true. This is |
| 71 // only invoked if the request was not canceled and returned true from | 72 // only invoked if the request was not canceled and returned true from |
| 72 // RunOnDBThread. | 73 // RunOnDBThread. |
| 73 virtual void DoneRunOnMainThread() = 0; | 74 virtual void DoneRunOnMainThread() = 0; |
| 74 | 75 |
| 75 protected: | 76 protected: |
| 76 friend class base::RefCountedThreadSafe<HistoryDBTask>; | 77 friend class base::RefCountedThreadSafe<HistoryDBTask>; |
| 77 | 78 |
| 78 virtual ~HistoryDBTask() {} | 79 virtual ~HistoryDBTask() {} |
| 79 }; | 80 }; |
| 80 | 81 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 137 |
| 137 // Triggers the backend to load if it hasn't already, and then returns the | 138 // Triggers the backend to load if it hasn't already, and then returns the |
| 138 // in-memory URL database. The returned pointer MAY BE NULL if the in-memory | 139 // in-memory URL database. The returned pointer MAY BE NULL if the in-memory |
| 139 // database has not been loaded yet. This pointer is owned by the history | 140 // database has not been loaded yet. This pointer is owned by the history |
| 140 // system. Callers should not store or cache this value. | 141 // system. Callers should not store or cache this value. |
| 141 // | 142 // |
| 142 // TODO(brettw) this should return the InMemoryHistoryBackend. | 143 // TODO(brettw) this should return the InMemoryHistoryBackend. |
| 143 history::URLDatabase* InMemoryDatabase(); | 144 history::URLDatabase* InMemoryDatabase(); |
| 144 | 145 |
| 145 // Return the quick history index. | 146 // Return the quick history index. |
| 146 history::InMemoryURLIndex* InMemoryIndex(); | 147 history::InMemoryURLIndex* InMemoryIndex() const { |
| 148 return in_memory_url_index_.get(); |
| 149 } |
| 147 | 150 |
| 148 // Navigation ---------------------------------------------------------------- | 151 // Navigation ---------------------------------------------------------------- |
| 149 | 152 |
| 150 // Adds the given canonical URL to history with the current time as the visit | 153 // Adds the given canonical URL to history with the current time as the visit |
| 151 // time. Referrer may be the empty string. | 154 // time. Referrer may be the empty string. |
| 152 // | 155 // |
| 153 // The supplied render process host is used to scope the given page ID. Page | 156 // The supplied render process host is used to scope the given page ID. Page |
| 154 // IDs are only unique inside a given render process, so we need that to | 157 // IDs are only unique inside a given render process, so we need that to |
| 155 // differentiate them. This pointer should not be dereferenced by the history | 158 // differentiate them. This pointer should not be dereferenced by the history |
| 156 // system. Since render view host pointers may be reused (if one gets deleted | 159 // system. Since render view host pointers may be reused (if one gets deleted |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 private: | 586 private: |
| 584 class BackendDelegate; | 587 class BackendDelegate; |
| 585 friend class base::RefCountedThreadSafe<HistoryService>; | 588 friend class base::RefCountedThreadSafe<HistoryService>; |
| 586 friend class BackendDelegate; | 589 friend class BackendDelegate; |
| 587 friend class FaviconService; | 590 friend class FaviconService; |
| 588 friend class history::HistoryBackend; | 591 friend class history::HistoryBackend; |
| 589 friend class history::HistoryQueryTest; | 592 friend class history::HistoryQueryTest; |
| 590 friend class HistoryOperation; | 593 friend class HistoryOperation; |
| 591 friend class HistoryURLProvider; | 594 friend class HistoryURLProvider; |
| 592 friend class HistoryURLProviderTest; | 595 friend class HistoryURLProviderTest; |
| 596 friend class history::InMemoryURLIndexTest; |
| 593 template<typename Info, typename Callback> friend class DownloadRequest; | 597 template<typename Info, typename Callback> friend class DownloadRequest; |
| 594 friend class PageUsageRequest; | 598 friend class PageUsageRequest; |
| 595 friend class RedirectRequest; | 599 friend class RedirectRequest; |
| 596 friend class TestingProfile; | 600 friend class TestingProfile; |
| 597 | 601 |
| 598 // Implementation of content::NotificationObserver. | 602 // Implementation of content::NotificationObserver. |
| 599 virtual void Observe(int type, | 603 virtual void Observe(int type, |
| 600 const content::NotificationSource& source, | 604 const content::NotificationSource& source, |
| 601 const content::NotificationDetails& details) OVERRIDE; | 605 const content::NotificationDetails& details) OVERRIDE; |
| 602 | 606 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 int current_backend_id_; | 862 int current_backend_id_; |
| 859 | 863 |
| 860 // Cached values from Init(), used whenever we need to reload the backend. | 864 // Cached values from Init(), used whenever we need to reload the backend. |
| 861 FilePath history_dir_; | 865 FilePath history_dir_; |
| 862 BookmarkService* bookmark_service_; | 866 BookmarkService* bookmark_service_; |
| 863 bool no_db_; | 867 bool no_db_; |
| 864 | 868 |
| 865 // True if needs top site migration. | 869 // True if needs top site migration. |
| 866 bool needs_top_sites_migration_; | 870 bool needs_top_sites_migration_; |
| 867 | 871 |
| 872 // The index used for quick history lookups. |
| 873 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; |
| 874 |
| 868 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 875 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
| 869 }; | 876 }; |
| 870 | 877 |
| 871 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ | 878 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ |
| OLD | NEW |