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

Unified Diff: components/password_manager/core/browser/login_database.cc

Issue 838453003: Open the LoginDatabase on the DB thread, not the UI thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac namespace fixes. Created 5 years, 11 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/password_manager/core/browser/login_database.cc
diff --git a/components/password_manager/core/browser/login_database.cc b/components/password_manager/core/browser/login_database.cc
index c769481f532e512111f025245528ba05d1549e89..0cf252c1089f981c70d7745301254040013406c8 100644
--- a/components/password_manager/core/browser/login_database.cc
+++ b/components/password_manager/core/browser/login_database.cc
@@ -154,6 +154,9 @@ void LogTimesUsedStat(const std::string& name, int sample) {
LogDynamicUMAStat(name, sample, 0, 100, 10);
}
+// When set, LoginDatabase::Init() on any instance will artificially fail.
+bool g_simulate_init_failure_for_testing = false;
+
} // namespace
LoginDatabase::LoginDatabase() {
@@ -163,6 +166,9 @@ LoginDatabase::~LoginDatabase() {
}
bool LoginDatabase::Init(const base::FilePath& db_path) {
+ if (g_simulate_init_failure_for_testing)
+ return false;
+
// Set pragmas for a small, private database (based on WebDatabase).
db_.set_page_size(2048);
db_.set_cache_size(32);
@@ -440,6 +446,11 @@ void LoginDatabase::ReportMetrics(const std::string& sync_username,
4);
}
+// static
+void LoginDatabase::set_simulate_init_failure_for_testing(bool fail) {
+ g_simulate_init_failure_for_testing = fail;
+}
+
PasswordStoreChangeList LoginDatabase::AddLogin(const PasswordForm& form) {
PasswordStoreChangeList list;
if (!DoesMatchConstraints(form))

Powered by Google App Engine
This is Rietveld 408576698