OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_CONSUMER_H_ | 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_CONSUMER_H_ |
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_CONSUMER_H_ | 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_CONSUMER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
| 10 #include "base/memory/scoped_vector.h" |
10 #include "base/task/cancelable_task_tracker.h" | 11 #include "base/task/cancelable_task_tracker.h" |
11 | 12 |
12 namespace autofill { | 13 namespace autofill { |
13 struct PasswordForm; | 14 struct PasswordForm; |
14 } | 15 } |
15 | 16 |
16 namespace password_manager { | 17 namespace password_manager { |
17 | 18 |
18 // Reads from the PasswordStore are done asynchronously on a separate | 19 // Reads from the PasswordStore are done asynchronously on a separate |
19 // thread. PasswordStoreConsumer provides the virtual callback method, which is | 20 // thread. PasswordStoreConsumer provides the virtual callback method, which is |
20 // guaranteed to be executed on this (the UI) thread. It also provides the | 21 // guaranteed to be executed on this (the UI) thread. It also provides the |
21 // base::CancelableTaskTracker member, which cancels any outstanding | 22 // base::CancelableTaskTracker member, which cancels any outstanding |
22 // tasks upon destruction. | 23 // tasks upon destruction. |
23 class PasswordStoreConsumer { | 24 class PasswordStoreConsumer { |
24 public: | 25 public: |
25 PasswordStoreConsumer(); | 26 PasswordStoreConsumer(); |
26 | 27 |
27 // Called when the request is finished. If there are no results, it is called | 28 // Called when the request is finished, with the associated |results|. |
28 // with an empty vector. | |
29 // Note: The implementation owns all PasswordForms in the vector. | |
30 virtual void OnGetPasswordStoreResults( | 29 virtual void OnGetPasswordStoreResults( |
31 const std::vector<autofill::PasswordForm*>& results) = 0; | 30 ScopedVector<autofill::PasswordForm> results) = 0; |
32 | 31 |
33 // The base::CancelableTaskTracker can be used for cancelling the | 32 // The base::CancelableTaskTracker can be used for cancelling the |
34 // tasks associated with the consumer. | 33 // tasks associated with the consumer. |
35 base::CancelableTaskTracker* cancelable_task_tracker() { | 34 base::CancelableTaskTracker* cancelable_task_tracker() { |
36 return &cancelable_task_tracker_; | 35 return &cancelable_task_tracker_; |
37 } | 36 } |
38 | 37 |
39 base::WeakPtr<PasswordStoreConsumer> GetWeakPtr() { | 38 base::WeakPtr<PasswordStoreConsumer> GetWeakPtr() { |
40 return weak_ptr_factory_.GetWeakPtr(); | 39 return weak_ptr_factory_.GetWeakPtr(); |
41 } | 40 } |
42 | 41 |
43 protected: | 42 protected: |
44 virtual ~PasswordStoreConsumer(); | 43 virtual ~PasswordStoreConsumer(); |
45 | 44 |
46 private: | 45 private: |
47 base::CancelableTaskTracker cancelable_task_tracker_; | 46 base::CancelableTaskTracker cancelable_task_tracker_; |
48 base::WeakPtrFactory<PasswordStoreConsumer> weak_ptr_factory_; | 47 base::WeakPtrFactory<PasswordStoreConsumer> weak_ptr_factory_; |
49 }; | 48 }; |
50 | 49 |
51 } // namespace password_manager | 50 } // namespace password_manager |
52 | 51 |
53 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_CONSUMER_H_ | 52 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_CONSUMER_H_ |
OLD | NEW |