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..1582282957b7445fffc57c90b2943801084fb119 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. |
@@ -652,14 +655,11 @@ void HistoryBackend::InitImpl( |
db_->set_error_callback(base::Bind(&HistoryBackend::DatabaseErrorCallback, |
base::Unretained(this))); |
+ db_diagnostics_.clear(); |
sql::InitStatus status = db_->Init(history_name); |
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 +669,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 = |
sky
2016/08/02 13:27:21
You have similar code to this in chrome. Please ex
afakhry
2016/08/02 23:58:24
Yes, absolutely! Thanks.
However, The sql diagnos
sky
2016/08/03 15:19:30
How about sql/?
Also, style guide suggests out par
afakhry
2016/08/03 17:51:23
Yes, it's in sql/error_delegate_util.h.
Done for t
|
+ history_name.DirName().BaseName().AsUTF8Unsafe() + "/" + |
+ history_name.BaseName().AsUTF8Unsafe(); |
+ base::StringAppendF(&db_diagnostics_, "Corrupted file: %s\n", |
+ corrupted_file_name.c_str()); |
+ delegate_->NotifyProfileError(status, db_diagnostics_); |
db_.reset(); |
return; |
} |
@@ -2410,6 +2417,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 |