1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_CONSUMER_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_CONSUMER_H_
8 #include "chrome/common/cancelable_task_tracker.h"
14 // Reads from the PasswordStore are done asynchronously on a separate
15 // thread. PasswordStoreConsumer provides the virtual callback method, which is
16 // guaranteed to be executed on this (the UI) thread. It also provides the
17 // CancelableTaskTracker member, which cancels any outstanding tasks upon
19 class PasswordStoreConsumer {
21 PasswordStoreConsumer();
23 // Called when the request is finished. If there are no results, it is called
24 // with an empty vector.
25 // Note: The implementation owns all PasswordForms in the vector.
26 virtual void OnGetPasswordStoreResults(
27 const std::vector<autofill::PasswordForm*>& results) = 0;
29 // The CancelableTaskTracker can be used for cancelling the tasks associated
31 CancelableTaskTracker* cancelable_task_tracker() {
32 return &cancelable_task_tracker_;
35 base::WeakPtr<PasswordStoreConsumer> GetWeakPtr() {
36 return weak_ptr_factory_.GetWeakPtr();
40 virtual ~PasswordStoreConsumer();
43 CancelableTaskTracker cancelable_task_tracker_;
44 base::WeakPtrFactory<PasswordStoreConsumer> weak_ptr_factory_;
47 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_CONSUMER_H_