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. |
| 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 void reset_error_callback() { | 133 void reset_error_callback() { |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 | 476 |
472 // The actual sqlite database. Will be NULL before Init has been called or if | 477 // The actual sqlite database. Will be NULL before Init has been called or if |
473 // Init resulted in an error. | 478 // Init resulted in an error. |
474 sqlite3* db_; | 479 sqlite3* db_; |
475 | 480 |
476 // Parameters we'll configure in sqlite before doing anything else. Zero means | 481 // Parameters we'll configure in sqlite before doing anything else. Zero means |
477 // use the default value. | 482 // use the default value. |
478 int page_size_; | 483 int page_size_; |
479 int cache_size_; | 484 int cache_size_; |
480 bool exclusive_locking_; | 485 bool exclusive_locking_; |
| 486 bool restrict_to_user_; |
481 | 487 |
482 // All cached statements. Keeping a reference to these statements means that | 488 // All cached statements. Keeping a reference to these statements means that |
483 // they'll remain active. | 489 // they'll remain active. |
484 typedef std::map<StatementID, scoped_refptr<StatementRef> > | 490 typedef std::map<StatementID, scoped_refptr<StatementRef> > |
485 CachedStatementMap; | 491 CachedStatementMap; |
486 CachedStatementMap statement_cache_; | 492 CachedStatementMap statement_cache_; |
487 | 493 |
488 // A list of all StatementRefs we've given out. Each ref must register with | 494 // A list of all StatementRefs we've given out. Each ref must register with |
489 // us when it's created or destroyed. This allows us to potentially close | 495 // us when it's created or destroyed. This allows us to potentially close |
490 // any open statements when we encounter an error. | 496 // any open statements when we encounter an error. |
(...skipping 22 matching lines...) Expand all Loading... |
513 | 519 |
514 // Tag for auxiliary histograms. | 520 // Tag for auxiliary histograms. |
515 std::string histogram_tag_; | 521 std::string histogram_tag_; |
516 | 522 |
517 DISALLOW_COPY_AND_ASSIGN(Connection); | 523 DISALLOW_COPY_AND_ASSIGN(Connection); |
518 }; | 524 }; |
519 | 525 |
520 } // namespace sql | 526 } // namespace sql |
521 | 527 |
522 #endif // SQL_CONNECTION_H_ | 528 #endif // SQL_CONNECTION_H_ |
OLD | NEW |