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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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", | 98 "Sqlite.Cookie.Error", |
99 "Sqlite.History.Error", | 99 "Sqlite.History.Error", |
100 "Sqlite.Thumbnail.Error", | 100 "Sqlite.Thumbnail.Error", |
101 "Sqlite.Text.Error", | 101 "Sqlite.Text.Error", |
102 "Sqlite.Web.Error" | 102 "Sqlite.Web.Error", |
| 103 "Sqlite.HQPCache.Error" |
103 }; | 104 }; |
104 return kHistogramNames[unique]; | 105 return kHistogramNames[unique]; |
105 } | 106 } |
106 }; | 107 }; |
107 | 108 |
108 } // namespace | 109 } // namespace |
109 | 110 |
110 sql::ErrorDelegate* GetErrorHandlerForCookieDb() { | 111 sql::ErrorDelegate* GetErrorHandlerForCookieDb() { |
111 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<0> >(); | 112 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<0> >(); |
112 } | 113 } |
113 | 114 |
114 sql::ErrorDelegate* GetErrorHandlerForHistoryDb() { | 115 sql::ErrorDelegate* GetErrorHandlerForHistoryDb() { |
115 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<1> >(); | 116 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<1> >(); |
116 } | 117 } |
117 | 118 |
118 sql::ErrorDelegate* GetErrorHandlerForThumbnailDb() { | 119 sql::ErrorDelegate* GetErrorHandlerForThumbnailDb() { |
119 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<2> >(); | 120 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<2> >(); |
120 } | 121 } |
121 | 122 |
122 sql::ErrorDelegate* GetErrorHandlerForTextDb() { | 123 sql::ErrorDelegate* GetErrorHandlerForTextDb() { |
123 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<3> >(); | 124 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<3> >(); |
124 } | 125 } |
125 | 126 |
126 sql::ErrorDelegate* GetErrorHandlerForWebDb() { | 127 sql::ErrorDelegate* GetErrorHandlerForWebDb() { |
127 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<4> >(); | 128 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<4> >(); |
128 } | 129 } |
129 | 130 |
| 131 sql::ErrorDelegate* GetErrorHandlerForHQPCacheDb() { |
| 132 return new sql::DiagnosticErrorDelegate<HistogramUniquifier<5> >(); |
| 133 } |
| 134 |
130 DiagnosticTest* MakeSqliteWebDbTest() { | 135 DiagnosticTest* MakeSqliteWebDbTest() { |
131 return new SqliteIntegrityTest(true, ASCIIToUTF16("Web DB"), | 136 return new SqliteIntegrityTest(true, ASCIIToUTF16("Web DB"), |
132 FilePath(chrome::kWebDataFilename)); | 137 FilePath(chrome::kWebDataFilename)); |
133 } | 138 } |
134 | 139 |
135 DiagnosticTest* MakeSqliteCookiesDbTest() { | 140 DiagnosticTest* MakeSqliteCookiesDbTest() { |
136 return new SqliteIntegrityTest(true, ASCIIToUTF16("Cookies DB"), | 141 return new SqliteIntegrityTest(true, ASCIIToUTF16("Cookies DB"), |
137 FilePath(chrome::kCookieFilename)); | 142 FilePath(chrome::kCookieFilename)); |
138 } | 143 } |
139 | 144 |
140 DiagnosticTest* MakeSqliteHistoryDbTest() { | 145 DiagnosticTest* MakeSqliteHistoryDbTest() { |
141 return new SqliteIntegrityTest(true, ASCIIToUTF16("History DB"), | 146 return new SqliteIntegrityTest(true, ASCIIToUTF16("History DB"), |
142 FilePath(chrome::kHistoryFilename)); | 147 FilePath(chrome::kHistoryFilename)); |
143 } | 148 } |
144 | 149 |
145 DiagnosticTest* MakeSqliteArchivedHistoryDbTest() { | 150 DiagnosticTest* MakeSqliteArchivedHistoryDbTest() { |
146 return new SqliteIntegrityTest(false, ASCIIToUTF16("Archived History DB"), | 151 return new SqliteIntegrityTest(false, ASCIIToUTF16("Archived History DB"), |
147 FilePath(chrome::kArchivedHistoryFilename)); | 152 FilePath(chrome::kArchivedHistoryFilename)); |
148 } | 153 } |
149 | 154 |
150 DiagnosticTest* MakeSqliteThumbnailsDbTest() { | 155 DiagnosticTest* MakeSqliteThumbnailsDbTest() { |
151 return new SqliteIntegrityTest(false, ASCIIToUTF16("Thumbnails DB"), | 156 return new SqliteIntegrityTest(false, ASCIIToUTF16("Thumbnails DB"), |
152 FilePath(chrome::kThumbnailsFilename)); | 157 FilePath(chrome::kThumbnailsFilename)); |
153 } | 158 } |
154 | 159 |
| 160 DiagnosticTest* MakeSqliteHQPCacheDbTest() { |
| 161 return new SqliteIntegrityTest(false, |
| 162 ASCIIToUTF16("History Provider Cache DB"), |
| 163 FilePath(chrome::kHQPCacheDBFilename)); |
| 164 } |
| 165 |
155 DiagnosticTest* MakeSqliteAppCacheDbTest() { | 166 DiagnosticTest* MakeSqliteAppCacheDbTest() { |
156 FilePath appcache_dir(content::kAppCacheDirname); | 167 FilePath appcache_dir(content::kAppCacheDirname); |
157 FilePath appcache_db = appcache_dir.Append(appcache::kAppCacheDatabaseName); | 168 FilePath appcache_db = appcache_dir.Append(appcache::kAppCacheDatabaseName); |
158 return new SqliteIntegrityTest(false, ASCIIToUTF16("AppCache DB"), | 169 return new SqliteIntegrityTest(false, ASCIIToUTF16("AppCache DB"), |
159 appcache_db); | 170 appcache_db); |
160 } | 171 } |
161 | 172 |
162 DiagnosticTest* MakeSqliteWebDatabaseTrackerDbTest() { | 173 DiagnosticTest* MakeSqliteWebDatabaseTrackerDbTest() { |
163 FilePath databases_dir(webkit_database::kDatabaseDirectoryName); | 174 FilePath databases_dir(webkit_database::kDatabaseDirectoryName); |
164 FilePath tracker_db = | 175 FilePath tracker_db = |
165 databases_dir.Append(webkit_database::kTrackerDatabaseFileName); | 176 databases_dir.Append(webkit_database::kTrackerDatabaseFileName); |
166 return new SqliteIntegrityTest(false, ASCIIToUTF16("DatabaseTracker DB"), | 177 return new SqliteIntegrityTest(false, ASCIIToUTF16("DatabaseTracker DB"), |
167 tracker_db); | 178 tracker_db); |
168 } | 179 } |
OLD | NEW |