summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralbertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-14 15:14:24 +0000
committeralbertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-14 15:14:24 +0000
commitdd34de09bf66de5ec57686a76de7120b748c32e2 (patch)
tree30b19e5e79952b5113182b82cf8d7b834db80cc2
parent65927ef362b19674fa52541609e339752349042f (diff)
downloadchromium_src-dd34de09bf66de5ec57686a76de7120b748c32e2.zip
chromium_src-dd34de09bf66de5ec57686a76de7120b748c32e2.tar.gz
chromium_src-dd34de09bf66de5ec57686a76de7120b748c32e2.tar.bz2
Schedule PasswordStore tasks on the DB thread on Windows and Linux; add a
NOTREACHED in the profile initialization when the password store fails to initialize correctly. BUG=35038 TEST=PasswordStoreMacTest.* Review URL: http://codereview.chromium.org/1528036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44475 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/password_manager/password_store.cc16
-rw-r--r--chrome/browser/password_manager/password_store.h3
-rw-r--r--chrome/browser/password_manager/password_store_mac.cc19
-rw-r--r--chrome/browser/password_manager/password_store_mac.h13
-rw-r--r--chrome/browser/profile.cc2
5 files changed, 36 insertions, 17 deletions
diff --git a/chrome/browser/password_manager/password_store.cc b/chrome/browser/password_manager/password_store.cc
index 72ce9a7..c58f394 100644
--- a/chrome/browser/password_manager/password_store.cc
+++ b/chrome/browser/password_manager/password_store.cc
@@ -6,6 +6,7 @@
#include "base/scoped_ptr.h"
#include "base/task.h"
+#include "chrome/browser/chrome_thread.h"
using std::vector;
using webkit_glue::PasswordForm;
@@ -14,20 +15,11 @@ PasswordStore::PasswordStore() : handle_(0) {
}
bool PasswordStore::Init() {
- thread_.reset(new base::Thread("Chrome_PasswordStore_Thread"));
-
- if (!thread_->Start()) {
- thread_.reset(NULL);
- return false;
- }
-
return true;
}
void PasswordStore::ScheduleTask(Task* task) {
- if (thread_.get()) {
- thread_->message_loop()->PostTask(FROM_HERE, task);
- }
+ ChromeThread::PostTask(ChromeThread::DB, FROM_HERE, task);
}
void PasswordStore::AddLogin(const PasswordForm& form) {
@@ -80,7 +72,9 @@ void PasswordStore::NotifyConsumer(GetLoginsRequest* request,
const vector<PasswordForm*> forms) {
scoped_ptr<GetLoginsRequest> request_ptr(request);
- DCHECK(MessageLoop::current() == thread_->message_loop());
+#if !defined(OS_MACOSX)
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::DB));
+#endif
request->message_loop->PostTask(FROM_HERE,
NewRunnableMethod(this,
&PasswordStore::NotifyConsumerImpl,
diff --git a/chrome/browser/password_manager/password_store.h b/chrome/browser/password_manager/password_store.h
index 193a8a6..f963611 100644
--- a/chrome/browser/password_manager/password_store.h
+++ b/chrome/browser/password_manager/password_store.h
@@ -120,9 +120,6 @@ class PasswordStore : public base::RefCountedThreadSafe<PasswordStore> {
void NotifyConsumer(GetLoginsRequest* request,
const std::vector<webkit_glue::PasswordForm*> forms);
- // Thread that the synchronous methods are run in.
- scoped_ptr<base::Thread> thread_;
-
private:
// Called by NotifyConsumer, but runs in the consumer's thread. Will not
// call the consumer if the request was canceled. This extra layer is here so
diff --git a/chrome/browser/password_manager/password_store_mac.cc b/chrome/browser/password_manager/password_store_mac.cc
index 95b8d5e..f35d5ba 100644
--- a/chrome/browser/password_manager/password_store_mac.cc
+++ b/chrome/browser/password_manager/password_store_mac.cc
@@ -715,7 +715,24 @@ PasswordStoreMac::PasswordStoreMac(MacKeychain* keychain,
DCHECK(login_metadata_db_.get());
}
-PasswordStoreMac::~PasswordStoreMac() {}
+PasswordStoreMac::~PasswordStoreMac() {
+}
+
+bool PasswordStoreMac::Init() {
+ thread_.reset(new base::Thread("Chrome_PasswordStore_Thread"));
+
+ if (!thread_->Start()) {
+ thread_.reset(NULL);
+ return false;
+ }
+ return PasswordStore::Init();
+}
+
+void PasswordStoreMac::ScheduleTask(Task* task) {
+ if (thread_.get()) {
+ thread_->message_loop()->PostTask(FROM_HERE, task);
+ }
+}
void PasswordStoreMac::AddLoginImpl(const PasswordForm& form) {
if (AddToKeychainIfNecessary(form)) {
diff --git a/chrome/browser/password_manager/password_store_mac.h b/chrome/browser/password_manager/password_store_mac.h
index 5956589..b746c4b 100644
--- a/chrome/browser/password_manager/password_store_mac.h
+++ b/chrome/browser/password_manager/password_store_mac.h
@@ -8,6 +8,7 @@
#include <vector>
#include "base/scoped_ptr.h"
+#include "base/thread.h"
#include "chrome/browser/password_manager/login_database.h"
#include "chrome/browser/password_manager/password_store.h"
@@ -24,9 +25,16 @@ class PasswordStoreMac : public PasswordStore {
// non-NULL.
PasswordStoreMac(MacKeychain* keychain, LoginDatabase* login_db);
- private:
+ // Initializes |thread_| and |notification_service_|.
+ virtual bool Init();
+
+ protected:
virtual ~PasswordStoreMac();
+ // Schedules tasks on |thread_|.
+ virtual void ScheduleTask(Task* task);
+
+ private:
void AddLoginImpl(const webkit_glue::PasswordForm& form);
void UpdateLoginImpl(const webkit_glue::PasswordForm& form);
void RemoveLoginImpl(const webkit_glue::PasswordForm& form);
@@ -63,6 +71,9 @@ class PasswordStoreMac : public PasswordStore {
scoped_ptr<MacKeychain> keychain_;
scoped_ptr<LoginDatabase> login_metadata_db_;
+ // Thread that the synchronous methods are run on.
+ scoped_ptr<base::Thread> thread_;
+
DISALLOW_COPY_AND_ASSIGN(PasswordStoreMac);
};
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index 83b2ad3e..6bda8b8 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -1192,7 +1192,7 @@ void ProfileImpl::CreatePasswordStore() {
#endif
if (!ps || !ps->Init()) {
// Try falling back to the default password manager
- LOG(WARNING) << "Could not initialise native password manager - "
+ NOTREACHED() << "Could not initialise native password manager - "
"falling back to default";
ps = new PasswordStoreDefault(GetWebDataService(Profile::IMPLICIT_ACCESS));
if (!ps->Init())