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

Side by Side Diff: components/history/core/browser/history_backend.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_backend.h" 5 #include "components/history/core/browser/history_backend.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 DownloadDatabase (stores a list of downloads) 61 DownloadDatabase (stores a list of downloads)
62 VisitDatabase (stores a list of visits for the URLs) 62 VisitDatabase (stores a list of visits for the URLs)
63 VisitSegmentDatabase (stores groups of URLs for the most visited view). 63 VisitSegmentDatabase (stores groups of URLs for the most visited view).
64 64
65 ExpireHistoryBackend (manages deleting things older than 3 months) 65 ExpireHistoryBackend (manages deleting things older than 3 months)
66 */ 66 */
67 67
68 namespace history { 68 namespace history {
69 69
70 namespace { 70 namespace {
71
71 void RunUnlessCanceled( 72 void RunUnlessCanceled(
72 const base::Closure& closure, 73 const base::Closure& closure,
73 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled) { 74 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled) {
74 if (!is_canceled.Run()) 75 if (!is_canceled.Run())
75 closure.Run(); 76 closure.Run();
76 } 77 }
78
77 } // namespace 79 } // namespace
78 80
79 // How long we'll wait to do a commit, so that things are batched together. 81 // How long we'll wait to do a commit, so that things are batched together.
80 const int kCommitIntervalSeconds = 10; 82 const int kCommitIntervalSeconds = 10;
81 83
82 // The amount of time before we re-fetch the favicon. 84 // The amount of time before we re-fetch the favicon.
83 const int kFaviconRefetchDays = 7; 85 const int kFaviconRefetchDays = 7;
84 86
85 // The maximum number of items we'll allow in the redirect list before 87 // The maximum number of items we'll allow in the redirect list before
86 // deleting some. 88 // deleting some.
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 647
646 // History database. 648 // History database.
647 db_.reset(new HistoryDatabase( 649 db_.reset(new HistoryDatabase(
648 history_database_params.download_interrupt_reason_none, 650 history_database_params.download_interrupt_reason_none,
649 history_database_params.download_interrupt_reason_crash)); 651 history_database_params.download_interrupt_reason_crash));
650 652
651 // Unretained to avoid a ref loop with db_. 653 // Unretained to avoid a ref loop with db_.
652 db_->set_error_callback(base::Bind(&HistoryBackend::DatabaseErrorCallback, 654 db_->set_error_callback(base::Bind(&HistoryBackend::DatabaseErrorCallback,
653 base::Unretained(this))); 655 base::Unretained(this)));
654 656
657 db_diagnostics_.clear();
655 sql::InitStatus status = db_->Init(history_name); 658 sql::InitStatus status = db_->Init(history_name);
656 switch (status) { 659 switch (status) {
657 case sql::INIT_OK: 660 case sql::INIT_OK:
658 break; 661 break;
659 case sql::INIT_TOO_NEW:
660 delegate_->NotifyProfileError(status);
661 db_.reset();
662 return;
663 case sql::INIT_FAILURE: { 662 case sql::INIT_FAILURE: {
664 // A null db_ will cause all calls on this object to notice this error 663 // A null db_ will cause all calls on this object to notice this error
665 // and to not continue. If the error callback scheduled killing the 664 // and to not continue. If the error callback scheduled killing the
666 // database, the task it posted has not executed yet. Try killing the 665 // database, the task it posted has not executed yet. Try killing the
667 // database now before we close it. 666 // database now before we close it.
668 bool kill_db = scheduled_kill_db_; 667 bool kill_db = scheduled_kill_db_;
669 if (kill_db) 668 if (kill_db)
670 KillHistoryDatabase(); 669 KillHistoryDatabase();
671 UMA_HISTOGRAM_BOOLEAN("History.AttemptedToFixProfileError", kill_db); 670 UMA_HISTOGRAM_BOOLEAN("History.AttemptedToFixProfileError", kill_db);
672 delegate_->NotifyProfileError(status); 671 } // Falls through.
672 case sql::INIT_TOO_NEW: {
673 db_diagnostics_ += sql::GetCorruptFileDiagnosticsInfo(history_name);
674 delegate_->NotifyProfileError(status, db_diagnostics_);
673 db_.reset(); 675 db_.reset();
674 return; 676 return;
675 } 677 }
676 default: 678 default:
677 NOTREACHED(); 679 NOTREACHED();
678 } 680 }
679 681
680 // Fill the in-memory database and send it back to the history service on the 682 // Fill the in-memory database and send it back to the history service on the
681 // main thread. 683 // main thread.
682 { 684 {
(...skipping 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 // that we can delete all associated icons in the case of deleting an 2406 // that we can delete all associated icons in the case of deleting an
2405 // unvisited bookmarked URL. 2407 // unvisited bookmarked URL.
2406 if (visits.empty()) 2408 if (visits.empty())
2407 expirer_.DeleteURL(*i); // There are no more visits; nuke the URL. 2409 expirer_.DeleteURL(*i); // There are no more visits; nuke the URL.
2408 } 2410 }
2409 } 2411 }
2410 2412
2411 void HistoryBackend::DatabaseErrorCallback(int error, sql::Statement* stmt) { 2413 void HistoryBackend::DatabaseErrorCallback(int error, sql::Statement* stmt) {
2412 if (!scheduled_kill_db_ && sql::IsErrorCatastrophic(error)) { 2414 if (!scheduled_kill_db_ && sql::IsErrorCatastrophic(error)) {
2413 scheduled_kill_db_ = true; 2415 scheduled_kill_db_ = true;
2416
2417 db_diagnostics_ = db_->GetDiagnosticInfo(error, stmt);
2418
2414 // Don't just do the close/delete here, as we are being called by |db| and 2419 // Don't just do the close/delete here, as we are being called by |db| and
2415 // that seems dangerous. 2420 // that seems dangerous.
2416 // TODO(shess): Consider changing KillHistoryDatabase() to use 2421 // TODO(shess): Consider changing KillHistoryDatabase() to use
2417 // RazeAndClose(). Then it can be cleared immediately. 2422 // RazeAndClose(). Then it can be cleared immediately.
2418 task_runner_->PostTask( 2423 task_runner_->PostTask(
2419 FROM_HERE, base::Bind(&HistoryBackend::KillHistoryDatabase, this)); 2424 FROM_HERE, base::Bind(&HistoryBackend::KillHistoryDatabase, this));
2420 } 2425 }
2421 } 2426 }
2422 2427
2423 void HistoryBackend::KillHistoryDatabase() { 2428 void HistoryBackend::KillHistoryDatabase() {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 // transaction is currently open. 2629 // transaction is currently open.
2625 db_->CommitTransaction(); 2630 db_->CommitTransaction();
2626 db_->Vacuum(); 2631 db_->Vacuum();
2627 db_->BeginTransaction(); 2632 db_->BeginTransaction();
2628 db_->GetStartDate(&first_recorded_time_); 2633 db_->GetStartDate(&first_recorded_time_);
2629 2634
2630 return true; 2635 return true;
2631 } 2636 }
2632 2637
2633 } // namespace history 2638 } // namespace history
OLDNEW
« no previous file with comments | « components/history/core/browser/history_backend.h ('k') | components/history/core/browser/history_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698