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

Unified Diff: components/password_manager/core/browser/password_store.h

Issue 866983003: GetLoginsRequest: Use ScopedVector to express ownership of forms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@324291_scopedvector
Patch Set: Fix Mac unittest Created 5 years, 10 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/password_store.h
diff --git a/components/password_manager/core/browser/password_store.h b/components/password_manager/core/browser/password_store.h
index fb7d3bb25819c1b3939f1e46d83efc67543dc1e9..86664b463e5ad353caebffd64d87f2e912ec2cbf 100644
--- a/components/password_manager/core/browser/password_store.h
+++ b/components/password_manager/core/browser/password_store.h
@@ -66,46 +66,6 @@ class PasswordStore : protected PasswordStoreSync,
// passwords, which requires prompting the user for permission.
enum AuthorizationPromptPolicy { ALLOW_PROMPT, DISALLOW_PROMPT };
- // PasswordForm vector elements are meant to be owned by the
- // PasswordStoreConsumer. However, if the request is canceled after the
- // allocation, then the request must take care of the deletion.
- class GetLoginsRequest {
- public:
- explicit GetLoginsRequest(PasswordStoreConsumer* consumer);
- virtual ~GetLoginsRequest();
-
- void set_ignore_logins_cutoff(base::Time cutoff) {
- ignore_logins_cutoff_ = cutoff;
- }
-
- // Removes any logins in the result list that were saved before the cutoff.
- void ApplyIgnoreLoginsCutoff();
-
- // Forward the result to the consumer on the original message loop.
- void ForwardResult();
-
- std::vector<autofill::PasswordForm*>* result() const {
- return result_.get();
- }
-
- private:
- // See GetLogins(). Logins older than this will be removed from the reply.
- base::Time ignore_logins_cutoff_;
-
- base::WeakPtr<PasswordStoreConsumer> consumer_weak_;
-
- // The result of the request. It is filled in on the PasswordStore's task
- // thread and consumed on the UI thread.
- // TODO(dubroy): Remove this, and instead pass the vector directly to the
- // backend methods.
- scoped_ptr<std::vector<autofill::PasswordForm*>> result_;
-
- base::ThreadChecker thread_checker_;
- scoped_refptr<base::MessageLoopProxy> origin_loop_;
-
- DISALLOW_COPY_AND_ASSIGN(GetLoginsRequest);
- };
-
// An interface used to notify clients (observers) of this object that data in
// the password store has changed. Register the observer via
// PasswordStore::AddObserver.
@@ -192,6 +152,42 @@ class PasswordStore : protected PasswordStoreSync,
typedef base::Callback<PasswordStoreChangeList(void)> ModificationTask;
+ // PasswordForm vector elements are meant to be owned by the
+ // PasswordStoreConsumer. However, if the request is canceled after the
+ // allocation, then the request must take care of the deletion.
+ class GetLoginsRequest {
+ public:
+ explicit GetLoginsRequest(PasswordStoreConsumer* consumer);
+ virtual ~GetLoginsRequest();
+
+ void set_ignore_logins_cutoff(base::Time cutoff) {
+ ignore_logins_cutoff_ = cutoff;
+ }
+
+ // Removes any logins in the result list that were saved before the cutoff.
+ void ApplyIgnoreLoginsCutoff();
+
+ // Forward the result to the consumer on the original message loop.
+ void ForwardResult();
+
+ ScopedVector<autofill::PasswordForm>* result() { return &result_; }
+
+ private:
+ // See GetLogins(). Logins older than this will be removed from the reply.
+ base::Time ignore_logins_cutoff_;
+
+ base::WeakPtr<PasswordStoreConsumer> consumer_weak_;
+
+ // The result of the request. It is filled in on the PasswordStore's task
+ // thread and consumed on the UI thread.
+ ScopedVector<autofill::PasswordForm> result_;
+
+ base::ThreadChecker thread_checker_;
+ scoped_refptr<base::MessageLoopProxy> origin_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(GetLoginsRequest);
+ };
+
~PasswordStore() override;
// Get the TaskRunner to use for PasswordStore background tasks.
@@ -235,14 +231,15 @@ class PasswordStore : protected PasswordStoreSync,
const ConsumerCallbackRunner& callback_runner) = 0;
// Finds all non-blacklist PasswordForms, and notifies the consumer.
- virtual void GetAutofillableLoginsImpl(GetLoginsRequest* request) = 0;
+ virtual void GetAutofillableLoginsImpl(
+ scoped_ptr<GetLoginsRequest> request) = 0;
// Finds all blacklist PasswordForms, and notifies the consumer.
- virtual void GetBlacklistLoginsImpl(GetLoginsRequest* request) = 0;
+ virtual void GetBlacklistLoginsImpl(scoped_ptr<GetLoginsRequest> request) = 0;
// Dispatches the result to the PasswordStoreConsumer on the original caller's
// thread so the callback can be executed there. This should be the UI thread.
- static void ForwardLoginsResult(GetLoginsRequest* request);
+ static void ForwardLoginsResult(scoped_ptr<GetLoginsRequest> request);
// Log UMA stats for number of bulk deletions.
void LogStatsForBulkDeletion(int num_deletions);
@@ -267,8 +264,8 @@ class PasswordStore : protected PasswordStoreSync,
private:
// Schedule the given |func| to be run in the PasswordStore's own thread with
// responses delivered to |consumer| on the current thread.
- template <typename BackendFunc>
- void Schedule(BackendFunc func, PasswordStoreConsumer* consumer);
+ void Schedule(void (PasswordStore::*func)(scoped_ptr<GetLoginsRequest>),
+ PasswordStoreConsumer* consumer);
// Wrapper method called on the destination thread (DB for non-mac) that
// invokes |task| and then calls back into the source thread to notify
@@ -291,7 +288,7 @@ class PasswordStore : protected PasswordStoreSync,
// |GetLoginsImpl| and |PasswordStoreConsumer|.
// TODO(dubroy): Get rid of this.
static void CopyAndForwardLoginsResult(
- PasswordStore::GetLoginsRequest* request,
+ scoped_ptr<PasswordStore::GetLoginsRequest> request,
ScopedVector<autofill::PasswordForm> matched_forms);
#if defined(PASSWORD_MANAGER_ENABLE_SYNC)

Powered by Google App Engine
This is Rietveld 408576698