1 // Copyright 2014 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 COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_CONSUMER_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_CONSUMER_H_
10 #include "base/task/cancelable_task_tracker.h"
16 namespace password_manager {
18 // Reads from the PasswordStore are done asynchronously on a separate
19 // thread. PasswordStoreConsumer provides the virtual callback method, which is
20 // guaranteed to be executed on this (the UI) thread. It also provides the
21 // base::CancelableTaskTracker member, which cancels any outstanding
22 // tasks upon destruction.
23 class PasswordStoreConsumer {
25 PasswordStoreConsumer();
27 // Called when the request is finished. If there are no results, it is called
28 // with an empty vector.
29 // Note: The implementation owns all PasswordForms in the vector.
30 virtual void OnGetPasswordStoreResults(
31 const std::vector<autofill::PasswordForm*>& results) = 0;
33 // The base::CancelableTaskTracker can be used for cancelling the
34 // tasks associated with the consumer.
35 base::CancelableTaskTracker* cancelable_task_tracker() {
36 return &cancelable_task_tracker_;
39 base::WeakPtr<PasswordStoreConsumer> GetWeakPtr() {
40 return weak_ptr_factory_.GetWeakPtr();
44 virtual ~PasswordStoreConsumer();
47 base::CancelableTaskTracker cancelable_task_tracker_;
48 base::WeakPtrFactory<PasswordStoreConsumer> weak_ptr_factory_;
51 } // namespace password_manager
53 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_CONSUMER_H_