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