cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chromeos / login / auth / auth_attempt_state.h
blob685ba688268019ddfe8797d13d55ae567d5eefbc
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_AUTH_ATTEMPT_STATE_H_
6 #define CHROMEOS_LOGIN_AUTH_AUTH_ATTEMPT_STATE_H_
8 #include <string>
10 #include "base/memory/weak_ptr.h"
11 #include "chromeos/chromeos_export.h"
12 #include "chromeos/login/auth/auth_status_consumer.h"
13 #include "chromeos/login/auth/user_context.h"
14 #include "google_apis/gaia/gaia_auth_consumer.h"
15 #include "third_party/cros_system_api/dbus/service_constants.h"
17 namespace chromeos {
19 // Tracks the state associated with a single attempt to log in to chromium OS.
20 // Enforces that methods are only called on the UI thread.
21 class CHROMEOS_EXPORT AuthAttemptState
22 : public base::SupportsWeakPtr<AuthAttemptState> {
23 public:
24 // Used to initialize for a login attempt.
25 AuthAttemptState(const UserContext& user_context,
26 bool unlock,
27 bool online_complete,
28 bool user_is_new);
30 virtual ~AuthAttemptState();
32 // Copy |user_context| and copy |outcome| into this object, so we can have
33 // a copy we're sure to own, and can make available on the UI thread.
34 // Must be called from the UI thread.
35 void RecordOnlineLoginStatus(const AuthFailure& outcome);
37 // Copy |username_hash| into this object, so we can have
38 // a copy we're sure to own, and can make available on the UI thread.
39 // Must be called from the UI thread.
40 void RecordUsernameHash(const std::string& username_hash);
42 // Marks that the username hash request attempt has failed.
43 void RecordUsernameHashFailed();
45 // Marks username hash as being requested so that flow will block till both
46 // requests (Mount/GetUsernameHash) are completed.
47 void UsernameHashRequested();
49 // Copy |cryptohome_code| and |cryptohome_outcome| into this object,
50 // so we can have a copy we're sure to own, and can make available
51 // on the UI thread. Must be called from the UI thread.
52 void RecordCryptohomeStatus(bool cryptohome_outcome,
53 cryptohome::MountError cryptohome_code);
55 // Blow away locally stored cryptohome login status.
56 // Must be called from the UI thread.
57 void ResetCryptohomeStatus();
59 virtual bool online_complete();
60 virtual const AuthFailure& online_outcome();
61 virtual bool is_first_time_user();
63 virtual bool cryptohome_complete();
64 virtual bool cryptohome_outcome();
65 virtual cryptohome::MountError cryptohome_code();
67 virtual bool username_hash_obtained();
68 virtual bool username_hash_valid();
70 // Saved so we can retry client login, and also so we know for whom login
71 // has succeeded, in the event of successful completion.
72 UserContext user_context;
74 // These fields are saved so we can retry client login.
75 const std::string login_token;
76 const std::string login_captcha;
78 const bool unlock; // True if authenticating to unlock the computer.
80 protected:
81 // Status of our online login attempt.
82 bool online_complete_;
83 AuthFailure online_outcome_;
85 bool is_first_time_user_;
87 // Status of our cryptohome op attempt. Can only have one in flight at a time.
88 bool cryptohome_complete_;
89 bool cryptohome_outcome_;
90 cryptohome::MountError cryptohome_code_;
92 private:
93 // Status of the crypthome GetSanitizedUsername() async call.
94 // This gets initialized as being completed and those callers
95 // that would explicitly request username hash would have to reset this.
96 bool username_hash_obtained_;
98 // After the username hash request is completed, this marks whether
99 // the request was successful.
100 bool username_hash_valid_;
102 DISALLOW_COPY_AND_ASSIGN(AuthAttemptState);
105 } // namespace chromeos
107 #endif // CHROMEOS_LOGIN_AUTH_AUTH_ATTEMPT_STATE_H_