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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // Corrupt cases currently dominate, report them very infrequently. | 257 // Corrupt cases currently dominate, report them very infrequently. |
258 static const uint64 kCorruptReportsPerMillion = 10000; | 258 static const uint64 kCorruptReportsPerMillion = 10000; |
259 if (rand < kCorruptReportsPerMillion) | 259 if (rand < kCorruptReportsPerMillion && db->RegisterIntentToUpload()) |
sky
2015/10/16 15:07:24
Naming is hard, but looking at this code it isn't
Scott Hess - ex-Googler
2015/10/16 15:27:43
Previously it was more like ShouldReportError(), b
| |
260 ReportCorrupt(db, startup_kb); | 260 ReportCorrupt(db, startup_kb); |
261 } else if (error == SQLITE_READONLY) { | 261 } else if (error == SQLITE_READONLY) { |
262 // SQLITE_READONLY appears similar to SQLITE_CORRUPT - once it | 262 // SQLITE_READONLY appears similar to SQLITE_CORRUPT - once it |
263 // is seen, it is almost guaranteed to be seen again. | 263 // is seen, it is almost guaranteed to be seen again. |
264 reported = true; | 264 reported = true; |
265 | 265 |
266 if (rand < kReportsPerMillion) | 266 if (rand < kReportsPerMillion && db->RegisterIntentToUpload()) |
267 ReportError(db, extended_error); | 267 ReportError(db, extended_error); |
268 } else { | 268 } else { |
269 // Only set the flag when making a report. This should allow | 269 // Only set the flag when making a report. This should allow |
270 // later (potentially different) errors in a stream of errors to | 270 // later (potentially different) errors in a stream of errors to |
271 // be reported. | 271 // be reported. |
272 // | 272 // |
273 // TODO(shess): Would it be worthwile to audit for which cases | 273 // TODO(shess): Would it be worthwile to audit for which cases |
274 // want once-only handling? Sqlite.Error.Thumbnail shows | 274 // want once-only handling? Sqlite.Error.Thumbnail shows |
275 // CORRUPT and READONLY as almost 95% of all reports on these | 275 // CORRUPT and READONLY as almost 95% of all reports on these |
276 // channels, so probably easier to just harvest from the field. | 276 // channels, so probably easier to just harvest from the field. |
277 if (rand < kReportsPerMillion) { | 277 if (rand < kReportsPerMillion) { |
278 reported = true; | 278 reported = true; |
279 ReportError(db, extended_error); | 279 if (db->RegisterIntentToUpload()) |
280 ReportError(db, extended_error); | |
280 } | 281 } |
281 } | 282 } |
282 } | 283 } |
283 | 284 |
284 // NOTE(shess): Schema modifications must consider initial creation in | 285 // NOTE(shess): Schema modifications must consider initial creation in |
285 // |InitImpl()|, recovery in |RecoverDatabaseOrRaze()|, and history pruning in | 286 // |InitImpl()|, recovery in |RecoverDatabaseOrRaze()|, and history pruning in |
286 // |RetainDataForPageUrls()|. | 287 // |RetainDataForPageUrls()|. |
287 bool InitTables(sql::Connection* db) { | 288 bool InitTables(sql::Connection* db) { |
288 const char kIconMappingSql[] = | 289 const char kIconMappingSql[] = |
289 "CREATE TABLE IF NOT EXISTS icon_mapping" | 290 "CREATE TABLE IF NOT EXISTS icon_mapping" |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1378 meta_table_.SetVersionNumber(8); | 1379 meta_table_.SetVersionNumber(8); |
1379 meta_table_.SetCompatibleVersionNumber(std::min(8, kCompatibleVersionNumber)); | 1380 meta_table_.SetCompatibleVersionNumber(std::min(8, kCompatibleVersionNumber)); |
1380 return true; | 1381 return true; |
1381 } | 1382 } |
1382 | 1383 |
1383 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { | 1384 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { |
1384 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); | 1385 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); |
1385 } | 1386 } |
1386 | 1387 |
1387 } // namespace history | 1388 } // namespace history |
OLD | NEW |