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

Side by Side Diff: sql/connection.h

Issue 10736042: [sql] Refactor to remove use of const_cast<>. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove accidentally-remaining change. 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 | « no previous file | sql/connection.cc » ('j') | sql/connection.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef SQL_CONNECTION_H_ 5 #ifndef SQL_CONNECTION_H_
6 #define SQL_CONNECTION_H_ 6 #define SQL_CONNECTION_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 // A statement ref can be valid, in which case it can be used, or invalid to 332 // A statement ref can be valid, in which case it can be used, or invalid to
333 // indicate that the statement hasn't been created yet, has an error, or has 333 // indicate that the statement hasn't been created yet, has an error, or has
334 // been destroyed. 334 // been destroyed.
335 // 335 //
336 // The Connection may revoke a StatementRef in some error cases, so callers 336 // The Connection may revoke a StatementRef in some error cases, so callers
337 // should always check validity before using. 337 // should always check validity before using.
338 class SQL_EXPORT StatementRef : public base::RefCounted<StatementRef> { 338 class SQL_EXPORT StatementRef : public base::RefCounted<StatementRef> {
339 public: 339 public:
340 // Default constructor initializes to an invalid statement. 340 // Default constructor initializes to an invalid statement.
341 StatementRef(); 341 StatementRef();
342 explicit StatementRef(sqlite3_stmt* stmt);
342 StatementRef(Connection* connection, sqlite3_stmt* stmt); 343 StatementRef(Connection* connection, sqlite3_stmt* stmt);
343 344
344 // When true, the statement can be used. 345 // When true, the statement can be used.
345 bool is_valid() const { return !!stmt_; } 346 bool is_valid() const { return !!stmt_; }
346 347
347 // If we've not been linked to a connection, this will be NULL. Guaranteed 348 // If we've not been linked to a connection, this will be NULL. Guaranteed
348 // non-NULL when is_valid(). 349 // non-NULL when is_valid().
349 Connection* connection() const { return connection_; } 350 Connection* connection() const { return connection_; }
350 351
351 // Returns the sqlite statement if any. If the statement is not active, 352 // Returns the sqlite statement if any. If the statement is not active,
(...skipping 29 matching lines...) Expand all
381 void ClearCache(); 382 void ClearCache();
382 383
383 // Called by Statement objects when an sqlite function returns an error. 384 // Called by Statement objects when an sqlite function returns an error.
384 // The return value is the error code reflected back to client code. 385 // The return value is the error code reflected back to client code.
385 int OnSqliteError(int err, Statement* stmt); 386 int OnSqliteError(int err, Statement* stmt);
386 387
387 // Like |Execute()|, but retries if the database is locked. 388 // Like |Execute()|, but retries if the database is locked.
388 bool ExecuteWithTimeout(const char* sql, base::TimeDelta ms_timeout) 389 bool ExecuteWithTimeout(const char* sql, base::TimeDelta ms_timeout)
389 WARN_UNUSED_RESULT; 390 WARN_UNUSED_RESULT;
390 391
392 // Like GetUniqueStatement(), except the statement is not entered
393 // into open_statements_, allowing this to be const. Open
394 // statements can block closing the database, so only use in cases
395 // where the last ref is released before close could be called.
396 scoped_refptr<StatementRef> GetUntrackedStatement(const char* sql) const;
Greg Billock 2012/07/12 21:08:17 I am reading this as being private, right? It look
Scott Hess - ex-Googler 2012/07/12 21:53:08 Yeah, it's private. Looks to me like pulling it i
397
391 // The actual sqlite database. Will be NULL before Init has been called or if 398 // The actual sqlite database. Will be NULL before Init has been called or if
392 // Init resulted in an error. 399 // Init resulted in an error.
393 sqlite3* db_; 400 sqlite3* db_;
394 401
395 // Parameters we'll configure in sqlite before doing anything else. Zero means 402 // Parameters we'll configure in sqlite before doing anything else. Zero means
396 // use the default value. 403 // use the default value.
397 int page_size_; 404 int page_size_;
398 int cache_size_; 405 int cache_size_;
399 bool exclusive_locking_; 406 bool exclusive_locking_;
400 407
(...skipping 20 matching lines...) Expand all
421 // This object handles errors resulting from all forms of executing sqlite 428 // This object handles errors resulting from all forms of executing sqlite
422 // commands or statements. It can be null which means default handling. 429 // commands or statements. It can be null which means default handling.
423 scoped_refptr<ErrorDelegate> error_delegate_; 430 scoped_refptr<ErrorDelegate> error_delegate_;
424 431
425 DISALLOW_COPY_AND_ASSIGN(Connection); 432 DISALLOW_COPY_AND_ASSIGN(Connection);
426 }; 433 };
427 434
428 } // namespace sql 435 } // namespace sql
429 436
430 #endif // SQL_CONNECTION_H_ 437 #endif // SQL_CONNECTION_H_
OLDNEW
« no previous file with comments | « no previous file | sql/connection.cc » ('j') | sql/connection.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698