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

Unified Diff: chrome/browser/password_manager/password_store_default.cc

Issue 118131: Change PasswordStoreDefault to access the WebDataService from the UI thread o... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 7 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: chrome/browser/password_manager/password_store_default.cc
===================================================================
--- chrome/browser/password_manager/password_store_default.cc (revision 17405)
+++ chrome/browser/password_manager/password_store_default.cc (working copy)
@@ -13,21 +13,66 @@
: web_data_service_(web_data_service) {
}
-void PasswordStoreDefault::AddLoginImpl(const PasswordForm& form) {
+PasswordStoreDefault::~PasswordStoreDefault() {
+ for (PendingRequestMap::const_iterator it = pending_requests_.begin();
+ it != pending_requests_.end(); ++it) {
+ web_data_service_->CancelRequest(it->first);
+ }
+}
+
+// Override all the public methods to do avoid passthroughs to the Impl
+// versions. Since we are calling through to WebDataService, which is
+// asynchronous, we'll still behave as the caller expects.
+void PasswordStoreDefault::AddLogin(const PasswordForm& form) {
web_data_service_->AddLogin(form);
}
-void PasswordStoreDefault::RemoveLoginImpl(const PasswordForm& form) {
+void PasswordStoreDefault::UpdateLogin(const PasswordForm& form) {
+ web_data_service_->UpdateLogin(form);
+}
+
+void PasswordStoreDefault::RemoveLogin(const PasswordForm& form) {
web_data_service_->RemoveLogin(form);
}
+int PasswordStoreDefault::GetLogins(const PasswordForm& form,
+ PasswordStoreConsumer* consumer) {
tim (not reviewing) 2009/06/03 21:35:14 nit indent
+ int handle = handle_++;
+ GetLoginsRequest* request = new GetLoginsRequest(form, consumer, handle);
+
+ int web_data_handle = web_data_service_->GetLogins(form, this);
+ pending_requests_.insert(PendingRequestMap::value_type(web_data_handle,
+ request));
+ return handle;
+}
+
+void PasswordStoreDefault::CancelLoginsQuery(int handle) {
+ for (PendingRequestMap::iterator it = pending_requests_.begin();
+ it != pending_requests_.end(); ++it) {
+ GetLoginsRequest* request = it->second;
+ if (request->handle == handle) {
+ web_data_service_->CancelRequest(it->first);
+ delete request;
+ pending_requests_.erase(it);
+ return;
+ }
+ }
+}
+
+void PasswordStoreDefault::AddLoginImpl(const PasswordForm& form) {
+ NOTREACHED();
+}
+
+void PasswordStoreDefault::RemoveLoginImpl(const PasswordForm& form) {
+ NOTREACHED();
+}
+
void PasswordStoreDefault::UpdateLoginImpl(const PasswordForm& form) {
- web_data_service_->UpdateLogin(form);
+ NOTREACHED();
}
void PasswordStoreDefault::GetLoginsImpl(GetLoginsRequest* request) {
- int web_data_handle = web_data_service_->GetLogins(request->form, this);
- AddPendingWebDataServiceRequest(web_data_handle, request);
+ NOTREACHED();
}
void PasswordStoreDefault::OnWebDataServiceRequestDone(
@@ -36,9 +81,11 @@
// Look up this handle in our request map to get the original
// GetLoginsRequest.
PendingRequestMap::iterator it(pending_requests_.find(h));
- DCHECK(it != pending_requests_.end());
+ // If the request was cancelled, we are done.
+ if (it == pending_requests_.end())
+ return;
- GetLoginsRequest* request = it->second;
+ scoped_ptr<GetLoginsRequest> request(it->second);
pending_requests_.erase(it);
DCHECK(result);
@@ -48,36 +95,6 @@
const WDResult<std::vector<PasswordForm*> >* r =
static_cast<const WDResult<std::vector<PasswordForm*> >*>(result);
- NotifyConsumer(request, r->GetValue());
-
- RemovePendingWebDataServiceRequest(h);
+ request->consumer->OnPasswordStoreRequestDone(request->handle,
+ r->GetValue());
}
-
-void PasswordStoreDefault::AddPendingWebDataServiceRequest(
- WebDataService::Handle handle, GetLoginsRequest* request) {
- pending_requests_.insert(PendingRequestMap::value_type(handle, request));
-
- // WebDataService callbacks are non-retaining. Since there would be a race
- // around cancelling the requests in the desctructor vs. getting a callback
- // in this worker thread, just make sure that we stick around instead.
- this->AddRef();
-}
-
-void PasswordStoreDefault::RemovePendingWebDataServiceRequest(
- WebDataService::Handle handle) {
- PendingRequestMap::iterator it(pending_requests_.find(handle));
- DCHECK(it != pending_requests_.end());
- pending_requests_.erase(it);
-
- // Balance the AddRef in AddPendingWebDataServiceRequest.
- this->Release();
-}
-
-PasswordStore::GetLoginsRequest*
- PasswordStoreDefault::GetLoginsRequestForWebDataServiceRequest(
- WebDataService::Handle handle) {
- PendingRequestMap::iterator it(pending_requests_.find(handle));
- if (it == pending_requests_.end())
- return NULL;
- return it->second;
-}
Property changes on: chrome\browser\password_manager\password_store_default.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/password_manager/password_store_default.h ('k') | chrome/browser/password_manager/password_store_gnome.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698