| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/sql/transaction.h" | 5 #include "app/sql/transaction.h" |
| 6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
| 7 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" | 7 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" |
| 8 #include "chrome/browser/history/top_sites.h" | 8 #include "chrome/browser/history/top_sites.h" |
| 9 #include "chrome/browser/history/top_sites_database.h" | 9 #include "chrome/browser/history/top_sites_database.h" |
| 10 | 10 |
| 11 namespace history { | 11 namespace history { |
| 12 | 12 |
| 13 TopSitesDatabaseImpl::TopSitesDatabaseImpl() { | 13 TopSitesDatabaseImpl::TopSitesDatabaseImpl() { |
| 14 } | 14 } |
| 15 | 15 |
| 16 bool TopSitesDatabaseImpl::Init(const FilePath& db_name) { | 16 bool TopSitesDatabaseImpl::Init(const FilePath& db_name) { |
| 17 // Settings copied from ThumbnailDatabase. | 17 // Settings copied from ThumbnailDatabase. |
| 18 db_.set_error_delegate(GetErrorHandlerForThumbnailDb()); | 18 db_.set_error_delegate(GetErrorHandlerForThumbnailDb()); |
| 19 db_.set_page_size(4096); | 19 db_.set_page_size(4096); |
| 20 db_.set_cache_size(64); | 20 db_.set_cache_size(64); |
| 21 | 21 |
| 22 if (!db_.Open(db_name)) { | 22 if (!db_.Open(db_name)) { |
| 23 LOG(WARNING) << db_.GetErrorMessage(); | 23 LOG(WARNING) << db_.GetErrorMessage(); |
| 24 return sql::INIT_FAILURE; | 24 return false; |
| 25 } | 25 } |
| 26 | 26 |
| 27 return InitThumbnailTable(); | 27 return InitThumbnailTable(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 bool TopSitesDatabaseImpl::InitThumbnailTable() { | 30 bool TopSitesDatabaseImpl::InitThumbnailTable() { |
| 31 if (!db_.DoesTableExist("thumbnails")) { | 31 if (!db_.DoesTableExist("thumbnails")) { |
| 32 if (!db_.Execute("CREATE TABLE thumbnails (" | 32 if (!db_.Execute("CREATE TABLE thumbnails (" |
| 33 "url LONGVARCHAR PRIMARY KEY," | 33 "url LONGVARCHAR PRIMARY KEY," |
| 34 "url_rank INTEGER ," | 34 "url_rank INTEGER ," |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 "DELETE FROM thumbnails WHERE url = ?")); | 240 "DELETE FROM thumbnails WHERE url = ?")); |
| 241 if (!delete_statement) | 241 if (!delete_statement) |
| 242 return false; | 242 return false; |
| 243 delete_statement.BindString(0, url.url.spec()); | 243 delete_statement.BindString(0, url.url.spec()); |
| 244 delete_statement.Run(); | 244 delete_statement.Run(); |
| 245 | 245 |
| 246 return transaction.Commit(); | 246 return transaction.Commit(); |
| 247 } | 247 } |
| 248 | 248 |
| 249 } // namespace history | 249 } // namespace history |
| 250 | |
| OLD | NEW |