Chromium Code Reviews| 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 "components/history/core/browser/thumbnail_database.h" | 5 #include "components/history/core/browser/thumbnail_database.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 if (reported) | 247 if (reported) |
| 248 return; | 248 return; |
| 249 | 249 |
| 250 uint64 rand = base::RandGenerator(1000000); | 250 uint64 rand = base::RandGenerator(1000000); |
| 251 if (error == SQLITE_CORRUPT) { | 251 if (error == SQLITE_CORRUPT) { |
| 252 // Once the database is known to be corrupt, it will generate a | 252 // Once the database is known to be corrupt, it will generate a |
| 253 // stream of errors until someone fixes it, so give one chance. | 253 // stream of errors until someone fixes it, so give one chance. |
| 254 // Set first in case of errors in generating the report. | 254 // Set first in case of errors in generating the report. |
| 255 reported = true; | 255 reported = true; |
| 256 | 256 |
| 257 if (!db->ShouldUploadDiagnosticDump()) | |
| 258 return; | |
|
pkotwicz
2015/10/15 18:02:29
Nit - I think that this is slightly clearer:
if (
Scott Hess - ex-Googler
2015/10/15 21:12:20
OK, I pulled all of these to just before the Repor
| |
| 259 | |
| 257 // Corrupt cases currently dominate, report them very infrequently. | 260 // Corrupt cases currently dominate, report them very infrequently. |
| 258 static const uint64 kCorruptReportsPerMillion = 10000; | 261 static const uint64 kCorruptReportsPerMillion = 10000; |
| 259 if (rand < kCorruptReportsPerMillion) | 262 if (rand < kCorruptReportsPerMillion) |
| 260 ReportCorrupt(db, startup_kb); | 263 ReportCorrupt(db, startup_kb); |
| 261 } else if (error == SQLITE_READONLY) { | 264 } else if (error == SQLITE_READONLY) { |
| 262 // SQLITE_READONLY appears similar to SQLITE_CORRUPT - once it | 265 // SQLITE_READONLY appears similar to SQLITE_CORRUPT - once it |
| 263 // is seen, it is almost guaranteed to be seen again. | 266 // is seen, it is almost guaranteed to be seen again. |
| 264 reported = true; | 267 reported = true; |
| 265 | 268 |
| 269 if (!db->ShouldUploadDiagnosticDump()) | |
| 270 return; | |
| 271 | |
| 266 if (rand < kReportsPerMillion) | 272 if (rand < kReportsPerMillion) |
| 267 ReportError(db, extended_error); | 273 ReportError(db, extended_error); |
| 268 } else { | 274 } else { |
| 269 // Only set the flag when making a report. This should allow | 275 // Only set the flag when making a report. This should allow |
| 270 // later (potentially different) errors in a stream of errors to | 276 // later (potentially different) errors in a stream of errors to |
| 271 // be reported. | 277 // be reported. |
| 272 // | 278 // |
| 273 // TODO(shess): Would it be worthwile to audit for which cases | 279 // TODO(shess): Would it be worthwile to audit for which cases |
| 274 // want once-only handling? Sqlite.Error.Thumbnail shows | 280 // want once-only handling? Sqlite.Error.Thumbnail shows |
| 275 // CORRUPT and READONLY as almost 95% of all reports on these | 281 // CORRUPT and READONLY as almost 95% of all reports on these |
| 276 // channels, so probably easier to just harvest from the field. | 282 // channels, so probably easier to just harvest from the field. |
| 277 if (rand < kReportsPerMillion) { | 283 if (rand < kReportsPerMillion) { |
| 278 reported = true; | 284 reported = true; |
| 285 if (!db->ShouldUploadDiagnosticDump()) | |
| 286 return; | |
| 279 ReportError(db, extended_error); | 287 ReportError(db, extended_error); |
| 280 } | 288 } |
| 281 } | 289 } |
| 282 } | 290 } |
| 283 | 291 |
| 284 // NOTE(shess): Schema modifications must consider initial creation in | 292 // NOTE(shess): Schema modifications must consider initial creation in |
| 285 // |InitImpl()|, recovery in |RecoverDatabaseOrRaze()|, and history pruning in | 293 // |InitImpl()|, recovery in |RecoverDatabaseOrRaze()|, and history pruning in |
| 286 // |RetainDataForPageUrls()|. | 294 // |RetainDataForPageUrls()|. |
| 287 bool InitTables(sql::Connection* db) { | 295 bool InitTables(sql::Connection* db) { |
| 288 const char kIconMappingSql[] = | 296 const char kIconMappingSql[] = |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1378 meta_table_.SetVersionNumber(8); | 1386 meta_table_.SetVersionNumber(8); |
| 1379 meta_table_.SetCompatibleVersionNumber(std::min(8, kCompatibleVersionNumber)); | 1387 meta_table_.SetCompatibleVersionNumber(std::min(8, kCompatibleVersionNumber)); |
| 1380 return true; | 1388 return true; |
| 1381 } | 1389 } |
| 1382 | 1390 |
| 1383 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { | 1391 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { |
| 1384 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); | 1392 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); |
| 1385 } | 1393 } |
| 1386 | 1394 |
| 1387 } // namespace history | 1395 } // namespace history |
| OLD | NEW |