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. | |
Ilya Sherman
2013/07/16 22:35:52
nit: Mebbe clarify that this is a no-op on other p
Scott Hess - ex-Googler
2013/07/17 00:25:37
Done.
| |
122 void set_restrict_to_user() { restrict_to_user_ = true; } | |
123 | |
119 // Set an error-handling callback. On errors, the error number (and | 124 // Set an error-handling callback. On errors, the error number (and |
120 // statement, if available) will be passed to the callback. | 125 // statement, if available) will be passed to the callback. |
121 // | 126 // |
122 // If no callback is set, the default action is to crash in debug | 127 // If no callback is set, the default action is to crash in debug |
123 // mode or return failure in release mode. | 128 // mode or return failure in release mode. |
124 typedef base::Callback<void(int, Statement*)> ErrorCallback; | 129 typedef base::Callback<void(int, Statement*)> ErrorCallback; |
125 void set_error_callback(const ErrorCallback& callback) { | 130 void set_error_callback(const ErrorCallback& callback) { |
126 error_callback_ = callback; | 131 error_callback_ = callback; |
127 } | 132 } |
128 bool has_error_callback() const { | 133 bool has_error_callback() const { |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 | 479 |
475 // The actual sqlite database. Will be NULL before Init has been called or if | 480 // The actual sqlite database. Will be NULL before Init has been called or if |
476 // Init resulted in an error. | 481 // Init resulted in an error. |
477 sqlite3* db_; | 482 sqlite3* db_; |
478 | 483 |
479 // Parameters we'll configure in sqlite before doing anything else. Zero means | 484 // Parameters we'll configure in sqlite before doing anything else. Zero means |
480 // use the default value. | 485 // use the default value. |
481 int page_size_; | 486 int page_size_; |
482 int cache_size_; | 487 int cache_size_; |
483 bool exclusive_locking_; | 488 bool exclusive_locking_; |
489 bool restrict_to_user_; | |
484 | 490 |
485 // All cached statements. Keeping a reference to these statements means that | 491 // All cached statements. Keeping a reference to these statements means that |
486 // they'll remain active. | 492 // they'll remain active. |
487 typedef std::map<StatementID, scoped_refptr<StatementRef> > | 493 typedef std::map<StatementID, scoped_refptr<StatementRef> > |
488 CachedStatementMap; | 494 CachedStatementMap; |
489 CachedStatementMap statement_cache_; | 495 CachedStatementMap statement_cache_; |
490 | 496 |
491 // A list of all StatementRefs we've given out. Each ref must register with | 497 // 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 | 498 // us when it's created or destroyed. This allows us to potentially close |
493 // any open statements when we encounter an error. | 499 // any open statements when we encounter an error. |
(...skipping 22 matching lines...) Expand all Loading... | |
516 | 522 |
517 // Tag for auxiliary histograms. | 523 // Tag for auxiliary histograms. |
518 std::string histogram_tag_; | 524 std::string histogram_tag_; |
519 | 525 |
520 DISALLOW_COPY_AND_ASSIGN(Connection); | 526 DISALLOW_COPY_AND_ASSIGN(Connection); |
521 }; | 527 }; |
522 | 528 |
523 } // namespace sql | 529 } // namespace sql |
524 | 530 |
525 #endif // SQL_CONNECTION_H_ | 531 #endif // SQL_CONNECTION_H_ |
OLD | NEW |