Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Side by Side Diff: chrome/browser/history/in_memory_history_backend.h

Issue 9316109: Move Ownership of IMUI to HistoryService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Contains the history backend wrapper around the in-memory URL database. This 5 // Contains the history backend wrapper around the in-memory URL database. This
6 // object maintains an in-memory cache of the subset of history required to do 6 // object maintains an in-memory cache of the subset of history required to do
7 // in-line autocomplete. 7 // in-line autocomplete.
8 // 8 //
9 // It is created on the history thread and passed to the main thread where 9 // It is created on the history thread and passed to the main thread where
10 // operations can be completed synchronously. It listens for notifications 10 // operations can be completed synchronously. It listens for notifications
(...skipping 23 matching lines...) Expand all
34 class URLDatabase; 34 class URLDatabase;
35 struct URLsDeletedDetails; 35 struct URLsDeletedDetails;
36 struct URLsModifiedDetails; 36 struct URLsModifiedDetails;
37 37
38 class InMemoryHistoryBackend : public content::NotificationObserver { 38 class InMemoryHistoryBackend : public content::NotificationObserver {
39 public: 39 public:
40 InMemoryHistoryBackend(); 40 InMemoryHistoryBackend();
41 virtual ~InMemoryHistoryBackend(); 41 virtual ~InMemoryHistoryBackend();
42 42
43 // Initializes the backend from the history database pointed to by the 43 // Initializes the backend from the history database pointed to by the
44 // full path in |history_filename|. |history_dir| is the path to the 44 // full path in |history_filename|. |db| is used for setting up the
45 // directory containing the history database and is also used 45 // InMemoryDatabase.
46 // as the directory where the InMemoryURLIndex's cache is kept. |db| is
47 // used for building the InMemoryURLIndex. |languages| gives the
48 // preferred user languages with which URLs and page titles are
49 // interpreted while decomposing into words and characters during indexing.
50 bool Init(const FilePath& history_filename, 46 bool Init(const FilePath& history_filename,
51 const FilePath& history_dir, 47 URLDatabase* db);
Peter Kasting 2012/02/04 02:20:31 Nit: Can probably fit on previous line?
mrossetti 2012/02/04 04:30:53 Done.
52 URLDatabase* db,
53 const std::string& languages);
54 48
55 // Does initialization work when this object is attached to the history 49 // Does initialization work when this object is attached to the history
56 // system on the main thread. The argument is the profile with which the 50 // system on the main thread. The argument is the profile with which the
57 // attached history service is under. 51 // attached history service is under.
58 void AttachToHistoryService(Profile* profile); 52 void AttachToHistoryService(Profile* profile);
59 53
60 // Returns the underlying database associated with this backend. The current 54 // Returns the underlying database associated with this backend. The current
61 // autocomplete code was written fro this, but it should probably be removed 55 // autocomplete code was written fro this, but it should probably be removed
62 // so that it can deal directly with this object, rather than the DB. 56 // so that it can deal directly with this object, rather than the DB.
63 InMemoryDatabase* db() const { 57 InMemoryDatabase* db() const {
64 return db_.get(); 58 return db_.get();
65 } 59 }
66 60
67 // Notification callback. 61 // Notification callback.
68 virtual void Observe(int type, 62 virtual void Observe(int type,
69 const content::NotificationSource& source, 63 const content::NotificationSource& source,
70 const content::NotificationDetails& details) OVERRIDE; 64 const content::NotificationDetails& details) OVERRIDE;
71 65
72 // Return the quick history index.
73 history::InMemoryURLIndex* InMemoryIndex() const { return index_.get(); }
74
75 private: 66 private:
76 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll); 67 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll);
77 68
78 // Handler for NOTIFY_HISTORY_TYPED_URLS_MODIFIED. 69 // Handler for NOTIFY_HISTORY_TYPED_URLS_MODIFIED.
79 void OnTypedURLsModified(const URLsModifiedDetails& details); 70 void OnTypedURLsModified(const URLsModifiedDetails& details);
80 71
81 // Handler for NOTIFY_HISTORY_URLS_DELETED. 72 // Handler for NOTIFY_HISTORY_URLS_DELETED.
82 void OnURLsDeleted(const URLsDeletedDetails& details); 73 void OnURLsDeleted(const URLsDeletedDetails& details);
83 74
84 // Handler for HISTORY_KEYWORD_SEARCH_TERM_UPDATED. 75 // Handler for HISTORY_KEYWORD_SEARCH_TERM_UPDATED.
85 void OnKeywordSearchTermUpdated(const KeywordSearchTermDetails& details); 76 void OnKeywordSearchTermUpdated(const KeywordSearchTermDetails& details);
86 77
87 // Returns true if there is a keyword associated with the specified url. 78 // Returns true if there is a keyword associated with the specified url.
88 bool HasKeyword(const GURL& url); 79 bool HasKeyword(const GURL& url);
89 80
90 content::NotificationRegistrar registrar_; 81 content::NotificationRegistrar registrar_;
91 82
92 scoped_ptr<InMemoryDatabase> db_; 83 scoped_ptr<InMemoryDatabase> db_;
93 84
94 // The profile that this object is attached. May be NULL before 85 // The profile that this object is attached. May be NULL before
95 // initialization. 86 // initialization.
96 Profile* profile_; 87 Profile* profile_;
97 88
98 // The index used for quick history lookups.
99 scoped_ptr<history::InMemoryURLIndex> index_;
100
101 DISALLOW_COPY_AND_ASSIGN(InMemoryHistoryBackend); 89 DISALLOW_COPY_AND_ASSIGN(InMemoryHistoryBackend);
102 }; 90 };
103 91
104 } // namespace history 92 } // namespace history
105 93
106 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_ 94 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698