OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_HISTORY_CORE_BROWSER_URL_DATABASE_H_ | 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_URL_DATABASE_H_ |
6 #define COMPONENTS_HISTORY_CORE_BROWSER_URL_DATABASE_H_ | 6 #define COMPONENTS_HISTORY_CORE_BROWSER_URL_DATABASE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "components/history/core/browser/keyword_id.h" | 9 #include "components/history/core/browser/keyword_id.h" |
10 #include "components/history/core/browser/url_row.h" | 10 #include "components/history/core/browser/url_row.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 131 |
132 DISALLOW_COPY_AND_ASSIGN(URLEnumeratorBase); | 132 DISALLOW_COPY_AND_ASSIGN(URLEnumeratorBase); |
133 }; | 133 }; |
134 | 134 |
135 // A basic enumerator to enumerate urls | 135 // A basic enumerator to enumerate urls |
136 class URLEnumerator : public URLEnumeratorBase { | 136 class URLEnumerator : public URLEnumeratorBase { |
137 public: | 137 public: |
138 URLEnumerator(); | 138 URLEnumerator(); |
139 | 139 |
140 // Retreives the next url. Returns false if no more urls are available | 140 // Retreives the next url. Returns false if no more urls are available |
141 bool GetNextURL(history::URLRow* r); | 141 bool GetNextURL(URLRow* r); |
142 | 142 |
143 private: | 143 private: |
144 DISALLOW_COPY_AND_ASSIGN(URLEnumerator); | 144 DISALLOW_COPY_AND_ASSIGN(URLEnumerator); |
145 }; | 145 }; |
146 | 146 |
147 // Initializes the given enumerator to enumerator all URLs in the database. | 147 // Initializes the given enumerator to enumerator all URLs in the database. |
148 bool InitURLEnumeratorForEverything(URLEnumerator* enumerator); | 148 bool InitURLEnumeratorForEverything(URLEnumerator* enumerator); |
149 | 149 |
150 // Initializes the given enumerator to enumerator all URLs in the database | 150 // Initializes the given enumerator to enumerator all URLs in the database |
151 // that are historically significant: ones having been visited within 3 days, | 151 // that are historically significant: ones having been visited within 3 days, |
(...skipping 22 matching lines...) Expand all Loading... |
174 // Tries to find the shortest URL beginning with |base| that strictly | 174 // Tries to find the shortest URL beginning with |base| that strictly |
175 // prefixes |url|, and has minimum visit_ and typed_counts as specified. | 175 // prefixes |url|, and has minimum visit_ and typed_counts as specified. |
176 // If found, fills in |info| and returns true; otherwise returns false, | 176 // If found, fills in |info| and returns true; otherwise returns false, |
177 // leaving |info| unchanged. | 177 // leaving |info| unchanged. |
178 // We allow matches of exactly |base| iff |allow_base| is true. | 178 // We allow matches of exactly |base| iff |allow_base| is true. |
179 bool FindShortestURLFromBase(const std::string& base, | 179 bool FindShortestURLFromBase(const std::string& base, |
180 const std::string& url, | 180 const std::string& url, |
181 int min_visits, | 181 int min_visits, |
182 int min_typed, | 182 int min_typed, |
183 bool allow_base, | 183 bool allow_base, |
184 history::URLRow* info); | 184 URLRow* info); |
185 | 185 |
186 // History search ------------------------------------------------------------ | 186 // History search ------------------------------------------------------------ |
187 | 187 |
188 // Performs a brute force search over the database to find any URLs or titles | 188 // Performs a brute force search over the database to find any URLs or titles |
189 // which match the |query| string. Returns any matches in |results|. | 189 // which match the |query| string. Returns any matches in |results|. |
190 bool GetTextMatches(const base::string16& query, URLRows* results); | 190 bool GetTextMatches(const base::string16& query, URLRows* results); |
191 | 191 |
192 // Keyword Search Terms ------------------------------------------------------ | 192 // Keyword Search Terms ------------------------------------------------------ |
193 | 193 |
194 // Sets the search terms for the specified url/keyword pair. | 194 // Sets the search terms for the specified url/keyword pair. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 bool DropKeywordSearchTermsTable(); | 269 bool DropKeywordSearchTermsTable(); |
270 | 270 |
271 // Inserts the given URL row into the URLs table, using the regular table | 271 // Inserts the given URL row into the URLs table, using the regular table |
272 // if is_temporary is false, or the temporary URL table if is temporary is | 272 // if is_temporary is false, or the temporary URL table if is temporary is |
273 // true. The current |id| of |info| will be ignored in both cases and a new ID | 273 // true. The current |id| of |info| will be ignored in both cases and a new ID |
274 // will be generated, which will also constitute the return value, except in | 274 // will be generated, which will also constitute the return value, except in |
275 // case of an error, when the return value is 0. The temporary table may only | 275 // case of an error, when the return value is 0. The temporary table may only |
276 // be used in between CreateTemporaryURLTable() and CommitTemporaryURLTable(). | 276 // be used in between CreateTemporaryURLTable() and CommitTemporaryURLTable(). |
277 URLID AddURLInternal(const URLRow& info, bool is_temporary); | 277 URLID AddURLInternal(const URLRow& info, bool is_temporary); |
278 | 278 |
279 // Convenience to fill a history::URLRow. Must be in sync with the fields in | 279 // Convenience to fill a URLRow. Must be in sync with the fields in |
280 // kHistoryURLRowFields. | 280 // kHistoryURLRowFields. |
281 static void FillURLRow(sql::Statement& s, URLRow* i); | 281 static void FillURLRow(sql::Statement& s, URLRow* i); |
282 | 282 |
283 // Returns the database for the functions in this interface. The decendent of | 283 // Returns the database for the functions in this interface. The decendent of |
284 // this class implements these functions to return its objects. | 284 // this class implements these functions to return its objects. |
285 virtual sql::Connection& GetDB() = 0; | 285 virtual sql::Connection& GetDB() = 0; |
286 | 286 |
287 private: | 287 private: |
288 // True if InitKeywordSearchTermsTable() has been invoked. Not all subclasses | 288 // True if InitKeywordSearchTermsTable() has been invoked. Not all subclasses |
289 // have keyword search terms. | 289 // have keyword search terms. |
(...skipping 29 matching lines...) Expand all Loading... |
319 // is_null() then this function determines a new time threshold each time it is | 319 // is_null() then this function determines a new time threshold each time it is |
320 // called. Since getting system time can be costly (such as for cases where | 320 // called. Since getting system time can be costly (such as for cases where |
321 // this function will be called in a loop over many history items), you can | 321 // this function will be called in a loop over many history items), you can |
322 // provide a non-null |time_cache| by simply initializing |time_cache| with | 322 // provide a non-null |time_cache| by simply initializing |time_cache| with |
323 // AutocompleteAgeThreshold() (or any other desired time in the past). | 323 // AutocompleteAgeThreshold() (or any other desired time in the past). |
324 bool RowQualifiesAsSignificant(const URLRow& row, const base::Time& threshold); | 324 bool RowQualifiesAsSignificant(const URLRow& row, const base::Time& threshold); |
325 | 325 |
326 } // namespace history | 326 } // namespace history |
327 | 327 |
328 #endif // COMPONENTS_HISTORY_CORE_BROWSER_URL_DATABASE_H_ | 328 #endif // COMPONENTS_HISTORY_CORE_BROWSER_URL_DATABASE_H_ |
OLD | NEW |