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 #include "sql/meta_table.h" | 5 #include "sql/meta_table.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "sql/connection.h" | 10 #include "sql/connection.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 return s.Run(); | 173 return s.Run(); |
174 } | 174 } |
175 | 175 |
176 bool MetaTable::SetValue(const char* key, int value) { | 176 bool MetaTable::SetValue(const char* key, int value) { |
177 Statement s; | 177 Statement s; |
178 PrepareSetStatement(&s, key); | 178 PrepareSetStatement(&s, key); |
179 s.BindInt(1, value); | 179 s.BindInt(1, value); |
180 return s.Run(); | 180 return s.Run(); |
181 } | 181 } |
182 | 182 |
183 bool MetaTable::SetValue(const char* key, int64 value) { | 183 bool MetaTable::SetValue(const char* key, int64_t value) { |
184 Statement s; | 184 Statement s; |
185 PrepareSetStatement(&s, key); | 185 PrepareSetStatement(&s, key); |
186 s.BindInt64(1, value); | 186 s.BindInt64(1, value); |
187 return s.Run(); | 187 return s.Run(); |
188 } | 188 } |
189 | 189 |
190 bool MetaTable::GetValue(const char* key, std::string* value) { | 190 bool MetaTable::GetValue(const char* key, std::string* value) { |
191 Statement s; | 191 Statement s; |
192 if (!PrepareGetStatement(&s, key)) | 192 if (!PrepareGetStatement(&s, key)) |
193 return false; | 193 return false; |
194 | 194 |
195 *value = s.ColumnString(0); | 195 *value = s.ColumnString(0); |
196 return true; | 196 return true; |
197 } | 197 } |
198 | 198 |
199 bool MetaTable::GetValue(const char* key, int* value) { | 199 bool MetaTable::GetValue(const char* key, int* value) { |
200 Statement s; | 200 Statement s; |
201 if (!PrepareGetStatement(&s, key)) | 201 if (!PrepareGetStatement(&s, key)) |
202 return false; | 202 return false; |
203 | 203 |
204 *value = s.ColumnInt(0); | 204 *value = s.ColumnInt(0); |
205 return true; | 205 return true; |
206 } | 206 } |
207 | 207 |
208 bool MetaTable::GetValue(const char* key, int64* value) { | 208 bool MetaTable::GetValue(const char* key, int64_t* value) { |
209 Statement s; | 209 Statement s; |
210 if (!PrepareGetStatement(&s, key)) | 210 if (!PrepareGetStatement(&s, key)) |
211 return false; | 211 return false; |
212 | 212 |
213 *value = s.ColumnInt64(0); | 213 *value = s.ColumnInt64(0); |
214 return true; | 214 return true; |
215 } | 215 } |
216 | 216 |
217 bool MetaTable::DeleteKey(const char* key) { | 217 bool MetaTable::DeleteKey(const char* key) { |
218 DCHECK(db_); | 218 DCHECK(db_); |
(...skipping 11 matching lines...) Expand all Loading... |
230 | 230 |
231 bool MetaTable::PrepareGetStatement(Statement* statement, const char* key) { | 231 bool MetaTable::PrepareGetStatement(Statement* statement, const char* key) { |
232 DCHECK(db_ && statement); | 232 DCHECK(db_ && statement); |
233 statement->Assign(db_->GetCachedStatement(SQL_FROM_HERE, | 233 statement->Assign(db_->GetCachedStatement(SQL_FROM_HERE, |
234 "SELECT value FROM meta WHERE key=?")); | 234 "SELECT value FROM meta WHERE key=?")); |
235 statement->BindCString(0, key); | 235 statement->BindCString(0, key); |
236 return statement->Step(); | 236 return statement->Step(); |
237 } | 237 } |
238 | 238 |
239 } // namespace sql | 239 } // namespace sql |
OLD | NEW |