OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/meta_table_helper.h" | 5 #include "chrome/browser/meta_table_helper.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/common/sqlite_utils.h" | 9 #include "chrome/common/sqlite_utils.h" |
10 | 10 |
11 // Key used in our meta table for version numbers. | 11 // Key used in our meta table for version numbers. |
12 static const char kVersionKey[] = "version"; | 12 static const char kVersionKey[] = "version"; |
13 static const char kCompatibleVersionKey[] = "last_compatible_version"; | 13 static const char kCompatibleVersionKey[] = "last_compatible_version"; |
14 | 14 |
15 // static | 15 // static |
16 void MetaTableHelper::PrimeCache(const std::string& db_name, sqlite3* db) { | 16 void MetaTableHelper::PrimeCache(const std::string& db_name, sqlite3* db) { |
17 // A statement must be open for the preload command to work. If the meta | 17 // A statement must be open for the preload command to work. If the meta |
18 // table doesn't exist, it probably means this is a new database and there | 18 // table doesn't exist, it probably means this is a new database and there |
19 // is nothing to preload (so it's OK we do nothing). | 19 // is nothing to preload (so it's OK we do nothing). |
20 SQLStatement dummy; | 20 SQLStatement dummy; |
21 if (!DoesSqliteTableExist(db, db_name.c_str(), "meta")) | 21 if (!DoesSqliteTableExist(db, db_name.c_str(), "meta")) |
22 return; | 22 return; |
23 std::string sql("SELECT * from "); | 23 std::string sql("SELECT * from "); |
24 appendMetaTableName(db_name, &sql); | 24 appendMetaTableName(db_name, &sql); |
25 if (dummy.prepare(db, sql.c_str()) != SQLITE_OK) | 25 if (dummy.prepare(db, sql.c_str()) != SQLITE_OK) |
26 return; | 26 return; |
27 if (dummy.step() != SQLITE_ROW) | 27 if (dummy.step() != SQLITE_ROW) |
28 return; | 28 return; |
29 | 29 |
30 sqlite3Preload(db); | 30 // TODO(jar): Temporary removal of the following optimization... be sure to |
| 31 // put it back in RSN (if we verify that it was not causing crashes). |
| 32 // sqlite3Preload(db); |
31 } | 33 } |
32 | 34 |
33 MetaTableHelper::MetaTableHelper() : db_(NULL) { | 35 MetaTableHelper::MetaTableHelper() : db_(NULL) { |
34 } | 36 } |
35 | 37 |
36 MetaTableHelper::~MetaTableHelper() { | 38 MetaTableHelper::~MetaTableHelper() { |
37 } | 39 } |
38 | 40 |
39 bool MetaTableHelper::Init(const std::string& db_name, | 41 bool MetaTableHelper::Init(const std::string& db_name, |
40 int version, | 42 int version, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 sql.append(" WHERE key = ?"); | 178 sql.append(" WHERE key = ?"); |
177 if (statement->prepare(db_, sql.c_str()) != SQLITE_OK) { | 179 if (statement->prepare(db_, sql.c_str()) != SQLITE_OK) { |
178 NOTREACHED() << sqlite3_errmsg(db_); | 180 NOTREACHED() << sqlite3_errmsg(db_); |
179 return false; | 181 return false; |
180 } | 182 } |
181 statement->bind_string(0, key); | 183 statement->bind_string(0, key); |
182 if (statement->step() != SQLITE_ROW) | 184 if (statement->step() != SQLITE_ROW) |
183 return false; | 185 return false; |
184 return true; | 186 return true; |
185 } | 187 } |
OLD | NEW |