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