| 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/browser/common/cancelable_request.h" | 8 #include "chrome/browser/common/cancelable_request.h" |
| 9 #include "chrome/common/cancelable_task_tracker.h" | 9 #include "chrome/common/cancelable_task_tracker.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace autofill { |
| 12 struct PasswordForm; | 12 struct PasswordForm; |
| 13 } | 13 } |
| 14 | 14 |
| 15 // Reads from the PasswordStore are done asynchronously on a separate | 15 // Reads from the PasswordStore are done asynchronously on a separate |
| 16 // thread. PasswordStoreConsumer provides the virtual callback method, which is | 16 // thread. PasswordStoreConsumer provides the virtual callback method, which is |
| 17 // guaranteed to be executed on this (the UI) thread. It also provides the | 17 // guaranteed to be executed on this (the UI) thread. It also provides the |
| 18 // CancelableRequestConsumer member, which cancels any outstanding requests upon | 18 // CancelableRequestConsumer member, which cancels any outstanding requests upon |
| 19 // destruction. | 19 // destruction. |
| 20 class PasswordStoreConsumer { | 20 class PasswordStoreConsumer { |
| 21 public: | 21 public: |
| 22 PasswordStoreConsumer(); | 22 PasswordStoreConsumer(); |
| 23 | 23 |
| 24 // Call this when the request is finished. If there are no results, call it | 24 // Call this when the request is finished. If there are no results, call it |
| 25 // anyway with an empty vector. | 25 // anyway with an empty vector. |
| 26 virtual void OnPasswordStoreRequestDone( | 26 virtual void OnPasswordStoreRequestDone( |
| 27 CancelableRequestProvider::Handle handle, | 27 CancelableRequestProvider::Handle handle, |
| 28 const std::vector<content::PasswordForm*>& result) = 0; | 28 const std::vector<autofill::PasswordForm*>& result) = 0; |
| 29 | 29 |
| 30 // The CancelableRequest framework needs both a callback (the | 30 // The CancelableRequest framework needs both a callback (the |
| 31 // PasswordStoreConsumer::OnPasswordStoreRequestDone) as well as a | 31 // PasswordStoreConsumer::OnPasswordStoreRequestDone) as well as a |
| 32 // CancelableRequestConsumer. This accessor makes the API simpler for callers | 32 // CancelableRequestConsumer. This accessor makes the API simpler for callers |
| 33 // as PasswordStore can get both from the PasswordStoreConsumer. | 33 // as PasswordStore can get both from the PasswordStoreConsumer. |
| 34 CancelableRequestConsumerBase* cancelable_consumer() { | 34 CancelableRequestConsumerBase* cancelable_consumer() { |
| 35 return &cancelable_consumer_; | 35 return &cancelable_consumer_; |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Called when the request is finished. If there are no results, it is called | 38 // Called when the request is finished. If there are no results, it is called |
| 39 // with an empty vector. | 39 // with an empty vector. |
| 40 // Note: The implementation owns all PasswordForms in the vector. | 40 // Note: The implementation owns all PasswordForms in the vector. |
| 41 virtual void OnGetPasswordStoreResults( | 41 virtual void OnGetPasswordStoreResults( |
| 42 const std::vector<content::PasswordForm*>& results) = 0; | 42 const std::vector<autofill::PasswordForm*>& results) = 0; |
| 43 | 43 |
| 44 // Cancels the task. | 44 // Cancels the task. |
| 45 CancelableTaskTracker* cancelable_task_tracker() { | 45 CancelableTaskTracker* cancelable_task_tracker() { |
| 46 return &cancelable_task_tracker_; | 46 return &cancelable_task_tracker_; |
| 47 } | 47 } |
| 48 | 48 |
| 49 protected: | 49 protected: |
| 50 virtual ~PasswordStoreConsumer(); | 50 virtual ~PasswordStoreConsumer(); |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 CancelableRequestConsumer cancelable_consumer_; | 53 CancelableRequestConsumer cancelable_consumer_; |
| 54 CancelableTaskTracker cancelable_task_tracker_; | 54 CancelableTaskTracker cancelable_task_tracker_; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_CONSUMER_H_ | 57 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_CONSUMER_H_ |
| OLD | NEW |