| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 void set_exclusive_locking() { exclusive_locking_ = true; } | 139 void set_exclusive_locking() { exclusive_locking_ = true; } |
| 140 | 140 |
| 141 // Sets the object that will handle errors. Recomended that it should be set | 141 // Sets the object that will handle errors. Recomended that it should be set |
| 142 // before calling Open(). If not set, the default is to ignore errors on | 142 // before calling Open(). If not set, the default is to ignore errors on |
| 143 // release and assert on debug builds. | 143 // release and assert on debug builds. |
| 144 // Takes ownership of |delegate|. | 144 // Takes ownership of |delegate|. |
| 145 void set_error_delegate(ErrorDelegate* delegate) { | 145 void set_error_delegate(ErrorDelegate* delegate) { |
| 146 error_delegate_.reset(delegate); | 146 error_delegate_.reset(delegate); |
| 147 } | 147 } |
| 148 | 148 |
| 149 // SQLite error codes for errors on all connections are logged to | 149 // Set this prefix to enable additional connection-type |
| 150 // enum histogram "Sqlite.Error". Setting this additionally logs | 150 // histogramming for SQLite error codes and database version |
| 151 // errors to the histogram |name|. | 151 // numbers. |
| 152 void set_error_histogram_name(const std::string& name) { | 152 void set_histogram_prefix(const std::string& prefix) { |
| 153 error_histogram_name_ = name; | 153 histogram_prefix_ = prefix; |
| 154 } | 154 } |
| 155 | 155 |
| 156 // Record a sparse UMA histogram sample under |histogram_prefix_|+|suffix|. |
| 157 // If |histogram_prefix_| is empty, no histogram is recorded. |
| 158 void AddSparseHistogram(const std::string& suffix, size_t sample) const; |
| 159 |
| 156 // Initialization ------------------------------------------------------------ | 160 // Initialization ------------------------------------------------------------ |
| 157 | 161 |
| 158 // Initializes the SQL connection for the given file, returning true if the | 162 // Initializes the SQL connection for the given file, returning true if the |
| 159 // file could be opened. You can call this or OpenInMemory. | 163 // file could be opened. You can call this or OpenInMemory. |
| 160 bool Open(const base::FilePath& path) WARN_UNUSED_RESULT; | 164 bool Open(const base::FilePath& path) WARN_UNUSED_RESULT; |
| 161 | 165 |
| 162 // Initializes the SQL connection for a temporary in-memory database. There | 166 // Initializes the SQL connection for a temporary in-memory database. There |
| 163 // will be no associated file on disk, and the initial database will be | 167 // will be no associated file on disk, and the initial database will be |
| 164 // empty. You can call this or Open. | 168 // empty. You can call this or Open. |
| 165 bool OpenInMemory() WARN_UNUSED_RESULT; | 169 bool OpenInMemory() WARN_UNUSED_RESULT; |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 // |true| if the connection was closed using RazeAndClose(). Used | 494 // |true| if the connection was closed using RazeAndClose(). Used |
| 491 // to enable diagnostics to distinguish calls to never-opened | 495 // to enable diagnostics to distinguish calls to never-opened |
| 492 // databases (incorrect use of the API) from calls to once-valid | 496 // databases (incorrect use of the API) from calls to once-valid |
| 493 // databases. | 497 // databases. |
| 494 bool poisoned_; | 498 bool poisoned_; |
| 495 | 499 |
| 496 // This object handles errors resulting from all forms of executing sqlite | 500 // This object handles errors resulting from all forms of executing sqlite |
| 497 // commands or statements. It can be null which means default handling. | 501 // commands or statements. It can be null which means default handling. |
| 498 scoped_ptr<ErrorDelegate> error_delegate_; | 502 scoped_ptr<ErrorDelegate> error_delegate_; |
| 499 | 503 |
| 500 // Auxiliary error-code histogram. | 504 // Prefix for auxiliary histograms. |
| 501 std::string error_histogram_name_; | 505 std::string histogram_prefix_; |
| 502 | 506 |
| 503 DISALLOW_COPY_AND_ASSIGN(Connection); | 507 DISALLOW_COPY_AND_ASSIGN(Connection); |
| 504 }; | 508 }; |
| 505 | 509 |
| 506 } // namespace sql | 510 } // namespace sql |
| 507 | 511 |
| 508 #endif // SQL_CONNECTION_H_ | 512 #endif // SQL_CONNECTION_H_ |
| OLD | NEW |