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 linear UMA histogram sample under | |
157 // |histogram_prefix_|+|suffix|. If |histogram_prefix_| is empty, | |
158 // no histogram is recorded. | |
159 void AddLinearHistogram(const std::string& suffix, | |
160 size_t sample, size_t sample_max) const; | |
jar (doing other things)
2013/05/07 23:46:41
nit: one arg per line when wrapping declarations a
Scott Hess - ex-Googler
2013/05/08 19:56:18
Done.
| |
161 | |
156 // Initialization ------------------------------------------------------------ | 162 // Initialization ------------------------------------------------------------ |
157 | 163 |
158 // Initializes the SQL connection for the given file, returning true if the | 164 // Initializes the SQL connection for the given file, returning true if the |
159 // file could be opened. You can call this or OpenInMemory. | 165 // file could be opened. You can call this or OpenInMemory. |
160 bool Open(const base::FilePath& path) WARN_UNUSED_RESULT; | 166 bool Open(const base::FilePath& path) WARN_UNUSED_RESULT; |
161 | 167 |
162 // Initializes the SQL connection for a temporary in-memory database. There | 168 // 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 | 169 // will be no associated file on disk, and the initial database will be |
164 // empty. You can call this or Open. | 170 // empty. You can call this or Open. |
165 bool OpenInMemory() WARN_UNUSED_RESULT; | 171 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 | 496 // |true| if the connection was closed using RazeAndClose(). Used |
491 // to enable diagnostics to distinguish calls to never-opened | 497 // to enable diagnostics to distinguish calls to never-opened |
492 // databases (incorrect use of the API) from calls to once-valid | 498 // databases (incorrect use of the API) from calls to once-valid |
493 // databases. | 499 // databases. |
494 bool poisoned_; | 500 bool poisoned_; |
495 | 501 |
496 // This object handles errors resulting from all forms of executing sqlite | 502 // This object handles errors resulting from all forms of executing sqlite |
497 // commands or statements. It can be null which means default handling. | 503 // commands or statements. It can be null which means default handling. |
498 scoped_ptr<ErrorDelegate> error_delegate_; | 504 scoped_ptr<ErrorDelegate> error_delegate_; |
499 | 505 |
500 // Auxiliary error-code histogram. | 506 // Prefix for auxiliary histograms. |
501 std::string error_histogram_name_; | 507 std::string histogram_prefix_; |
502 | 508 |
503 DISALLOW_COPY_AND_ASSIGN(Connection); | 509 DISALLOW_COPY_AND_ASSIGN(Connection); |
504 }; | 510 }; |
505 | 511 |
506 } // namespace sql | 512 } // namespace sql |
507 | 513 |
508 #endif // SQL_CONNECTION_H_ | 514 #endif // SQL_CONNECTION_H_ |
OLD | NEW |