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

Side by Side Diff: chrome/browser/history/thumbnail_database.cc

Issue 104593010: AppCache: Run a quick integrity check on the sqlite database when opening. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed clang error Created 7 years 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 | sql/connection.h » ('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 "chrome/browser/history/thumbnail_database.h" 5 #include "chrome/browser/history/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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 base::StringAppendF(&debug_info, "SQLITE_CORRUPT, integrity_check:\n"); 133 base::StringAppendF(&debug_info, "SQLITE_CORRUPT, integrity_check:\n");
134 134
135 // Check files up to 8M to keep things from blocking too long. 135 // Check files up to 8M to keep things from blocking too long.
136 const size_t kMaxIntegrityCheckSize = 8192; 136 const size_t kMaxIntegrityCheckSize = 8192;
137 if (startup_kb > kMaxIntegrityCheckSize) { 137 if (startup_kb > kMaxIntegrityCheckSize) {
138 base::StringAppendF(&debug_info, "too big %" PRIuS "\n", startup_kb); 138 base::StringAppendF(&debug_info, "too big %" PRIuS "\n", startup_kb);
139 } else { 139 } else {
140 std::vector<std::string> messages; 140 std::vector<std::string> messages;
141 141
142 const base::TimeTicks before = base::TimeTicks::Now(); 142 const base::TimeTicks before = base::TimeTicks::Now();
143 db->IntegrityCheck(&messages); 143 db->FullIntegrityCheck(&messages);
144 base::StringAppendF(&debug_info, "# %" PRIx64 " ms, %" PRIuS " records\n", 144 base::StringAppendF(&debug_info, "# %" PRIx64 " ms, %" PRIuS " records\n",
145 (base::TimeTicks::Now() - before).InMilliseconds(), 145 (base::TimeTicks::Now() - before).InMilliseconds(),
146 messages.size()); 146 messages.size());
147 147
148 // SQLite returns up to 100 messages by default, trim deeper to 148 // SQLite returns up to 100 messages by default, trim deeper to
149 // keep close to the 2000-character size limit for dumping. 149 // keep close to the 2000-character size limit for dumping.
150 // 150 //
151 // TODO(shess): If the first 20 tend to be actionable, test if 151 // TODO(shess): If the first 20 tend to be actionable, test if
152 // passing the count to integrity_check makes it exit earlier. In 152 // passing the count to integrity_check makes it exit earlier. In
153 // that case it may be possible to greatly ease the size 153 // that case it may be possible to greatly ease the size
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 meta_table_.SetVersionNumber(7); 1427 meta_table_.SetVersionNumber(7);
1428 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber)); 1428 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber));
1429 return true; 1429 return true;
1430 } 1430 }
1431 1431
1432 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { 1432 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() {
1433 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); 1433 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons");
1434 } 1434 }
1435 1435
1436 } // namespace history 1436 } // namespace history
OLDNEW
« no previous file with comments | « no previous file | sql/connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698