Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: sql/meta_table.cc

Issue 14976003: Histogram versions and extended error codes for SQLite databases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: excess include. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/string_util.h" 8 #include "base/string_util.h"
9 #include "sql/connection.h" 9 #include "sql/connection.h"
10 #include "sql/statement.h" 10 #include "sql/statement.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 if (!DoesTableExist(db)) { 45 if (!DoesTableExist(db)) {
46 if (!db_->Execute("CREATE TABLE meta" 46 if (!db_->Execute("CREATE TABLE meta"
47 "(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR)")) 47 "(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR)"))
48 return false; 48 return false;
49 49
50 // Note: there is no index over the meta table. We currently only have a 50 // Note: there is no index over the meta table. We currently only have a
51 // couple of keys, so it doesn't matter. If we start storing more stuff in 51 // couple of keys, so it doesn't matter. If we start storing more stuff in
52 // there, we should create an index. 52 // there, we should create an index.
53 SetVersionNumber(version); 53 SetVersionNumber(version);
54 SetCompatibleVersionNumber(compatible_version); 54 SetCompatibleVersionNumber(compatible_version);
55 } else {
56 // At this point, the highest version is Web, at 50, then
57 // History at 25, then a tie for 6. 100 leaves some room for
58 // growth.
59 // TODO(shess): Another option would be to use |version| as the cap.
60 static size_t kSqliteVersionMax = 100;
jar (doing other things) 2013/05/07 23:46:41 This fits wonderfully into a UMA_HISTOGRAM_SPARSE_
61 db_->AddLinearHistogram(".Version", GetVersionNumber(), kSqliteVersionMax);
55 } 62 }
56 return transaction.Commit(); 63 return transaction.Commit();
57 } 64 }
58 65
59 void MetaTable::Reset() { 66 void MetaTable::Reset() {
60 db_ = NULL; 67 db_ = NULL;
61 } 68 }
62 69
63 void MetaTable::SetVersionNumber(int version) { 70 void MetaTable::SetVersionNumber(int version) {
64 DCHECK_GT(version, 0); 71 DCHECK_GT(version, 0);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 151
145 bool MetaTable::PrepareGetStatement(Statement* statement, const char* key) { 152 bool MetaTable::PrepareGetStatement(Statement* statement, const char* key) {
146 DCHECK(db_ && statement); 153 DCHECK(db_ && statement);
147 statement->Assign(db_->GetCachedStatement(SQL_FROM_HERE, 154 statement->Assign(db_->GetCachedStatement(SQL_FROM_HERE,
148 "SELECT value FROM meta WHERE key=?")); 155 "SELECT value FROM meta WHERE key=?"));
149 statement->BindCString(0, key); 156 statement->BindCString(0, key);
150 return statement->Step(); 157 return statement->Step();
151 } 158 }
152 159
153 } // namespace sql 160 } // namespace sql
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698