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 // Reads from the PasswordStore are done asynchronously on a separate
17 // thread. PasswordStoreConsumer provides the virtual callback method, which is
18 // guaranteed to be executed on this (the UI) thread. It also provides the
19 // base::CancelableTaskTracker member, which cancels any outstanding
20 // tasks upon destruction.
21 class PasswordStoreConsumer {
23 PasswordStoreConsumer();
25 // Called when the request is finished. If there are no results, it is called
26 // with an empty vector.
27 // Note: The implementation owns all PasswordForms in the vector.
28 virtual void OnGetPasswordStoreResults(
29 const std::vector<autofill::PasswordForm*>& results) = 0;
31 // The base::CancelableTaskTracker can be used for cancelling the
32 // tasks associated with the consumer.
33 base::CancelableTaskTracker* cancelable_task_tracker() {
34 return &cancelable_task_tracker_;
37 base::WeakPtr<PasswordStoreConsumer> GetWeakPtr() {
38 return weak_ptr_factory_.GetWeakPtr();
42 virtual ~PasswordStoreConsumer();
45 base::CancelableTaskTracker cancelable_task_tracker_;
46 base::WeakPtrFactory<PasswordStoreConsumer> weak_ptr_factory_;
49 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_CONSUMER_H_