OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_TEXT_DATABASE_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_TEXT_DATABASE_MANAGER_H_ |
6 #define CHROME_BROWSER_HISTORY_TEXT_DATABASE_MANAGER_H_ | 6 #define CHROME_BROWSER_HISTORY_TEXT_DATABASE_MANAGER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // automatically coalesced and added to the database some time in the future | 94 // automatically coalesced and added to the database some time in the future |
95 // using AddPageData(). | 95 // using AddPageData(). |
96 // | 96 // |
97 // AddPageURL must be called for a given URL (+ its corresponding ID) before | 97 // AddPageURL must be called for a given URL (+ its corresponding ID) before |
98 // either the title or body set. The visit ID specifies the visit that will | 98 // either the title or body set. The visit ID specifies the visit that will |
99 // get updated to refer to the full text indexed information. The visit time | 99 // get updated to refer to the full text indexed information. The visit time |
100 // should be the time corresponding to that visit in the database. | 100 // should be the time corresponding to that visit in the database. |
101 void AddPageURL(const GURL& url, URLID url_id, VisitID visit_id, | 101 void AddPageURL(const GURL& url, URLID url_id, VisitID visit_id, |
102 base::Time visit_time); | 102 base::Time visit_time); |
103 void AddPageTitle(const GURL& url, const std::wstring& title); | 103 void AddPageTitle(const GURL& url, const std::wstring& title); |
104 void AddPageContents(const GURL& url, const std::wstring& body); | 104 void AddPageContents(const GURL& url, const string16& body); |
105 | 105 |
106 // Adds the given data to the appropriate database file, returning true on | 106 // Adds the given data to the appropriate database file, returning true on |
107 // success. The visit database row identified by |visit_id| will be updated | 107 // success. The visit database row identified by |visit_id| will be updated |
108 // to refer to the full text index entry. If the visit ID is 0, the visit | 108 // to refer to the full text index entry. If the visit ID is 0, the visit |
109 // database will not be updated. | 109 // database will not be updated. |
110 bool AddPageData(const GURL& url, | 110 bool AddPageData(const GURL& url, |
111 URLID url_id, | 111 URLID url_id, |
112 VisitID visit_id, | 112 VisitID visit_id, |
113 base::Time visit_time, | 113 base::Time visit_time, |
114 const std::wstring& title, | 114 const std::wstring& title, |
115 const std::wstring& body); | 115 const string16& body); |
116 | 116 |
117 // Deletes the instance of indexed data identified by the given time and URL. | 117 // Deletes the instance of indexed data identified by the given time and URL. |
118 // Any changes will be tracked in the optional change set for use when calling | 118 // Any changes will be tracked in the optional change set for use when calling |
119 // OptimizeChangedDatabases later. change_set can be NULL. | 119 // OptimizeChangedDatabases later. change_set can be NULL. |
120 void DeletePageData(base::Time time, const GURL& url, | 120 void DeletePageData(base::Time time, const GURL& url, |
121 ChangeSet* change_set); | 121 ChangeSet* change_set); |
122 | 122 |
123 // The text database manager keeps a list of changes that are made to the | 123 // The text database manager keeps a list of changes that are made to the |
124 // file AddPageURL/Title/Body that may not be committed to the database yet. | 124 // file AddPageURL/Title/Body that may not be committed to the database yet. |
125 // This function removes entires from this list happening between the given | 125 // This function removes entires from this list happening between the given |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // visit, title, and body all come in at different times. | 167 // visit, title, and body all come in at different times. |
168 class PageInfo { | 168 class PageInfo { |
169 public: | 169 public: |
170 PageInfo(URLID url_id, VisitID visit_id, base::Time visit_time); | 170 PageInfo(URLID url_id, VisitID visit_id, base::Time visit_time); |
171 | 171 |
172 // Getters. | 172 // Getters. |
173 URLID url_id() const { return url_id_; } | 173 URLID url_id() const { return url_id_; } |
174 VisitID visit_id() const { return visit_id_; } | 174 VisitID visit_id() const { return visit_id_; } |
175 base::Time visit_time() const { return visit_time_; } | 175 base::Time visit_time() const { return visit_time_; } |
176 const std::wstring& title() const { return title_; } | 176 const std::wstring& title() const { return title_; } |
177 const std::wstring& body() const { return body_; } | 177 const string16& body() const { return body_; } |
178 | 178 |
179 // Setters, we can only update the title and body. | 179 // Setters, we can only update the title and body. |
180 void set_title(const std::wstring& ttl); | 180 void set_title(const std::wstring& ttl); |
181 void set_body(const std::wstring& bdy); | 181 void set_body(const string16& bdy); |
182 | 182 |
183 // Returns true if both the title or body of the entry has been set. Since | 183 // Returns true if both the title or body of the entry has been set. Since |
184 // both the title and body setters will "fix" empty strings to be a space, | 184 // both the title and body setters will "fix" empty strings to be a space, |
185 // these indicate if the setter was ever called. | 185 // these indicate if the setter was ever called. |
186 bool has_title() const { return !title_.empty(); } | 186 bool has_title() const { return !title_.empty(); } |
187 bool has_body() { return !body_.empty(); } | 187 bool has_body() { return !body_.empty(); } |
188 | 188 |
189 // Returns true if this entry was added too long ago and we should give up | 189 // Returns true if this entry was added too long ago and we should give up |
190 // waiting for more data. The current time is passed in as an argument so we | 190 // waiting for more data. The current time is passed in as an argument so we |
191 // can check many without re-querying the timer. | 191 // can check many without re-querying the timer. |
192 bool Expired(base::TimeTicks now) const; | 192 bool Expired(base::TimeTicks now) const; |
193 | 193 |
194 private: | 194 private: |
195 URLID url_id_; | 195 URLID url_id_; |
196 VisitID visit_id_; | 196 VisitID visit_id_; |
197 | 197 |
198 // Time of the visit of the URL. This will be the value stored in the URL | 198 // Time of the visit of the URL. This will be the value stored in the URL |
199 // and visit tables for the entry. | 199 // and visit tables for the entry. |
200 base::Time visit_time_; | 200 base::Time visit_time_; |
201 | 201 |
202 // When this page entry was created. We have a cap on the maximum time that | 202 // When this page entry was created. We have a cap on the maximum time that |
203 // an entry will be in the queue before being flushed to the database. | 203 // an entry will be in the queue before being flushed to the database. |
204 base::TimeTicks added_time_; | 204 base::TimeTicks added_time_; |
205 | 205 |
206 // Will be the string " " when they are set to distinguish set and unset. | 206 // Will be the string " " when they are set to distinguish set and unset. |
207 std::wstring title_; | 207 std::wstring title_; |
208 std::wstring body_; | 208 string16 body_; |
209 }; | 209 }; |
210 | 210 |
211 // Converts the given time to a database identifier or vice-versa. | 211 // Converts the given time to a database identifier or vice-versa. |
212 static TextDatabase::DBIdent TimeToID(base::Time time); | 212 static TextDatabase::DBIdent TimeToID(base::Time time); |
213 static base::Time IDToTime(TextDatabase::DBIdent id); | 213 static base::Time IDToTime(TextDatabase::DBIdent id); |
214 | 214 |
215 // Returns a text database for the given identifier or time. This file will | 215 // Returns a text database for the given identifier or time. This file will |
216 // be created if it doesn't exist and |for_writing| is set. On error, | 216 // be created if it doesn't exist and |for_writing| is set. On error, |
217 // including the case where the file doesn't exist and |for_writing| | 217 // including the case where the file doesn't exist and |for_writing| |
218 // is false, it will return NULL. | 218 // is false, it will return NULL. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 // This can be NULL if there are no indexers registered to receive indexing | 298 // This can be NULL if there are no indexers registered to receive indexing |
299 // data from us. | 299 // data from us. |
300 const HistoryPublisher* history_publisher_; | 300 const HistoryPublisher* history_publisher_; |
301 | 301 |
302 DISALLOW_COPY_AND_ASSIGN(TextDatabaseManager); | 302 DISALLOW_COPY_AND_ASSIGN(TextDatabaseManager); |
303 }; | 303 }; |
304 | 304 |
305 } // namespace history | 305 } // namespace history |
306 | 306 |
307 #endif // CHROME_BROWSER_HISTORY_TEXT_DATABASE_MANAGER_H_ | 307 #endif // CHROME_BROWSER_HISTORY_TEXT_DATABASE_MANAGER_H_ |
OLD | NEW |