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

Side by Side Diff: sql/statement.cc

Issue 10806025: Revert 147309 - Annotate calls to SQLite functions - they have to be executed on a thread allowing … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | « sql/connection.cc ('k') | 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) 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/statement.h" 5 #include "sql/statement.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 "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "third_party/sqlite/sqlite3.h" 10 #include "third_party/sqlite/sqlite3.h"
(...skipping 30 matching lines...) Expand all
41 succeeded_ = false; 41 succeeded_ = false;
42 } 42 }
43 43
44 bool Statement::CheckValid() const { 44 bool Statement::CheckValid() const {
45 if (!is_valid()) 45 if (!is_valid())
46 DLOG(FATAL) << "Cannot call mutating statements on an invalid statement."; 46 DLOG(FATAL) << "Cannot call mutating statements on an invalid statement.";
47 return is_valid(); 47 return is_valid();
48 } 48 }
49 49
50 bool Statement::Run() { 50 bool Statement::Run() {
51 ref_->AssertIOAllowed();
52 if (!CheckValid()) 51 if (!CheckValid())
53 return false; 52 return false;
54 53
55 return CheckError(sqlite3_step(ref_->stmt())) == SQLITE_DONE; 54 return CheckError(sqlite3_step(ref_->stmt())) == SQLITE_DONE;
56 } 55 }
57 56
58 bool Statement::Step() { 57 bool Statement::Step() {
59 ref_->AssertIOAllowed();
60 if (!CheckValid()) 58 if (!CheckValid())
61 return false; 59 return false;
62 60
63 return CheckError(sqlite3_step(ref_->stmt())) == SQLITE_ROW; 61 return CheckError(sqlite3_step(ref_->stmt())) == SQLITE_ROW;
64 } 62 }
65 63
66 void Statement::Reset(bool clear_bound_vars) { 64 void Statement::Reset(bool clear_bound_vars) {
67 ref_->AssertIOAllowed();
68 if (is_valid()) { 65 if (is_valid()) {
69 // We don't call CheckError() here because sqlite3_reset() returns 66 // We don't call CheckError() here because sqlite3_reset() returns
70 // the last error that Step() caused thereby generating a second 67 // the last error that Step() caused thereby generating a second
71 // spurious error callback. 68 // spurious error callback.
72 if (clear_bound_vars) 69 if (clear_bound_vars)
73 sqlite3_clear_bindings(ref_->stmt()); 70 sqlite3_clear_bindings(ref_->stmt());
74 sqlite3_reset(ref_->stmt()); 71 sqlite3_reset(ref_->stmt());
75 } 72 }
76 73
77 succeeded_ = false; 74 succeeded_ = false;
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 302
306 int Statement::CheckError(int err) { 303 int Statement::CheckError(int err) {
307 // Please don't add DCHECKs here, OnSqliteError() already has them. 304 // Please don't add DCHECKs here, OnSqliteError() already has them.
308 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); 305 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE);
309 if (!succeeded_ && is_valid()) 306 if (!succeeded_ && is_valid())
310 return ref_->connection()->OnSqliteError(err, this); 307 return ref_->connection()->OnSqliteError(err, this);
311 return err; 308 return err;
312 } 309 }
313 310
314 } // namespace sql 311 } // namespace sql
OLDNEW
« no previous file with comments | « sql/connection.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698