Chromium Code Reviews| Index: sql/connection.cc |
| diff --git a/sql/connection.cc b/sql/connection.cc |
| index 29708e41164a95376d4ae7deb392214647b04e63..760a076aac81b1d3fe7c6b7e4e49b2ad1fcf82e4 100644 |
| --- a/sql/connection.cc |
| +++ b/sql/connection.cc |
| @@ -708,6 +708,25 @@ void Connection::StatementRefDeleted(StatementRef* ref) { |
| open_statements_.erase(i); |
| } |
| +void Connection::AddLinearHistogram(const std::string& suffix, |
|
jar (doing other things)
2013/05/07 23:46:41
It is also tempting to use the sparse histogram to
|
| + size_t sample, size_t sample_max) const { |
|
jar (doing other things)
2013/05/07 23:46:41
nit: one arg per line
Scott Hess - ex-Googler
2013/05/08 19:56:18
Done.
|
| + if (!histogram_prefix_.empty()) { |
|
jar (doing other things)
2013/05/07 23:46:41
nit: personal preference. Early return on empty()
Scott Hess - ex-Googler
2013/05/08 19:56:18
Done. I had pulled it out of the earlier context
|
| + // TODO(shess): The histogram macros create a bit of static |
| + // storage for caching the histogram object. Since SQLite is |
| + // being used for I/O, generally without error, this code |
| + // shouldn't execute often enough for such caching to be crucial. |
| + // If it becomes an issue, the object could be cached alongside |
| + // histogram_prefix_. |
| + std::string full_histogram_name = histogram_prefix_ + suffix; |
| + base::HistogramBase* histogram = |
| + base::LinearHistogram::FactoryGet( |
| + full_histogram_name, 1, sample_max, sample_max + 1, |
| + base::HistogramBase::kUmaTargetedHistogramFlag); |
| + if (histogram) |
| + histogram->Add(sample); |
| + } |
| +} |
| + |
| int Connection::OnSqliteError(int err, sql::Statement *stmt) { |
| // Strip extended error codes. |
| int base_err = err&0xff; |
| @@ -723,20 +742,7 @@ int Connection::OnSqliteError(int err, sql::Statement *stmt) { |
| UMA_HISTOGRAM_ENUMERATION("Sqlite.Error.IOERR", err>>8, kSqliteIOErrorMax); |
| } |
| - if (!error_histogram_name_.empty()) { |
| - // TODO(shess): The histogram macros create a bit of static |
| - // storage for caching the histogram object. Since SQLite is |
| - // being used for I/O, generally without error, this code |
| - // shouldn't execute often enough for such caching to be crucial. |
| - // If it becomes an issue, the object could be cached alongside |
| - // error_histogram_name_. |
| - base::HistogramBase* histogram = |
| - base::LinearHistogram::FactoryGet( |
| - error_histogram_name_, 1, kSqliteErrorMax, kSqliteErrorMax + 1, |
| - base::HistogramBase::kUmaTargetedHistogramFlag); |
| - if (histogram) |
| - histogram->Add(base_err); |
| - } |
| + AddLinearHistogram(".Error", base_err, kSqliteErrorMax); |
| // Always log the error. |
| LOG(ERROR) << "sqlite error " << err |