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

Side by Side Diff: components/history/core/browser/history_database.cc

Issue 2107493002: Offer user to send feedback from profile error dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pkasting's & droger's Created 4 years, 4 months 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
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 "components/history/core/browser/history_database.h" 5 #include "components/history/core/browser/history_database.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 : DownloadDatabase(download_interrupt_reason_none, 49 : DownloadDatabase(download_interrupt_reason_none,
50 download_interrupt_reason_crash) { 50 download_interrupt_reason_crash) {
51 } 51 }
52 52
53 HistoryDatabase::~HistoryDatabase() { 53 HistoryDatabase::~HistoryDatabase() {
54 } 54 }
55 55
56 sql::InitStatus HistoryDatabase::Init(const base::FilePath& history_name) { 56 sql::InitStatus HistoryDatabase::Init(const base::FilePath& history_name) {
57 db_.set_histogram_tag("History"); 57 db_.set_histogram_tag("History");
58 58
59 // Set the exceptional sqlite error handler.
60 db_.set_error_callback(error_callback_);
61
62 // Set the database page size to something a little larger to give us 59 // Set the database page size to something a little larger to give us
63 // better performance (we're typically seek rather than bandwidth limited). 60 // better performance (we're typically seek rather than bandwidth limited).
64 // This only has an effect before any tables have been created, otherwise 61 // This only has an effect before any tables have been created, otherwise
65 // this is a NOP. Must be a power of 2 and a max of 8192. 62 // this is a NOP. Must be a power of 2 and a max of 8192.
66 db_.set_page_size(4096); 63 db_.set_page_size(4096);
67 64
68 // Set the cache size. The page size, plus a little extra, times this 65 // Set the cache size. The page size, plus a little extra, times this
69 // value, tells us how much memory the cache will use maximum. 66 // value, tells us how much memory the cache will use maximum.
70 // 1000 * 4kB = 4MB 67 // 1000 * 4kB = 4MB
71 // TODO(brettw) scale this value to the amount of available memory. 68 // TODO(brettw) scale this value to the amount of available memory.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 249
253 void HistoryDatabase::BeginTransaction() { 250 void HistoryDatabase::BeginTransaction() {
254 db_.BeginTransaction(); 251 db_.BeginTransaction();
255 } 252 }
256 253
257 void HistoryDatabase::CommitTransaction() { 254 void HistoryDatabase::CommitTransaction() {
258 db_.CommitTransaction(); 255 db_.CommitTransaction();
259 } 256 }
260 257
261 void HistoryDatabase::RollbackTransaction() { 258 void HistoryDatabase::RollbackTransaction() {
262 db_.RollbackTransaction(); 259 // If Init() returns with a failure status, the Transaction created there will
260 // be destructed and rolled back. HistoryBackend might try to kill the
261 // database after that, at which point it will try to roll back a non-existing
262 // transaction. This will crash on a DCHECK. So transaction_nesting() is
263 // checked first.
264 if (db_.transaction_nesting())
265 db_.RollbackTransaction();
263 } 266 }
264 267
265 bool HistoryDatabase::RecreateAllTablesButURL() { 268 bool HistoryDatabase::RecreateAllTablesButURL() {
266 if (!DropVisitTable()) 269 if (!DropVisitTable())
267 return false; 270 return false;
268 if (!InitVisitTable()) 271 if (!InitVisitTable())
269 return false; 272 return false;
270 273
271 if (!DropKeywordSearchTermsTable()) 274 if (!DropKeywordSearchTermsTable())
272 return false; 275 return false;
(...skipping 16 matching lines...) Expand all
289 } 292 }
290 293
291 void HistoryDatabase::TrimMemory(bool aggressively) { 294 void HistoryDatabase::TrimMemory(bool aggressively) {
292 db_.TrimMemory(aggressively); 295 db_.TrimMemory(aggressively);
293 } 296 }
294 297
295 bool HistoryDatabase::Raze() { 298 bool HistoryDatabase::Raze() {
296 return db_.Raze(); 299 return db_.Raze();
297 } 300 }
298 301
302 std::string HistoryDatabase::GetDiagnosticInfo(int extended_error,
303 sql::Statement* statement) {
304 return db_.GetDiagnosticInfo(extended_error, statement);
305 }
306
299 bool HistoryDatabase::SetSegmentID(VisitID visit_id, SegmentID segment_id) { 307 bool HistoryDatabase::SetSegmentID(VisitID visit_id, SegmentID segment_id) {
300 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, 308 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE,
301 "UPDATE visits SET segment_id = ? WHERE id = ?")); 309 "UPDATE visits SET segment_id = ? WHERE id = ?"));
302 s.BindInt64(0, segment_id); 310 s.BindInt64(0, segment_id);
303 s.BindInt64(1, visit_id); 311 s.BindInt64(1, visit_id);
304 DCHECK(db_.GetLastChangeCount() == 1); 312 DCHECK(db_.GetLastChangeCount() == 1);
305 313
306 return s.Run(); 314 return s.Run();
307 } 315 }
308 316
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 "SET visit_time = visit_time + 11644473600000000 " 545 "SET visit_time = visit_time + 11644473600000000 "
538 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);")); 546 "WHERE id IN (SELECT id FROM visits WHERE visit_time > 0);"));
539 ignore_result(db_.Execute( 547 ignore_result(db_.Execute(
540 "UPDATE segment_usage " 548 "UPDATE segment_usage "
541 "SET time_slot = time_slot + 11644473600000000 " 549 "SET time_slot = time_slot + 11644473600000000 "
542 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); 550 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"));
543 } 551 }
544 #endif 552 #endif
545 553
546 } // namespace history 554 } // namespace history
OLDNEW
« no previous file with comments | « components/history/core/browser/history_database.h ('k') | components/history/core/browser/history_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698