Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Side by Side Diff: sql/error_delegate_util.h

Issue 11141012: Move ErrorDelegate to its own file and add static utility functions to ErrorDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win build Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sql/diagnostic_error_delegate.h ('k') | sql/error_delegate_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SQL_ERROR_DELEGATE_UTIL_H_
6 #define SQL_ERROR_DELEGATE_UTIL_H_
7
8 #include "base/metrics/histogram.h"
9 #include "sql/connection.h"
10 #include "sql/sql_export.h"
11
12 namespace sql {
13
14 // Returns true if it is highly unlikely that the database can recover from
15 // |error|.
16 SQL_EXPORT bool IsErrorCatastrophic(int error);
17
18 // Log error in console in debug mode and generate a UMA histogram in release
19 // mode for |error| for |UniqueT::name()|.
20 // This function is templated because histograms need to be singletons. That is
21 // why they are always static at the function scope. The template parameter
22 // makes the compiler create unique functions that don't share the same static
23 // variable.
24 template <class UniqueT>
25 void LogAndRecordErrorInHistogram(int error,
26 sql::Connection* connection) {
27 LOG(ERROR) << "sqlite error " << error
28 << ", errno " << connection->GetLastErrno()
29 << ": " << connection->GetErrorMessage();
30
31 // Trim off the extended error codes.
32 error &= 0xff;
33
34 // The histogram values from sqlite result codes currently go from 1 to 26
35 // but 50 gives them room to grow.
36 UMA_HISTOGRAM_ENUMERATION(UniqueT::name(), error, 50);
37 }
38
39 } // namespace sql
40
41 #endif // SQL_ERROR_DELEGATE_UTIL_H_
OLDNEW
« no previous file with comments | « sql/diagnostic_error_delegate.h ('k') | sql/error_delegate_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698