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_
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/single_thread_task_runner.h"
14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/login/auth/auth_attempt_state_resolver.h"
16 #include "chromeos/login/auth/user_context.h"
19 class URLRequestContextGetter
;
24 class AuthAttemptState
;
28 // Helper class which hosts OnlineAttempt for online credentials checking.
29 class CHROMEOS_EXPORT OnlineAttemptHost
: public AuthAttemptStateResolver
{
33 // Called after user_context were checked online.
34 virtual void OnChecked(const std::string
& username
, bool success
) = 0;
37 explicit OnlineAttemptHost(Delegate
* delegate
);
38 ~OnlineAttemptHost() override
;
40 // Performs an online check of the credentials in |request_context| and
42 // the delegate's OnChecked() with the result. Note that only one check can be
43 // in progress at any given time. If this method is invoked with a different
44 // |user_context| than a check currently in progress, the current check will
45 // be silently aborted.
46 void Check(net::URLRequestContextGetter
* request_context
,
47 const UserContext
& user_context
);
49 // Resets the checking process.
52 // AuthAttemptStateResolver overrides.
53 // Executed on IO thread.
54 void Resolve() override
;
56 // Does an actual resolve on UI thread.
57 void ResolveOnUIThread(bool success
);
60 scoped_refptr
<base::SingleThreadTaskRunner
> task_runner_
;
62 UserContext current_attempt_user_context_
;
63 scoped_ptr
<OnlineAttempt
> online_attempt_
;
64 scoped_ptr
<AuthAttemptState
> state_
;
65 base::WeakPtrFactory
<OnlineAttemptHost
> weak_ptr_factory_
;
67 DISALLOW_COPY_AND_ASSIGN(OnlineAttemptHost
);
70 } // namespace chromeos
72 #endif // CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_HOST_H_