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

Side by Side Diff: sql/statement.cc

Issue 10824008: 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, 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
« 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();
51 if (!CheckValid()) 52 if (!CheckValid())
52 return false; 53 return false;
53 54
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() {
59 ref_->AssertIOAllowed();
58 if (!CheckValid()) 60 if (!CheckValid())
59 return false; 61 return false;
60 62
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) {
67 ref_->AssertIOAllowed();
65 if (is_valid()) { 68 if (is_valid()) {
66 // We don't call CheckError() here because sqlite3_reset() returns 69 // We don't call CheckError() here because sqlite3_reset() returns
67 // the last error that Step() caused thereby generating a second 70 // the last error that Step() caused thereby generating a second
68 // spurious error callback. 71 // spurious error callback.
69 if (clear_bound_vars) 72 if (clear_bound_vars)
70 sqlite3_clear_bindings(ref_->stmt()); 73 sqlite3_clear_bindings(ref_->stmt());
71 sqlite3_reset(ref_->stmt()); 74 sqlite3_reset(ref_->stmt());
72 } 75 }
73 76
74 succeeded_ = false; 77 succeeded_ = false;
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 305
303 int Statement::CheckError(int err) { 306 int Statement::CheckError(int err) {
304 // Please don't add DCHECKs here, OnSqliteError() already has them. 307 // Please don't add DCHECKs here, OnSqliteError() already has them.
305 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); 308 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE);
306 if (!succeeded_ && is_valid()) 309 if (!succeeded_ && is_valid())
307 return ref_->connection()->OnSqliteError(err, this); 310 return ref_->connection()->OnSqliteError(err, this);
308 return err; 311 return err;
309 } 312 }
310 313
311 } // namespace sql 314 } // 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