summaryrefslogtreecommitdiffstats
path: root/sql/connection.h
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-24 01:59:58 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-24 01:59:58 +0000
commit2eec0a26907429341fb077b6968cc24dcc40378b (patch)
tree53d46fd61207c46dcee9cf701fab44206d64c771 /sql/connection.h
parent35bc8bfe2930a0157c17cdd5bd6abb5c0558f57a (diff)
downloadchromium_src-2eec0a26907429341fb077b6968cc24dcc40378b.zip
chromium_src-2eec0a26907429341fb077b6968cc24dcc40378b.tar.gz
chromium_src-2eec0a26907429341fb077b6968cc24dcc40378b.tar.bz2
[sql] Refactor to remove use of const_cast<>.
The comments in these cases used incorrect reasoning for why the const_cast<> was safe. Whether the SQL statements modify the database is irrelevant. Add an internal helper to allow them to correctly accomplish things in a const situation. BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/10736042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148031 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql/connection.h')
-rw-r--r--sql/connection.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/sql/connection.h b/sql/connection.h
index fba0326..e5c9469 100644
--- a/sql/connection.h
+++ b/sql/connection.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -338,6 +338,7 @@ class SQL_EXPORT Connection {
public:
// Default constructor initializes to an invalid statement.
StatementRef();
+ explicit StatementRef(sqlite3_stmt* stmt);
StatementRef(Connection* connection, sqlite3_stmt* stmt);
// When true, the statement can be used.
@@ -387,6 +388,14 @@ class SQL_EXPORT Connection {
bool ExecuteWithTimeout(const char* sql, base::TimeDelta ms_timeout)
WARN_UNUSED_RESULT;
+ // Internal helper for const functions. Like GetUniqueStatement(),
+ // except the statement is not entered into open_statements_,
+ // allowing this function to be const. Open statements can block
+ // closing the database, so only use in cases where the last ref is
+ // released before close could be called (which should always be the
+ // case for const functions).
+ scoped_refptr<StatementRef> GetUntrackedStatement(const char* sql) const;
+
// The actual sqlite database. Will be NULL before Init has been called or if
// Init resulted in an error.
sqlite3* db_;