Chromium Code Reviews| 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. The associated results are accessible |
| 28 // with an empty vector. | 29 // through results(). |
| 29 // Note: The implementation owns all PasswordForms in the vector. | 30 virtual void OnGetPasswordStoreResults() = 0; |
|
vasilii
2015/02/03 19:22:17
This is my deepest concern in the CL. I didn't see
vabr (Chromium)
2015/02/04 16:13:44
Thanks for pointing that out. I agree, and I'm act
| |
| 30 virtual void OnGetPasswordStoreResults( | |
| 31 const std::vector<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 |
| 42 ScopedVector<autofill::PasswordForm>* results() { return &results_; } | |
| 43 | |
| 43 protected: | 44 protected: |
| 44 virtual ~PasswordStoreConsumer(); | 45 virtual ~PasswordStoreConsumer(); |
| 45 | 46 |
| 46 private: | 47 private: |
| 48 ScopedVector<autofill::PasswordForm> results_; | |
| 47 base::CancelableTaskTracker cancelable_task_tracker_; | 49 base::CancelableTaskTracker cancelable_task_tracker_; |
| 48 base::WeakPtrFactory<PasswordStoreConsumer> weak_ptr_factory_; | 50 base::WeakPtrFactory<PasswordStoreConsumer> weak_ptr_factory_; |
| 49 }; | 51 }; |
| 50 | 52 |
| 51 } // namespace password_manager | 53 } // namespace password_manager |
| 52 | 54 |
| 53 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_CONSUMER_H_ | 55 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_CONSUMER_H_ |
| OLD | NEW |