Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "chrome/browser/history/url_database.h" | 5 #include "chrome/browser/history/url_database.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 if (!enumerator->statement_) { | 254 if (!enumerator->statement_) { |
| 255 NOTREACHED() << GetDB().GetErrorMessage(); | 255 NOTREACHED() << GetDB().GetErrorMessage(); |
| 256 return false; | 256 return false; |
| 257 } | 257 } |
| 258 enumerator->initialized_ = true; | 258 enumerator->initialized_ = true; |
| 259 return true; | 259 return true; |
| 260 } | 260 } |
| 261 | 261 |
| 262 bool URLDatabase::InitURLEnumeratorForSignificant(URLEnumerator* enumerator) { | 262 bool URLDatabase::InitURLEnumeratorForSignificant(URLEnumerator* enumerator) { |
| 263 DCHECK(!enumerator->initialized_); | 263 DCHECK(!enumerator->initialized_); |
| 264 sql::Connection& db(GetDB()); | |
| 265 if (!db.is_open()) | |
| 266 return false; | |
|
Peter Kasting
2012/01/14 00:12:49
We access GetDB() directly a lot in the rest of th
mrossetti
2012/03/03 05:05:56
Done.
| |
| 264 std::string sql("SELECT "); | 267 std::string sql("SELECT "); |
| 265 sql.append(kURLRowFields); | 268 sql.append(kURLRowFields); |
| 266 sql.append(" FROM urls WHERE last_visit_time >= ? OR visit_count >= ? OR " | 269 sql.append(" FROM urls WHERE last_visit_time >= ? OR visit_count >= ? OR " |
| 267 "typed_count >= ?"); | 270 "typed_count >= ?"); |
| 268 enumerator->statement_.Assign(GetDB().GetUniqueStatement(sql.c_str())); | 271 enumerator->statement_.Assign(db.GetUniqueStatement(sql.c_str())); |
| 269 if (!enumerator->statement_) { | 272 if (!enumerator->statement_) { |
| 270 NOTREACHED() << GetDB().GetErrorMessage(); | 273 NOTREACHED() << db.GetErrorMessage(); |
| 271 return false; | 274 return false; |
| 272 } | 275 } |
| 273 enumerator->statement_.BindInt64( | 276 enumerator->statement_.BindInt64( |
| 274 0, AutocompleteAgeThreshold().ToInternalValue()); | 277 0, AutocompleteAgeThreshold().ToInternalValue()); |
| 275 enumerator->statement_.BindInt(1, kLowQualityMatchVisitLimit); | 278 enumerator->statement_.BindInt(1, kLowQualityMatchVisitLimit); |
| 276 enumerator->statement_.BindInt(2, kLowQualityMatchTypedLimit); | 279 enumerator->statement_.BindInt(2, kLowQualityMatchTypedLimit); |
| 277 enumerator->initialized_ = true; | 280 enumerator->initialized_ = true; |
| 278 return true; | 281 return true; |
| 279 } | 282 } |
| 280 | 283 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 576 return GetDB().Execute(sql.c_str()); | 579 return GetDB().Execute(sql.c_str()); |
| 577 } | 580 } |
| 578 | 581 |
| 579 bool URLDatabase::CreateMainURLIndex() { | 582 bool URLDatabase::CreateMainURLIndex() { |
| 580 // Index over URLs so we can quickly look up based on URL. | 583 // Index over URLs so we can quickly look up based on URL. |
| 581 return GetDB().Execute( | 584 return GetDB().Execute( |
| 582 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)"); | 585 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)"); |
| 583 } | 586 } |
| 584 | 587 |
| 585 } // namespace history | 588 } // namespace history |
| OLD | NEW |