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

Side by Side Diff: sql/statement.cc

Issue 10540155: Annotate calls to SQLite functions - they have to be executed on a thread allowing IO access. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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
« sql/connection.cc ('K') | « 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (!CheckValid()) 51 if (!CheckValid())
52 return false; 52 return false;
53 53
54 ref_->AssertIOAllowed();
54 return CheckError(sqlite3_step(ref_->stmt())) == SQLITE_DONE; 55 return CheckError(sqlite3_step(ref_->stmt())) == SQLITE_DONE;
55 } 56 }
56 57
57 bool Statement::Step() { 58 bool Statement::Step() {
58 if (!CheckValid()) 59 if (!CheckValid())
59 return false; 60 return false;
60 61
62 ref_->AssertIOAllowed();
61 return CheckError(sqlite3_step(ref_->stmt())) == SQLITE_ROW; 63 return CheckError(sqlite3_step(ref_->stmt())) == SQLITE_ROW;
62 } 64 }
63 65
64 void Statement::Reset(bool clear_bound_vars) { 66 void Statement::Reset(bool clear_bound_vars) {
65 if (is_valid()) { 67 if (is_valid()) {
66 // We don't call CheckError() here because sqlite3_reset() returns 68 // We don't call CheckError() here because sqlite3_reset() returns
67 // the last error that Step() caused thereby generating a second 69 // the last error that Step() caused thereby generating a second
68 // spurious error callback. 70 // spurious error callback.
69 if (clear_bound_vars) 71 if (clear_bound_vars)
70 sqlite3_clear_bindings(ref_->stmt()); 72 sqlite3_clear_bindings(ref_->stmt());
73
74 ref_->AssertIOAllowed();
71 sqlite3_reset(ref_->stmt()); 75 sqlite3_reset(ref_->stmt());
72 } 76 }
73 77
74 succeeded_ = false; 78 succeeded_ = false;
75 } 79 }
76 80
77 bool Statement::Succeeded() const { 81 bool Statement::Succeeded() const {
78 if (!is_valid()) 82 if (!is_valid())
79 return false; 83 return false;
80 84
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 306
303 int Statement::CheckError(int err) { 307 int Statement::CheckError(int err) {
304 // Please don't add DCHECKs here, OnSqliteError() already has them. 308 // Please don't add DCHECKs here, OnSqliteError() already has them.
305 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); 309 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE);
306 if (!succeeded_ && is_valid()) 310 if (!succeeded_ && is_valid())
307 return ref_->connection()->OnSqliteError(err, this); 311 return ref_->connection()->OnSqliteError(err, this);
308 return err; 312 return err;
309 } 313 }
310 314
311 } // namespace sql 315 } // namespace sql
OLDNEW
« sql/connection.cc ('K') | « sql/connection.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698