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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // for SQLite error codes and database version numbers. | 143 // for SQLite error codes and database version numbers. |
144 void set_histogram_tag(const std::string& tag) { | 144 void set_histogram_tag(const std::string& tag) { |
145 histogram_tag_ = tag; | 145 histogram_tag_ = tag; |
146 } | 146 } |
147 | 147 |
148 // Record a sparse UMA histogram sample under | 148 // Record a sparse UMA histogram sample under |
149 // |name|+"."+|histogram_tag_|. If |histogram_tag_| is empty, no | 149 // |name|+"."+|histogram_tag_|. If |histogram_tag_| is empty, no |
150 // histogram is recorded. | 150 // histogram is recorded. |
151 void AddTaggedHistogram(const std::string& name, size_t sample) const; | 151 void AddTaggedHistogram(const std::string& name, size_t sample) const; |
152 | 152 |
153 // Run "PRAGMA integrity_check" and post each line of results into | 153 // Run "PRAGMA integrity_check" and post each line of |
154 // |messages|. Returns the success of running the statement - per | 154 // results into |messages|. Returns the success of running the |
155 // the SQLite documentation, if no errors are found the call should | 155 // statement - per the SQLite documentation, if no errors are found the |
156 // succeed, and a single value "ok" should be in messages. | 156 // call should succeed, and a single value "ok" should be in messages. |
157 bool IntegrityCheck(std::vector<std::string>* messages); | 157 bool FullIntegrityCheck(std::vector<std::string>* messages); |
| 158 |
| 159 // Runs "PRAGMA quick_check" and, unlike the FullIntegrityCheck method, |
| 160 // interprets the results returning true if the the statement executes |
| 161 // without error and results in a single "ok" value. |
| 162 bool QuickIntegrityCheck() WARN_UNUSED_RESULT; |
158 | 163 |
159 // Initialization ------------------------------------------------------------ | 164 // Initialization ------------------------------------------------------------ |
160 | 165 |
161 // Initializes the SQL connection for the given file, returning true if the | 166 // Initializes the SQL connection for the given file, returning true if the |
162 // file could be opened. You can call this or OpenInMemory. | 167 // file could be opened. You can call this or OpenInMemory. |
163 bool Open(const base::FilePath& path) WARN_UNUSED_RESULT; | 168 bool Open(const base::FilePath& path) WARN_UNUSED_RESULT; |
164 | 169 |
165 // Initializes the SQL connection for a temporary in-memory database. There | 170 // Initializes the SQL connection for a temporary in-memory database. There |
166 // will be no associated file on disk, and the initial database will be | 171 // will be no associated file on disk, and the initial database will be |
167 // empty. You can call this or Open. | 172 // empty. You can call this or Open. |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 WARN_UNUSED_RESULT; | 538 WARN_UNUSED_RESULT; |
534 | 539 |
535 // Internal helper for const functions. Like GetUniqueStatement(), | 540 // Internal helper for const functions. Like GetUniqueStatement(), |
536 // except the statement is not entered into open_statements_, | 541 // except the statement is not entered into open_statements_, |
537 // allowing this function to be const. Open statements can block | 542 // allowing this function to be const. Open statements can block |
538 // closing the database, so only use in cases where the last ref is | 543 // closing the database, so only use in cases where the last ref is |
539 // released before close could be called (which should always be the | 544 // released before close could be called (which should always be the |
540 // case for const functions). | 545 // case for const functions). |
541 scoped_refptr<StatementRef> GetUntrackedStatement(const char* sql) const; | 546 scoped_refptr<StatementRef> GetUntrackedStatement(const char* sql) const; |
542 | 547 |
| 548 bool IntegrityCheckHelper( |
| 549 const char* pragma_sql, |
| 550 std::vector<std::string>* messages) WARN_UNUSED_RESULT; |
| 551 |
543 // The actual sqlite database. Will be NULL before Init has been called or if | 552 // The actual sqlite database. Will be NULL before Init has been called or if |
544 // Init resulted in an error. | 553 // Init resulted in an error. |
545 sqlite3* db_; | 554 sqlite3* db_; |
546 | 555 |
547 // Parameters we'll configure in sqlite before doing anything else. Zero means | 556 // Parameters we'll configure in sqlite before doing anything else. Zero means |
548 // use the default value. | 557 // use the default value. |
549 int page_size_; | 558 int page_size_; |
550 int cache_size_; | 559 int cache_size_; |
551 bool exclusive_locking_; | 560 bool exclusive_locking_; |
552 bool restrict_to_user_; | 561 bool restrict_to_user_; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 | 594 |
586 // Tag for auxiliary histograms. | 595 // Tag for auxiliary histograms. |
587 std::string histogram_tag_; | 596 std::string histogram_tag_; |
588 | 597 |
589 DISALLOW_COPY_AND_ASSIGN(Connection); | 598 DISALLOW_COPY_AND_ASSIGN(Connection); |
590 }; | 599 }; |
591 | 600 |
592 } // namespace sql | 601 } // namespace sql |
593 | 602 |
594 #endif // SQL_CONNECTION_H_ | 603 #endif // SQL_CONNECTION_H_ |
OLD | NEW |