OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/connection.h" | 5 #include "app/sql/connection.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "app/sql/statement.h" | 9 #include "app/sql/statement.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 Statement begin(GetCachedStatement(SQL_FROM_HERE, "BEGIN TRANSACTION")); | 115 Statement begin(GetCachedStatement(SQL_FROM_HERE, "BEGIN TRANSACTION")); |
116 if (!begin || !begin.Run()) | 116 if (!begin || !begin.Run()) |
117 return false; | 117 return false; |
118 } | 118 } |
119 transaction_nesting_++; | 119 transaction_nesting_++; |
120 return success; | 120 return success; |
121 } | 121 } |
122 | 122 |
123 void Connection::RollbackTransaction() { | 123 void Connection::RollbackTransaction() { |
124 if (!transaction_nesting_) { | 124 if (!transaction_nesting_) { |
125 NOTREACHED() << "Rolling back a nonexistant transaction"; | 125 NOTREACHED() << "Rolling back a nonexistent transaction"; |
126 return; | 126 return; |
127 } | 127 } |
128 | 128 |
129 transaction_nesting_--; | 129 transaction_nesting_--; |
130 | 130 |
131 if (transaction_nesting_ > 0) { | 131 if (transaction_nesting_ > 0) { |
132 // Mark the outermost transaction as needing rollback. | 132 // Mark the outermost transaction as needing rollback. |
133 needs_rollback_ = true; | 133 needs_rollback_ = true; |
134 return; | 134 return; |
135 } | 135 } |
136 | 136 |
137 DoRollback(); | 137 DoRollback(); |
138 } | 138 } |
139 | 139 |
140 bool Connection::CommitTransaction() { | 140 bool Connection::CommitTransaction() { |
141 if (!transaction_nesting_) { | 141 if (!transaction_nesting_) { |
142 NOTREACHED() << "Rolling back a nonexistant transaction"; | 142 NOTREACHED() << "Rolling back a nonexistent transaction"; |
143 return false; | 143 return false; |
144 } | 144 } |
145 transaction_nesting_--; | 145 transaction_nesting_--; |
146 | 146 |
147 if (transaction_nesting_ > 0) { | 147 if (transaction_nesting_ > 0) { |
148 // Mark any nested transactions as failing after we've already got one. | 148 // Mark any nested transactions as failing after we've already got one. |
149 return !needs_rollback_; | 149 return !needs_rollback_; |
150 } | 150 } |
151 | 151 |
152 if (needs_rollback_) { | 152 if (needs_rollback_) { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 327 |
328 int Connection::OnSqliteError(int err, sql::Statement *stmt) { | 328 int Connection::OnSqliteError(int err, sql::Statement *stmt) { |
329 if (error_delegate_.get()) | 329 if (error_delegate_.get()) |
330 return error_delegate_->OnError(err, this, stmt); | 330 return error_delegate_->OnError(err, this, stmt); |
331 // The default handling is to assert on debug and to ignore on release. | 331 // The default handling is to assert on debug and to ignore on release. |
332 NOTREACHED() << GetErrorMessage(); | 332 NOTREACHED() << GetErrorMessage(); |
333 return err; | 333 return err; |
334 } | 334 } |
335 | 335 |
336 } // namespace sql | 336 } // namespace sql |
OLD | NEW |