Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Side by Side Diff: chrome/browser/chromeos/login/auth/online_attempt.h

Issue 402403004: Refactoring : Move OnlineAttempt to chromeos/login (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Yet another merge with ToT Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_H_
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "base/gtest_prod_util.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "chromeos/login/auth/auth_status_consumer.h"
16 #include "google_apis/gaia/gaia_auth_consumer.h"
17 #include "google_apis/gaia/google_service_auth_error.h"
18
19 class GaiaAuthFetcher;
20
21 namespace content {
22 class BrowserContext;
23 }
24
25 namespace chromeos {
26 class AuthAttemptState;
27 class AuthAttemptStateResolver;
28
29 class OnlineAttempt
30 : public GaiaAuthConsumer {
31 public:
32 OnlineAttempt(AuthAttemptState* current_attempt,
33 AuthAttemptStateResolver* callback);
34 virtual ~OnlineAttempt();
35
36 // Initiate the online login attempt either through client or auth login.
37 // Status will be recorded in |current_attempt|, and resolver_->Resolve() will
38 // be called on the IO thread when useful state is available.
39 // Must be called on the UI thread.
40 void Initiate(content::BrowserContext* auth_context);
41
42 // GaiaAuthConsumer overrides. Callbacks from GaiaAuthFetcher
43 virtual void OnClientLoginFailure(
44 const GoogleServiceAuthError& error) OVERRIDE;
45 virtual void OnClientLoginSuccess(
46 const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE;
47
48 private:
49 FRIEND_TEST_ALL_PREFIXES(OnlineAttemptTest, LoginSuccess);
50 FRIEND_TEST_ALL_PREFIXES(OnlineAttemptTest, TwoFactorSuccess);
51
52 // Milliseconds until we timeout our attempt to hit ClientLogin.
53 static const int kClientLoginTimeoutMs;
54
55 void TryClientLogin();
56 void CancelClientLogin();
57
58 void TriggerResolve(const AuthFailure& outcome);
59
60 bool HasPendingFetch();
61 void CancelRequest();
62
63 AuthAttemptState* const attempt_;
64 AuthAttemptStateResolver* const resolver_;
65
66 // Handles ClientLogin communications with Gaia.
67 scoped_ptr<GaiaAuthFetcher> client_fetcher_;
68
69 // Used to cancel the CancelClientLogin closure.
70 base::WeakPtrFactory<OnlineAttempt> weak_factory_;
71
72 // Whether we're willing to re-try the ClientLogin attempt.
73 bool try_again_;
74
75 friend class OnlineAttemptTest;
76 DISALLOW_COPY_AND_ASSIGN(OnlineAttempt);
77 };
78
79 } // namespace chromeos
80
81 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_ONLINE_ATTEMPT_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/auth/mock_url_fetchers.cc ('k') | chrome/browser/chromeos/login/auth/online_attempt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698