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

Side by Side Diff: trunk/src/sql/connection.cc

Issue 14555006: Revert 197147 "Deeper histogram for SQLITE_IOERR." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 7 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 | « no previous file | trunk/src/tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "sql/connection.h" 5 #include "sql/connection.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 else 707 else
708 open_statements_.erase(i); 708 open_statements_.erase(i);
709 } 709 }
710 710
711 int Connection::OnSqliteError(int err, sql::Statement *stmt) { 711 int Connection::OnSqliteError(int err, sql::Statement *stmt) {
712 // Strip extended error codes. 712 // Strip extended error codes.
713 int base_err = err&0xff; 713 int base_err = err&0xff;
714 714
715 static size_t kSqliteErrorMax = 50; 715 static size_t kSqliteErrorMax = 50;
716 UMA_HISTOGRAM_ENUMERATION("Sqlite.Error", base_err, kSqliteErrorMax); 716 UMA_HISTOGRAM_ENUMERATION("Sqlite.Error", base_err, kSqliteErrorMax);
717 if (base_err == SQLITE_IOERR) {
718 // TODO(shess): Consider folding the IOERR range into the main
719 // histogram directly. Perhaps 30..49? The downside risk would
720 // be that SQLite core adds a bunch of codes and this becomes a
721 // complicated mapping.
722 static size_t kSqliteIOErrorMax = 20;
723 UMA_HISTOGRAM_ENUMERATION("Sqlite.Error.IOERR", err>>8, kSqliteIOErrorMax);
724 }
725
726 if (!error_histogram_name_.empty()) { 717 if (!error_histogram_name_.empty()) {
727 // TODO(shess): The histogram macros create a bit of static 718 // TODO(shess): The histogram macros create a bit of static
728 // storage for caching the histogram object. Since SQLite is 719 // storage for caching the histogram object. Since SQLite is
729 // being used for I/O, generally without error, this code 720 // being used for I/O, generally without error, this code
730 // shouldn't execute often enough for such caching to be crucial. 721 // shouldn't execute often enough for such caching to be crucial.
731 // If it becomes an issue, the object could be cached alongside 722 // If it becomes an issue, the object could be cached alongside
732 // error_histogram_name_. 723 // error_histogram_name_.
733 base::HistogramBase* histogram = 724 base::HistogramBase* histogram =
734 base::LinearHistogram::FactoryGet( 725 base::LinearHistogram::FactoryGet(
735 error_histogram_name_, 1, kSqliteErrorMax, kSqliteErrorMax + 1, 726 error_histogram_name_, 1, kSqliteErrorMax, kSqliteErrorMax + 1,
736 base::HistogramBase::kUmaTargetedHistogramFlag); 727 base::HistogramBase::kUmaTargetedHistogramFlag);
737 if (histogram) 728 if (histogram)
738 histogram->Add(base_err); 729 histogram->Add(base_err);
739 } 730 }
740 731
741 // Always log the error. 732 // Always log the error.
742 LOG(ERROR) << "sqlite error " << err 733 LOG(ERROR) << "sqlite error " << err
743 << ", errno " << GetLastErrno() 734 << ", errno " << GetLastErrno()
744 << ": " << GetErrorMessage(); 735 << ": " << GetErrorMessage();
745 736
746 if (error_delegate_.get()) 737 if (error_delegate_.get())
747 return error_delegate_->OnError(err, this, stmt); 738 return error_delegate_->OnError(err, this, stmt);
748 739
749 // The default handling is to assert on debug and to ignore on release. 740 // The default handling is to assert on debug and to ignore on release.
750 DLOG(FATAL) << GetErrorMessage(); 741 DLOG(FATAL) << GetErrorMessage();
751 return err; 742 return err;
752 } 743 }
753 744
754 } // namespace sql 745 } // namespace sql
OLDNEW
« no previous file with comments | « no previous file | trunk/src/tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698