| OLD | NEW |
| 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 #ifndef SQL_CONNECTION_H_ | 5 #ifndef SQL_CONNECTION_H_ |
| 6 #define SQL_CONNECTION_H_ | 6 #define SQL_CONNECTION_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // transaition (requires another access to the DB) and because we don't | 109 // transaition (requires another access to the DB) and because we don't |
| 110 // actually need it. | 110 // actually need it. |
| 111 // | 111 // |
| 112 // Exclusive mode means that the database is not unlocked at the end of each | 112 // Exclusive mode means that the database is not unlocked at the end of each |
| 113 // transaction, which means there may be less time spent initializing the | 113 // transaction, which means there may be less time spent initializing the |
| 114 // next transaction because it doesn't have to re-aquire locks. | 114 // next transaction because it doesn't have to re-aquire locks. |
| 115 // | 115 // |
| 116 // This must be called before Open() to have an effect. | 116 // This must be called before Open() to have an effect. |
| 117 void set_exclusive_locking() { exclusive_locking_ = true; } | 117 void set_exclusive_locking() { exclusive_locking_ = true; } |
| 118 | 118 |
| 119 // Call to cause Open() to restrict access permissions of the |
| 120 // database file to only the owner. |
| 121 // TODO(shess): Currently only supported on OS_POSIX, is a noop on |
| 122 // other platforms. |
| 123 void set_restrict_to_user() { restrict_to_user_ = true; } |
| 124 |
| 119 // Set an error-handling callback. On errors, the error number (and | 125 // Set an error-handling callback. On errors, the error number (and |
| 120 // statement, if available) will be passed to the callback. | 126 // statement, if available) will be passed to the callback. |
| 121 // | 127 // |
| 122 // If no callback is set, the default action is to crash in debug | 128 // If no callback is set, the default action is to crash in debug |
| 123 // mode or return failure in release mode. | 129 // mode or return failure in release mode. |
| 124 typedef base::Callback<void(int, Statement*)> ErrorCallback; | 130 typedef base::Callback<void(int, Statement*)> ErrorCallback; |
| 125 void set_error_callback(const ErrorCallback& callback) { | 131 void set_error_callback(const ErrorCallback& callback) { |
| 126 error_callback_ = callback; | 132 error_callback_ = callback; |
| 127 } | 133 } |
| 128 bool has_error_callback() const { | 134 bool has_error_callback() const { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 480 |
| 475 // The actual sqlite database. Will be NULL before Init has been called or if | 481 // The actual sqlite database. Will be NULL before Init has been called or if |
| 476 // Init resulted in an error. | 482 // Init resulted in an error. |
| 477 sqlite3* db_; | 483 sqlite3* db_; |
| 478 | 484 |
| 479 // Parameters we'll configure in sqlite before doing anything else. Zero means | 485 // Parameters we'll configure in sqlite before doing anything else. Zero means |
| 480 // use the default value. | 486 // use the default value. |
| 481 int page_size_; | 487 int page_size_; |
| 482 int cache_size_; | 488 int cache_size_; |
| 483 bool exclusive_locking_; | 489 bool exclusive_locking_; |
| 490 bool restrict_to_user_; |
| 484 | 491 |
| 485 // All cached statements. Keeping a reference to these statements means that | 492 // All cached statements. Keeping a reference to these statements means that |
| 486 // they'll remain active. | 493 // they'll remain active. |
| 487 typedef std::map<StatementID, scoped_refptr<StatementRef> > | 494 typedef std::map<StatementID, scoped_refptr<StatementRef> > |
| 488 CachedStatementMap; | 495 CachedStatementMap; |
| 489 CachedStatementMap statement_cache_; | 496 CachedStatementMap statement_cache_; |
| 490 | 497 |
| 491 // A list of all StatementRefs we've given out. Each ref must register with | 498 // A list of all StatementRefs we've given out. Each ref must register with |
| 492 // us when it's created or destroyed. This allows us to potentially close | 499 // us when it's created or destroyed. This allows us to potentially close |
| 493 // any open statements when we encounter an error. | 500 // any open statements when we encounter an error. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 516 | 523 |
| 517 // Tag for auxiliary histograms. | 524 // Tag for auxiliary histograms. |
| 518 std::string histogram_tag_; | 525 std::string histogram_tag_; |
| 519 | 526 |
| 520 DISALLOW_COPY_AND_ASSIGN(Connection); | 527 DISALLOW_COPY_AND_ASSIGN(Connection); |
| 521 }; | 528 }; |
| 522 | 529 |
| 523 } // namespace sql | 530 } // namespace sql |
| 524 | 531 |
| 525 #endif // SQL_CONNECTION_H_ | 532 #endif // SQL_CONNECTION_H_ |
| OLD | NEW |