Chromium Code Reviews| Index: components/history/core/browser/history_backend.cc |
| diff --git a/components/history/core/browser/history_backend.cc b/components/history/core/browser/history_backend.cc |
| index 4ca3a34a6b09f9fc88bc24bf17be752a1d70a8b6..1dbb34917e176891583c43009949c5e4b55b5691 100644 |
| --- a/components/history/core/browser/history_backend.cc |
| +++ b/components/history/core/browser/history_backend.cc |
| @@ -22,6 +22,7 @@ |
| #include "base/sequenced_task_runner.h" |
| #include "base/single_thread_task_runner.h" |
| #include "base/strings/string_util.h" |
| +#include "base/strings/stringprintf.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/time/time.h" |
| #include "build/build_config.h" |
| @@ -68,12 +69,14 @@ using base::TimeTicks; |
| namespace history { |
| namespace { |
| + |
| void RunUnlessCanceled( |
| const base::Closure& closure, |
| const base::CancelableTaskTracker::IsCanceledCallback& is_canceled) { |
| if (!is_canceled.Run()) |
| closure.Run(); |
| } |
| + |
| } // namespace |
| // How long we'll wait to do a commit, so that things are batched together. |
| @@ -656,10 +659,6 @@ void HistoryBackend::InitImpl( |
| switch (status) { |
| case sql::INIT_OK: |
| break; |
| - case sql::INIT_TOO_NEW: |
| - delegate_->NotifyProfileError(status); |
| - db_.reset(); |
| - return; |
| case sql::INIT_FAILURE: { |
| // A null db_ will cause all calls on this object to notice this error |
| // and to not continue. If the error callback scheduled killing the |
| @@ -669,7 +668,14 @@ void HistoryBackend::InitImpl( |
| if (kill_db) |
| KillHistoryDatabase(); |
| UMA_HISTOGRAM_BOOLEAN("History.AttemptedToFixProfileError", kill_db); |
| - delegate_->NotifyProfileError(status); |
| + } // Falls through. |
| + case sql::INIT_TOO_NEW: { |
| + const std::string corrupted_file_name = |
| + history_name.DirName().BaseName().AsUTF8Unsafe() + "/" + |
| + history_name.BaseName().AsUTF8Unsafe(); |
|
sky
2016/07/18 21:06:01
Why are you building the name like this and not us
afakhry
2016/07/26 23:33:47
shess@, michaeln@ and I have agreed to not use the
sky
2016/07/26 23:47:50
Might the user want to try removing the file? In w
|
| + base::StringAppendF(&db_diagnostics_, "Corrupted file: %s\n", |
|
sky
2016/07/18 21:06:01
If we're going to show this to users, which it app
afakhry
2016/07/26 23:33:47
Please take a look at this screenshot: https://dri
|
| + corrupted_file_name.c_str()); |
| + delegate_->NotifyProfileError(status, db_diagnostics_); |
| db_.reset(); |
| return; |
| } |
| @@ -2410,6 +2416,9 @@ void HistoryBackend::URLsNoLongerBookmarked(const std::set<GURL>& urls) { |
| void HistoryBackend::DatabaseErrorCallback(int error, sql::Statement* stmt) { |
| if (!scheduled_kill_db_ && sql::IsErrorCatastrophic(error)) { |
| scheduled_kill_db_ = true; |
| + |
| + db_diagnostics_ = db_->GetDiagnosticInfo(error, stmt); |
| + |
| // Don't just do the close/delete here, as we are being called by |db| and |
| // that seems dangerous. |
| // TODO(shess): Consider changing KillHistoryDatabase() to use |