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 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" | 5 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 DISALLOW_COPY_AND_ASSIGN(SqliteIntegrityTest); | 88 DISALLOW_COPY_AND_ASSIGN(SqliteIntegrityTest); |
89 }; | 89 }; |
90 | 90 |
91 // Uniquifier to use the sql::DiagnosticErrorDelegate template which | 91 // Uniquifier to use the sql::DiagnosticErrorDelegate template which |
92 // requires a static name() method. | 92 // requires a static name() method. |
93 template <size_t unique> | 93 template <size_t unique> |
94 class HistogramUniquifier { | 94 class HistogramUniquifier { |
95 public: | 95 public: |
96 static const char* name() { | 96 static const char* name() { |
97 const char* kHistogramNames[] = { | 97 const char* kHistogramNames[] = { |
98 "Sqlite.Cookie.Error", | |
99 "Sqlite.History.Error", | 98 "Sqlite.History.Error", |
100 "Sqlite.Thumbnail.Error", | 99 "Sqlite.Thumbnail.Error", |
101 "Sqlite.Text.Error", | 100 "Sqlite.Text.Error", |
102 "Sqlite.Web.Error" | 101 "Sqlite.Web.Error" |
103 }; | 102 }; |
104 return kHistogramNames[unique]; | 103 return kHistogramNames[unique]; |
105 } | 104 } |
106 }; | 105 }; |
107 | 106 |
108 } // namespace | 107 } // namespace |
109 | 108 |
110 sql::ErrorDelegate* GetErrorHandlerForCookieDb() { | 109 sql::ErrorDelegate* GetErrorHandlerForHistoryDb() { |
111 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<0> >(); | 110 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<0> >(); |
112 } | 111 } |
113 | 112 |
114 sql::ErrorDelegate* GetErrorHandlerForHistoryDb() { | 113 sql::ErrorDelegate* GetErrorHandlerForThumbnailDb() { |
115 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<1> >(); | 114 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<1> >(); |
116 } | 115 } |
117 | 116 |
118 sql::ErrorDelegate* GetErrorHandlerForThumbnailDb() { | 117 sql::ErrorDelegate* GetErrorHandlerForTextDb() { |
119 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<2> >(); | 118 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<2> >(); |
120 } | 119 } |
121 | 120 |
122 sql::ErrorDelegate* GetErrorHandlerForTextDb() { | 121 sql::ErrorDelegate* GetErrorHandlerForWebDb() { |
123 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<3> >(); | 122 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<3> >(); |
124 } | 123 } |
125 | 124 |
126 sql::ErrorDelegate* GetErrorHandlerForWebDb() { | |
127 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<4> >(); | |
128 } | |
129 | |
130 DiagnosticTest* MakeSqliteWebDbTest() { | 125 DiagnosticTest* MakeSqliteWebDbTest() { |
131 return new SqliteIntegrityTest(true, ASCIIToUTF16("Web DB"), | 126 return new SqliteIntegrityTest(true, ASCIIToUTF16("Web DB"), |
132 FilePath(chrome::kWebDataFilename)); | 127 FilePath(chrome::kWebDataFilename)); |
133 } | 128 } |
134 | 129 |
135 DiagnosticTest* MakeSqliteCookiesDbTest() { | 130 DiagnosticTest* MakeSqliteCookiesDbTest() { |
136 return new SqliteIntegrityTest(true, ASCIIToUTF16("Cookies DB"), | 131 return new SqliteIntegrityTest(true, ASCIIToUTF16("Cookies DB"), |
137 FilePath(chrome::kCookieFilename)); | 132 FilePath(chrome::kCookieFilename)); |
138 } | 133 } |
139 | 134 |
(...skipping 19 matching lines...) Expand all Loading... |
159 appcache_db); | 154 appcache_db); |
160 } | 155 } |
161 | 156 |
162 DiagnosticTest* MakeSqliteWebDatabaseTrackerDbTest() { | 157 DiagnosticTest* MakeSqliteWebDatabaseTrackerDbTest() { |
163 FilePath databases_dir(webkit_database::kDatabaseDirectoryName); | 158 FilePath databases_dir(webkit_database::kDatabaseDirectoryName); |
164 FilePath tracker_db = | 159 FilePath tracker_db = |
165 databases_dir.Append(webkit_database::kTrackerDatabaseFileName); | 160 databases_dir.Append(webkit_database::kTrackerDatabaseFileName); |
166 return new SqliteIntegrityTest(false, ASCIIToUTF16("DatabaseTracker DB"), | 161 return new SqliteIntegrityTest(false, ASCIIToUTF16("DatabaseTracker DB"), |
167 tracker_db); | 162 tracker_db); |
168 } | 163 } |
OLD | NEW |