Roll src/third_party/WebKit abe9e39c:3d349bd (svn 182659:182669)
[chromium-blink-merge.git] / chromeos / login / auth / online_attempt_host.h
blob8d49a7b70d7bad116b5dd3cbd5cd99bf5cbf8604
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
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_HOST_H_
6 #define CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_HOST_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chromeos/chromeos_export.h"
14 #include "chromeos/login/auth/auth_attempt_state_resolver.h"
15 #include "chromeos/login/auth/user_context.h"
17 namespace net {
18 class URLRequestContextGetter;
21 namespace chromeos {
23 class AuthAttemptState;
24 class OnlineAttempt;
25 class UserContext;
27 // Helper class which hosts OnlineAttempt for online credentials checking.
28 class CHROMEOS_EXPORT OnlineAttemptHost : public AuthAttemptStateResolver {
29 public:
30 class Delegate {
31 public:
32 // Called after user_context were checked online.
33 virtual void OnChecked(const std::string& username, bool success) = 0;
36 explicit OnlineAttemptHost(Delegate* delegate);
37 virtual ~OnlineAttemptHost();
39 // Performs an online check of the credentials in |request_context| and
40 // invokes
41 // the delegate's OnChecked() with the result. Note that only one check can be
42 // in progress at any given time. If this method is invoked with a different
43 // |user_context| than a check currently in progress, the current check will
44 // be silently aborted.
45 void Check(net::URLRequestContextGetter* request_context,
46 const UserContext& user_context);
48 // Resets the checking process.
49 void Reset();
51 // AuthAttemptStateResolver overrides.
52 // Executed on IO thread.
53 virtual void Resolve() OVERRIDE;
55 // Does an actual resolve on UI thread.
56 void ResolveOnUIThread(bool success);
58 private:
59 scoped_refptr<base::MessageLoopProxy> message_loop_;
60 Delegate* delegate_;
61 UserContext current_attempt_user_context_;
62 scoped_ptr<OnlineAttempt> online_attempt_;
63 scoped_ptr<AuthAttemptState> state_;
64 base::WeakPtrFactory<OnlineAttemptHost> weak_ptr_factory_;
66 DISALLOW_COPY_AND_ASSIGN(OnlineAttemptHost);
69 } // namespace chromeos
71 #endif // CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_HOST_H_