blob: 6800919b5165973ad1c769bc8b5cea6969f7f1a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright 2014 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.
#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_CONSUMER_H_
#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_CONSUMER_H_
#include <memory>
#include <vector>
#include "base/task/cancelable_task_tracker.h"
namespace autofill {
struct PasswordForm;
}
namespace password_manager {
struct InteractionsStats;
// Reads from the PasswordStore are done asynchronously on a separate
// thread. PasswordStoreConsumer provides the virtual callback method, which is
// guaranteed to be executed on this (the UI) thread. It also provides the
// base::CancelableTaskTracker member, which cancels any outstanding
// tasks upon destruction.
class PasswordStoreConsumer {
public:
PasswordStoreConsumer();
// Called when the GetLogins() request is finished, with the associated
// |results|.
virtual void OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>> results) = 0;
// Called when the GetLogins() request is finished, with the associated site
// statistics.
virtual void OnGetSiteStatistics(std::vector<InteractionsStats> stats);
// The base::CancelableTaskTracker can be used for cancelling the
// tasks associated with the consumer.
base::CancelableTaskTracker* cancelable_task_tracker() {
return &cancelable_task_tracker_;
}
base::WeakPtr<PasswordStoreConsumer> GetWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
bool HasWeakPtrs() const { return weak_ptr_factory_.HasWeakPtrs(); }
protected:
virtual ~PasswordStoreConsumer();
private:
base::CancelableTaskTracker cancelable_task_tracker_;
base::WeakPtrFactory<PasswordStoreConsumer> weak_ptr_factory_;
};
} // namespace password_manager
#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_CONSUMER_H_
|