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

Unified Diff: components/webdata/common/web_database_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: wchar_t Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: components/webdata/common/web_database_backend.cc
diff --git a/components/webdata/common/web_database_backend.cc b/components/webdata/common/web_database_backend.cc
index 7cb343e62f02e5a76ba03a4fff2f999a07a33491..cbd8ac7ce3c29127c7271e171a0d74f4ac7495b2 100644
--- a/components/webdata/common/web_database_backend.cc
+++ b/components/webdata/common/web_database_backend.cc
@@ -4,6 +4,7 @@
#include "components/webdata/common/web_database_backend.h"
+#include <algorithm>
#include <utility>
#include "base/bind.h"
@@ -35,7 +36,7 @@ void WebDatabaseBackend::AddTable(std::unique_ptr<WebDatabaseTable> table) {
void WebDatabaseBackend::InitDatabase() {
LoadDatabaseIfNecessary();
if (delegate_) {
- delegate_->DBLoaded(init_status_);
+ delegate_->DBLoaded(init_status_, db_diagnostics_);
}
}
@@ -46,14 +47,29 @@ sql::InitStatus WebDatabaseBackend::LoadDatabaseIfNecessary() {
init_complete_ = true;
db_.reset(new WebDatabase());
- for (ScopedVector<WebDatabaseTable>::iterator it = tables_.begin();
- it != tables_.end(); ++it) {
- db_->AddTable(*it);
- }
+ for (const auto& table : tables_)
+ db_->AddTable(table);
init_status_ = db_->Init(db_path_);
if (init_status_ != sql::INIT_OK) {
LOG(ERROR) << "Cannot initialize the web database: " << init_status_;
+ db_diagnostics_ = db_->GetDiagnosticMap();
+ std::vector<base::FilePath::StringType> path_components;
+ db_path_.GetComponents(&path_components);
+
+#if defined(OS_WIN)
+ const base::FilePath::StringType default_dir(L"Default");
+#else
+ const base::FilePath::StringType default_dir("Default");
+#endif // defined(OS_WIN)
+
+ auto itr =
+ std::find(path_components.begin(), path_components.end(), default_dir);
+ const std::string corrupted_file_name =
+ db_path_.BaseName().AsUTF8Unsafe() + (itr != path_components.end()
+ ? " [Default profile]"
+ : " [User profile]");
+ db_diagnostics_["Corrupted file"] = corrupted_file_name;
db_.reset(NULL);
return init_status_;
}

Powered by Google App Engine
This is Rietveld 408576698