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

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

Issue 114057: Re-land the password store work from bug 8205, with changes that should fix b... (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 0)
+++ chrome/browser/password_manager/password_store_default.cc (revision 0)
@@ -0,0 +1,83 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/password_manager/password_store_default.h"
+#include "chrome/browser/webdata/web_data_service.h"
+#include "chrome/common/chrome_constants.h"
+
+#include "base/logging.h"
+#include "base/task.h"
+
+PasswordStoreDefault::PasswordStoreDefault(WebDataService* web_data_service)
+ : web_data_service_(web_data_service) {
+}
+
+void PasswordStoreDefault::AddLoginImpl(const PasswordForm& form) {
+ web_data_service_->AddLogin(form);
+}
+
+void PasswordStoreDefault::RemoveLoginImpl(const PasswordForm& form) {
+ web_data_service_->RemoveLogin(form);
+}
+
+void PasswordStoreDefault::UpdateLoginImpl(const PasswordForm& form) {
+ web_data_service_->UpdateLogin(form);
+}
+
+void PasswordStoreDefault::GetLoginsImpl(GetLoginsRequest* request) {
+ int web_data_handle = web_data_service_->GetLogins(request->form, this);
+ AddPendingWebDataServiceRequest(web_data_handle, request);
+}
+
+void PasswordStoreDefault::OnWebDataServiceRequestDone(
+ WebDataService::Handle h,
+ const WDTypedResult *result) {
+ // 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());
+
+ GetLoginsRequest* request = it->second;
+ pending_requests_.erase(it);
+
+ DCHECK(result);
+ if (!result)
+ return;
+
+ const WDResult<std::vector<PasswordForm*> >* r =
+ static_cast<const WDResult<std::vector<PasswordForm*> >*>(result);
+
+ NotifyConsumer(request, r->GetValue());
+
+ RemovePendingWebDataServiceRequest(h);
+}
+
+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;
+}
« 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