| 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_URL_DATABASE_H_ | 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_URL_DATABASE_H_ |
| 6 #define CHROME_BROWSER_HISTORY_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 "chrome/browser/history/history_types.h" | |
| 10 #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" |
| 11 #include "components/query_parser/query_parser.h" | 11 #include "components/query_parser/query_parser.h" |
| 12 #include "sql/statement.h" | 12 #include "sql/statement.h" |
| 13 | 13 |
| 14 class GURL; | 14 class GURL; |
| 15 | 15 |
| 16 namespace sql { | 16 namespace sql { |
| 17 class Connection; | 17 class Connection; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace history { | 20 namespace history { |
| 21 | 21 |
| 22 struct KeywordSearchTermRow; |
| 23 struct KeywordSearchTermVisit; |
| 22 class VisitDatabase; // For friend statement. | 24 class VisitDatabase; // For friend statement. |
| 23 | 25 |
| 24 // Encapsulates an SQL database that holds URL info. This is a subset of the | 26 // Encapsulates an SQL database that holds URL info. This is a subset of the |
| 25 // full history data. We split this class' functionality out from the larger | 27 // full history data. We split this class' functionality out from the larger |
| 26 // HistoryDatabase class to support maintaining separate databases of URLs with | 28 // HistoryDatabase class to support maintaining separate databases of URLs with |
| 27 // different capabilities (for example, the in-memory database). | 29 // different capabilities (for example, the in-memory database). |
| 28 // | 30 // |
| 29 // This is refcounted to support calling InvokeLater() with some of its methods | 31 // This is refcounted to support calling InvokeLater() with some of its methods |
| 30 // (necessary to maintain ordering of DB operations). | 32 // (necessary to maintain ordering of DB operations). |
| 31 class URLDatabase { | 33 class URLDatabase { |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // so that DISTINCT can be prepended to get distinct URLs. | 298 // so that DISTINCT can be prepended to get distinct URLs. |
| 297 // | 299 // |
| 298 // This is available BOTH as a macro and a static string (kURLRowFields). Use | 300 // This is available BOTH as a macro and a static string (kURLRowFields). Use |
| 299 // the macro if you want to put this in the middle of an otherwise constant | 301 // the macro if you want to put this in the middle of an otherwise constant |
| 300 // string, it will save time doing string appends. If you have to build a SQL | 302 // string, it will save time doing string appends. If you have to build a SQL |
| 301 // string dynamically anyway, use the constant, it will save space. | 303 // string dynamically anyway, use the constant, it will save space. |
| 302 #define HISTORY_URL_ROW_FIELDS \ | 304 #define HISTORY_URL_ROW_FIELDS \ |
| 303 " urls.id, urls.url, urls.title, urls.visit_count, urls.typed_count, " \ | 305 " urls.id, urls.url, urls.title, urls.visit_count, urls.typed_count, " \ |
| 304 "urls.last_visit_time, urls.hidden " | 306 "urls.last_visit_time, urls.hidden " |
| 305 | 307 |
| 308 // Constants which specify, when considered altogether, 'significant' |
| 309 // history items. These are used to filter out insignificant items |
| 310 // for consideration as autocomplete candidates. |
| 311 extern const int kLowQualityMatchTypedLimit; |
| 312 extern const int kLowQualityMatchVisitLimit; |
| 313 extern const int kLowQualityMatchAgeLimitInDays; |
| 314 |
| 315 // Returns the date threshold for considering an history item as significant. |
| 316 base::Time AutocompleteAgeThreshold(); |
| 317 |
| 318 // Return true if |row| qualifies as an autocomplete candidate. If |time_cache| |
| 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 |
| 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 |
| 323 // AutocompleteAgeThreshold() (or any other desired time in the past). |
| 324 bool RowQualifiesAsSignificant(const URLRow& row, const base::Time& threshold); |
| 325 |
| 306 } // namespace history | 326 } // namespace history |
| 307 | 327 |
| 308 #endif // CHROME_BROWSER_HISTORY_URL_DATABASE_H_ | 328 #endif // COMPONENTS_HISTORY_CORE_BROWSER_URL_DATABASE_H_ |
| OLD | NEW |