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

Side by Side Diff: chrome/browser/history/archived_database.cc

Issue 222024: Coverity: Initialize statement_cache_ in the constructor.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm>
6 #include <string>
7
5 #include "base/string_util.h" 8 #include "base/string_util.h"
6 #include "chrome/browser/history/archived_database.h" 9 #include "chrome/browser/history/archived_database.h"
7 #include "chrome/common/sqlite_utils.h" 10 #include "chrome/common/sqlite_utils.h"
8 11
9 namespace history { 12 namespace history {
10 13
11 namespace { 14 namespace {
12 15
13 static const int kCurrentVersionNumber = 2; 16 static const int kCurrentVersionNumber = 2;
14 static const int kCompatibleVersionNumber = 2; 17 static const int kCompatibleVersionNumber = 2;
15 18
16 } // namespace 19 } // namespace
17 20
18 ArchivedDatabase::ArchivedDatabase() 21 ArchivedDatabase::ArchivedDatabase()
19 : db_(NULL), 22 : db_(NULL),
23 statement_cache_(NULL),
20 transaction_nesting_(0) { 24 transaction_nesting_(0) {
21 } 25 }
22 26
23 ArchivedDatabase::~ArchivedDatabase() { 27 ArchivedDatabase::~ArchivedDatabase() {
24 } 28 }
25 29
26 bool ArchivedDatabase::Init(const FilePath& file_name) { 30 bool ArchivedDatabase::Init(const FilePath& file_name) {
27 // OpenSqliteDb uses the narrow version of open, indicating to sqlite that we 31 // OpenSqliteDb uses the narrow version of open, indicating to sqlite that we
28 // want the database to be in UTF-8 if it doesn't already exist. 32 // want the database to be in UTF-8 if it doesn't already exist.
29 DCHECK(!db_) << "Already initialized!"; 33 DCHECK(!db_) << "Already initialized!";
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 DCHECK(db_); 77 DCHECK(db_);
74 if (transaction_nesting_ == 0) { 78 if (transaction_nesting_ == 0) {
75 int rv = sqlite3_exec(db_, "BEGIN TRANSACTION", NULL, NULL, NULL); 79 int rv = sqlite3_exec(db_, "BEGIN TRANSACTION", NULL, NULL, NULL);
76 DCHECK(rv == SQLITE_OK) << "Failed to begin transaction"; 80 DCHECK(rv == SQLITE_OK) << "Failed to begin transaction";
77 } 81 }
78 transaction_nesting_++; 82 transaction_nesting_++;
79 } 83 }
80 84
81 void ArchivedDatabase::CommitTransaction() { 85 void ArchivedDatabase::CommitTransaction() {
82 DCHECK(db_); 86 DCHECK(db_);
83 DCHECK(transaction_nesting_ > 0) << "Committing too many transactions"; 87 DCHECK_GT(transaction_nesting_, 0) << "Committing too many transactions";
84 transaction_nesting_--; 88 transaction_nesting_--;
85 if (transaction_nesting_ == 0) { 89 if (transaction_nesting_ == 0) {
86 int rv = sqlite3_exec(db_, "COMMIT", NULL, NULL, NULL); 90 int rv = sqlite3_exec(db_, "COMMIT", NULL, NULL, NULL);
87 DCHECK(rv == SQLITE_OK) << "Failed to commit transaction"; 91 DCHECK(rv == SQLITE_OK) << "Failed to commit transaction";
88 } 92 }
89 } 93 }
90 94
91 sqlite3* ArchivedDatabase::GetDB() { 95 sqlite3* ArchivedDatabase::GetDB() {
92 return db_; 96 return db_;
93 } 97 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // Put future migration cases here. 130 // Put future migration cases here.
127 131
128 // When the version is too old, we just try to continue anyway, there should 132 // When the version is too old, we just try to continue anyway, there should
129 // not be a released product that makes a database too old for us to handle. 133 // not be a released product that makes a database too old for us to handle.
130 LOG_IF(WARNING, cur_version < kCurrentVersionNumber) << 134 LOG_IF(WARNING, cur_version < kCurrentVersionNumber) <<
131 "Archived database version " << cur_version << " is too old to handle."; 135 "Archived database version " << cur_version << " is too old to handle.";
132 136
133 return INIT_OK; 137 return INIT_OK;
134 } 138 }
135 } // namespace history 139 } // namespace history
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698