Chromium Code Reviews| 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_IN_MEMORY_URL_INDEX_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_IN_MEMORY_URL_INDEX_H_ |
| 6 #define CHROME_BROWSER_HISTORY_IN_MEMORY_URL_INDEX_H_ | 6 #define CHROME_BROWSER_HISTORY_IN_MEMORY_URL_INDEX_H_ |
| 7 | 7 |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
| 20 #include "base/task/cancelable_task_tracker.h" | 20 #include "base/task/cancelable_task_tracker.h" |
| 21 #include "chrome/browser/history/history_db_task.h" | 21 #include "chrome/browser/history/history_db_task.h" |
| 22 #include "chrome/browser/history/history_types.h" | 22 #include "chrome/browser/history/history_types.h" |
| 23 #include "chrome/browser/history/in_memory_url_index_types.h" | 23 #include "chrome/browser/history/in_memory_url_index_types.h" |
| 24 #include "chrome/browser/history/scored_history_match.h" | 24 #include "chrome/browser/history/scored_history_match.h" |
| 25 #include "components/history/core/browser/history_service_observer.h" | |
| 25 #include "content/public/browser/notification_observer.h" | 26 #include "content/public/browser/notification_observer.h" |
| 26 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
| 27 #include "sql/connection.h" | 28 #include "sql/connection.h" |
| 28 | 29 |
| 29 class HistoryQuickProviderTest; | 30 class HistoryQuickProviderTest; |
| 31 class HistoryService; | |
| 30 class Profile; | 32 class Profile; |
| 31 | 33 |
| 32 namespace base { | 34 namespace base { |
| 33 class Time; | 35 class Time; |
| 34 } | 36 } |
| 35 | 37 |
| 36 namespace in_memory_url_index { | 38 namespace in_memory_url_index { |
| 37 class InMemoryURLIndexCacheItem; | 39 class InMemoryURLIndexCacheItem; |
| 38 } | 40 } |
| 39 | 41 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 61 // URL strings to lowercase. Multi-byte-edness makes no difference when | 63 // URL strings to lowercase. Multi-byte-edness makes no difference when |
| 62 // indexing or when searching the index as the final filtering of results | 64 // indexing or when searching the index as the final filtering of results |
| 63 // is dependent on the comparison of a string of bytes, not individual | 65 // is dependent on the comparison of a string of bytes, not individual |
| 64 // characters. While the lookup of those bytes during a search in the | 66 // characters. While the lookup of those bytes during a search in the |
| 65 // |char_word_map_| could serve up words in which the individual char16 | 67 // |char_word_map_| could serve up words in which the individual char16 |
| 66 // occurs as a portion of a composite character the next filtering step | 68 // occurs as a portion of a composite character the next filtering step |
| 67 // will eliminate such words except in the case where a single character | 69 // will eliminate such words except in the case where a single character |
| 68 // is being searched on and which character occurs as the second char16 of a | 70 // is being searched on and which character occurs as the second char16 of a |
| 69 // multi-char16 instance. | 71 // multi-char16 instance. |
| 70 class InMemoryURLIndex : public content::NotificationObserver, | 72 class InMemoryURLIndex : public content::NotificationObserver, |
| 71 public base::SupportsWeakPtr<InMemoryURLIndex> { | 73 public base::SupportsWeakPtr<InMemoryURLIndex>, |
| 74 public history::HistoryServiceObserver { | |
| 72 public: | 75 public: |
| 73 // Defines an abstract class which is notified upon completion of restoring | 76 // Defines an abstract class which is notified upon completion of restoring |
| 74 // the index's private data either by reading from the cache file or by | 77 // the index's private data either by reading from the cache file or by |
| 75 // rebuilding from the history database. | 78 // rebuilding from the history database. |
| 76 class RestoreCacheObserver { | 79 class RestoreCacheObserver { |
| 77 public: | 80 public: |
| 78 virtual ~RestoreCacheObserver(); | 81 virtual ~RestoreCacheObserver(); |
| 79 | 82 |
| 80 // Callback that lets the observer know that the restore operation has | 83 // Callback that lets the observer know that the restore operation has |
| 81 // completed. |succeeded| indicates if the restore was successful. This is | 84 // completed. |succeeded| indicates if the restore was successful. This is |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 } | 139 } |
| 137 void set_save_cache_observer(SaveCacheObserver* save_cache_observer) { | 140 void set_save_cache_observer(SaveCacheObserver* save_cache_observer) { |
| 138 save_cache_observer_ = save_cache_observer; | 141 save_cache_observer_ = save_cache_observer; |
| 139 } | 142 } |
| 140 | 143 |
| 141 // Indicates that the index restoration is complete. | 144 // Indicates that the index restoration is complete. |
| 142 bool restored() const { | 145 bool restored() const { |
| 143 return restored_; | 146 return restored_; |
| 144 } | 147 } |
| 145 | 148 |
| 149 // Is called when |service| is loaded. | |
|
sdefresne
2014/09/23 08:45:09
When overriding methods from an interface, you don
nshaik
2014/10/29 08:43:39
Done.
| |
| 150 virtual void HistoryServiceLoaded(HistoryService* service) OVERRIDE; | |
|
sdefresne
2014/10/20 13:15:42
OVERRIDE -> override
| |
| 151 | |
| 146 private: | 152 private: |
| 147 friend class ::HistoryQuickProviderTest; | 153 friend class ::HistoryQuickProviderTest; |
| 148 friend class InMemoryURLIndexTest; | 154 friend class InMemoryURLIndexTest; |
| 149 friend class InMemoryURLIndexCacheTest; | 155 friend class InMemoryURLIndexCacheTest; |
| 150 FRIEND_TEST_ALL_PREFIXES(LimitedInMemoryURLIndexTest, Initialization); | 156 FRIEND_TEST_ALL_PREFIXES(LimitedInMemoryURLIndexTest, Initialization); |
| 151 | 157 |
| 152 // Creating one of me without a history path is not allowed (tests excepted). | 158 // Creating one of me without a history path is not allowed (tests excepted). |
| 153 InMemoryURLIndex(); | 159 InMemoryURLIndex(); |
| 154 | 160 |
| 155 // HistoryDBTask used to rebuild our private data from the history database. | 161 // HistoryDBTask used to rebuild our private data from the history database. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 // temporary safety check to insure that the cache is saved before the | 304 // temporary safety check to insure that the cache is saved before the |
| 299 // index has been destructed. | 305 // index has been destructed. |
| 300 bool needs_to_be_cached_; | 306 bool needs_to_be_cached_; |
| 301 | 307 |
| 302 DISALLOW_COPY_AND_ASSIGN(InMemoryURLIndex); | 308 DISALLOW_COPY_AND_ASSIGN(InMemoryURLIndex); |
| 303 }; | 309 }; |
| 304 | 310 |
| 305 } // namespace history | 311 } // namespace history |
| 306 | 312 |
| 307 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_URL_INDEX_H_ | 313 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_URL_INDEX_H_ |
| OLD | NEW |