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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 // transaition (requires another access to the DB) and because we don't | 133 // transaition (requires another access to the DB) and because we don't |
134 // actually need it. | 134 // actually need it. |
135 // | 135 // |
136 // Exclusive mode means that the database is not unlocked at the end of each | 136 // Exclusive mode means that the database is not unlocked at the end of each |
137 // transaction, which means there may be less time spent initializing the | 137 // transaction, which means there may be less time spent initializing the |
138 // next transaction because it doesn't have to re-aquire locks. | 138 // next transaction because it doesn't have to re-aquire locks. |
139 // | 139 // |
140 // This must be called before Open() to have an effect. | 140 // This must be called before Open() to have an effect. |
141 void set_exclusive_locking() { exclusive_locking_ = true; } | 141 void set_exclusive_locking() { exclusive_locking_ = true; } |
142 | 142 |
143 | |
144 // Call to have the database use the default lookaside buffer for small object | |
145 // allocations. The lookaside buffer is intended to provide a speed boost when | |
146 // running with slow malloc implementations. However, under typical use-cases | |
147 // in Chrome, it seem to have no negligible impact while costing 50KB per | |
148 // connection, therefore we disable it by default. | |
149 // | |
150 // This must be called before Open() to have an effect. | |
151 void set_enable_lookaside_buffer() { enable_lookaside_buffer_ = true; } | |
152 | |
Scott Hess - ex-Googler
2013/06/04 16:35:21
IMHO, this is either the right thing to do, or not
rmcilroy
2013/06/04 17:05:38
Done.
| |
143 // Set an error-handling callback. On errors, the error number (and | 153 // Set an error-handling callback. On errors, the error number (and |
144 // statement, if available) will be passed to the callback. | 154 // statement, if available) will be passed to the callback. |
145 // | 155 // |
146 // If no callback is set, the default action is to crash in debug | 156 // If no callback is set, the default action is to crash in debug |
147 // mode or return failure in release mode. | 157 // mode or return failure in release mode. |
148 // | 158 // |
149 // TODO(shess): ErrorDelegate allowed for returning a different | 159 // TODO(shess): ErrorDelegate allowed for returning a different |
150 // error. Determine if this is necessary for the callback. In my | 160 // error. Determine if this is necessary for the callback. In my |
151 // experience, this is not well-tested and probably not safe, and | 161 // experience, this is not well-tested and probably not safe, and |
152 // current clients always return the same error passed. | 162 // current clients always return the same error passed. |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 | 499 |
490 // The actual sqlite database. Will be NULL before Init has been called or if | 500 // The actual sqlite database. Will be NULL before Init has been called or if |
491 // Init resulted in an error. | 501 // Init resulted in an error. |
492 sqlite3* db_; | 502 sqlite3* db_; |
493 | 503 |
494 // Parameters we'll configure in sqlite before doing anything else. Zero means | 504 // Parameters we'll configure in sqlite before doing anything else. Zero means |
495 // use the default value. | 505 // use the default value. |
496 int page_size_; | 506 int page_size_; |
497 int cache_size_; | 507 int cache_size_; |
498 bool exclusive_locking_; | 508 bool exclusive_locking_; |
509 bool enable_lookaside_buffer_; | |
499 | 510 |
500 // All cached statements. Keeping a reference to these statements means that | 511 // All cached statements. Keeping a reference to these statements means that |
501 // they'll remain active. | 512 // they'll remain active. |
502 typedef std::map<StatementID, scoped_refptr<StatementRef> > | 513 typedef std::map<StatementID, scoped_refptr<StatementRef> > |
503 CachedStatementMap; | 514 CachedStatementMap; |
504 CachedStatementMap statement_cache_; | 515 CachedStatementMap statement_cache_; |
505 | 516 |
506 // A list of all StatementRefs we've given out. Each ref must register with | 517 // A list of all StatementRefs we've given out. Each ref must register with |
507 // us when it's created or destroyed. This allows us to potentially close | 518 // us when it's created or destroyed. This allows us to potentially close |
508 // any open statements when we encounter an error. | 519 // any open statements when we encounter an error. |
(...skipping 26 matching lines...) Expand all Loading... | |
535 | 546 |
536 // Tag for auxiliary histograms. | 547 // Tag for auxiliary histograms. |
537 std::string histogram_tag_; | 548 std::string histogram_tag_; |
538 | 549 |
539 DISALLOW_COPY_AND_ASSIGN(Connection); | 550 DISALLOW_COPY_AND_ASSIGN(Connection); |
540 }; | 551 }; |
541 | 552 |
542 } // namespace sql | 553 } // namespace sql |
543 | 554 |
544 #endif // SQL_CONNECTION_H_ | 555 #endif // SQL_CONNECTION_H_ |
OLD | NEW |