OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chromeos/login/auth/login_performer.h" | 5 #include "chromeos/login/auth/login_performer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 if (authenticator_.get()) | 46 if (authenticator_.get()) |
47 authenticator_->SetConsumer(NULL); | 47 authenticator_->SetConsumer(NULL); |
48 if (extended_authenticator_.get()) | 48 if (extended_authenticator_.get()) |
49 extended_authenticator_->SetConsumer(NULL); | 49 extended_authenticator_->SetConsumer(NULL); |
50 } | 50 } |
51 | 51 |
52 //////////////////////////////////////////////////////////////////////////////// | 52 //////////////////////////////////////////////////////////////////////////////// |
53 // LoginPerformer, AuthStatusConsumer implementation: | 53 // LoginPerformer, AuthStatusConsumer implementation: |
54 | 54 |
55 void LoginPerformer::OnAuthFailure(const AuthFailure& failure) { | 55 void LoginPerformer::OnAuthFailure(const AuthFailure& failure) { |
56 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 56 DCHECK(task_runner_->RunsTasksInCurrentSequence()); |
57 base::RecordAction(UserMetricsAction("Login_Failure")); | 57 base::RecordAction(UserMetricsAction("Login_Failure")); |
58 | 58 |
59 UMA_HISTOGRAM_ENUMERATION("Login.FailureReason", | 59 UMA_HISTOGRAM_ENUMERATION("Login.FailureReason", |
60 failure.reason(), | 60 failure.reason(), |
61 AuthFailure::NUM_FAILURE_REASONS); | 61 AuthFailure::NUM_FAILURE_REASONS); |
62 | 62 |
63 LOG(ERROR) << "Login failure, reason=" << failure.reason() | 63 LOG(ERROR) << "Login failure, reason=" << failure.reason() |
64 << ", error.state=" << failure.error().state(); | 64 << ", error.state=" << failure.error().state(); |
65 | 65 |
66 last_login_failure_ = failure; | 66 last_login_failure_ = failure; |
67 if (delegate_) { | 67 if (delegate_) { |
68 delegate_->SetAuthFlowOffline(user_context_.GetAuthFlow() == | 68 delegate_->SetAuthFlowOffline(user_context_.GetAuthFlow() == |
69 UserContext::AUTH_FLOW_OFFLINE); | 69 UserContext::AUTH_FLOW_OFFLINE); |
70 delegate_->OnAuthFailure(failure); | 70 delegate_->OnAuthFailure(failure); |
71 return; | 71 return; |
72 } else { | 72 } else { |
73 // COULD_NOT_MOUNT_CRYPTOHOME, COULD_NOT_MOUNT_TMPFS: | 73 // COULD_NOT_MOUNT_CRYPTOHOME, COULD_NOT_MOUNT_TMPFS: |
74 // happens during offline auth only. | 74 // happens during offline auth only. |
75 NOTREACHED(); | 75 NOTREACHED(); |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 void LoginPerformer::OnAuthSuccess(const UserContext& user_context) { | 79 void LoginPerformer::OnAuthSuccess(const UserContext& user_context) { |
80 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 80 DCHECK(task_runner_->RunsTasksInCurrentSequence()); |
81 base::RecordAction(UserMetricsAction("Login_Success")); | 81 base::RecordAction(UserMetricsAction("Login_Success")); |
82 | 82 |
83 // Do not distinguish between offline and online success. | 83 // Do not distinguish between offline and online success. |
84 UMA_HISTOGRAM_ENUMERATION("Login.SuccessReason", OFFLINE_AND_ONLINE, | 84 UMA_HISTOGRAM_ENUMERATION("Login.SuccessReason", OFFLINE_AND_ONLINE, |
85 NUM_SUCCESS_REASONS); | 85 NUM_SUCCESS_REASONS); |
86 | 86 |
87 VLOG(1) << "LoginSuccess hash: " << user_context.GetUserIDHash(); | 87 VLOG(1) << "LoginSuccess hash: " << user_context.GetUserIDHash(); |
88 DCHECK(delegate_); | 88 DCHECK(delegate_); |
89 // After delegate_->OnAuthSuccess(...) is called, delegate_ releases | 89 // After delegate_->OnAuthSuccess(...) is called, delegate_ releases |
90 // LoginPerformer ownership. LP now manages it's lifetime on its own. | 90 // LoginPerformer ownership. LP now manages it's lifetime on its own. |
91 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 91 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
92 delegate_->OnAuthSuccess(user_context); | 92 delegate_->OnAuthSuccess(user_context); |
93 } | 93 } |
94 | 94 |
95 void LoginPerformer::OnOffTheRecordAuthSuccess() { | 95 void LoginPerformer::OnOffTheRecordAuthSuccess() { |
96 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 96 DCHECK(task_runner_->RunsTasksInCurrentSequence()); |
97 base::RecordAction(UserMetricsAction("Login_GuestLoginSuccess")); | 97 base::RecordAction(UserMetricsAction("Login_GuestLoginSuccess")); |
98 | 98 |
99 if (delegate_) | 99 if (delegate_) |
100 delegate_->OnOffTheRecordAuthSuccess(); | 100 delegate_->OnOffTheRecordAuthSuccess(); |
101 else | 101 else |
102 NOTREACHED(); | 102 NOTREACHED(); |
103 } | 103 } |
104 | 104 |
105 void LoginPerformer::OnPasswordChangeDetected() { | 105 void LoginPerformer::OnPasswordChangeDetected() { |
106 password_changed_ = true; | 106 password_changed_ = true; |
107 password_changed_callback_count_++; | 107 password_changed_callback_count_++; |
108 if (delegate_) { | 108 if (delegate_) { |
109 delegate_->OnPasswordChangeDetected(); | 109 delegate_->OnPasswordChangeDetected(); |
110 } else { | 110 } else { |
111 NOTREACHED(); | 111 NOTREACHED(); |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 void LoginPerformer::OnOldEncryptionDetected(const UserContext& user_context, | 115 void LoginPerformer::OnOldEncryptionDetected(const UserContext& user_context, |
116 bool has_incomplete_migration) { | 116 bool has_incomplete_migration) { |
117 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 117 DCHECK(task_runner_->RunsTasksInCurrentSequence()); |
118 | 118 |
119 if (delegate_) | 119 if (delegate_) |
120 delegate_->OnOldEncryptionDetected(user_context, has_incomplete_migration); | 120 delegate_->OnOldEncryptionDetected(user_context, has_incomplete_migration); |
121 else | 121 else |
122 NOTREACHED(); | 122 NOTREACHED(); |
123 } | 123 } |
124 | 124 |
125 //////////////////////////////////////////////////////////////////////////////// | 125 //////////////////////////////////////////////////////////////////////////////// |
126 // LoginPerformer, public: | 126 // LoginPerformer, public: |
127 | 127 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 } else { | 311 } else { |
312 NOTREACHED(); | 312 NOTREACHED(); |
313 } | 313 } |
314 user_context_.ClearSecrets(); | 314 user_context_.ClearSecrets(); |
315 } | 315 } |
316 | 316 |
317 void LoginPerformer::EnsureAuthenticator() { | 317 void LoginPerformer::EnsureAuthenticator() { |
318 authenticator_ = CreateAuthenticator(); | 318 authenticator_ = CreateAuthenticator(); |
319 } | 319 } |
320 } // namespace chromeos | 320 } // namespace chromeos |
OLD | NEW |