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

Side by Side Diff: chrome/browser/chromeos/policy/wildcard_login_checker.cc

Issue 181363002: Properly handle failure modes in the wildcard login check. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
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 "chrome/browser/chromeos/policy/wildcard_login_checker.h" 5 #include "chrome/browser/chromeos/policy/wildcard_login_checker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 void WildcardLoginChecker::OnGetUserInfoSuccess( 64 void WildcardLoginChecker::OnGetUserInfoSuccess(
65 const base::DictionaryValue* response) { 65 const base::DictionaryValue* response) {
66 if (!start_timestamp_.is_null()) { 66 if (!start_timestamp_.is_null()) {
67 base::Time now = base::Time::Now(); 67 base::Time now = base::Time::Now();
68 UMA_HISTOGRAM_MEDIUM_TIMES(kUMADelayUserInfoFetch, 68 UMA_HISTOGRAM_MEDIUM_TIMES(kUMADelayUserInfoFetch,
69 now - token_available_timestamp_); 69 now - token_available_timestamp_);
70 UMA_HISTOGRAM_MEDIUM_TIMES(kUMADelayTotal, 70 UMA_HISTOGRAM_MEDIUM_TIMES(kUMADelayTotal,
71 now - start_timestamp_); 71 now - start_timestamp_);
72 } 72 }
73 73
74 OnCheckCompleted(response->HasKey(kHostedDomainKey)); 74 OnCheckCompleted(response->HasKey(kHostedDomainKey) ? RESULT_ALLOWED
75 : RESULT_BLOCKED);
75 } 76 }
76 77
77 void WildcardLoginChecker::OnGetUserInfoFailure( 78 void WildcardLoginChecker::OnGetUserInfoFailure(
78 const GoogleServiceAuthError& error) { 79 const GoogleServiceAuthError& error) {
79 LOG(ERROR) << "Failed to fetch user info " << error.ToString(); 80 LOG(ERROR) << "Failed to fetch user info " << error.ToString();
80 OnCheckCompleted(false); 81 OnCheckCompleted(RESULT_FAILED);
81 } 82 }
82 83
83 void WildcardLoginChecker::OnPolicyTokenFetched( 84 void WildcardLoginChecker::OnPolicyTokenFetched(
84 const std::string& access_token, 85 const std::string& access_token,
85 const GoogleServiceAuthError& error) { 86 const GoogleServiceAuthError& error) {
86 if (error.state() != GoogleServiceAuthError::NONE) { 87 if (error.state() != GoogleServiceAuthError::NONE) {
87 LOG(ERROR) << "Failed to fetch policy token " << error.ToString(); 88 LOG(ERROR) << "Failed to fetch policy token " << error.ToString();
88 OnCheckCompleted(false); 89 OnCheckCompleted(RESULT_FAILED);
89 return; 90 return;
90 } 91 }
91 92
92 if (!start_timestamp_.is_null()) { 93 if (!start_timestamp_.is_null()) {
93 token_available_timestamp_ = base::Time::Now(); 94 token_available_timestamp_ = base::Time::Now();
94 UMA_HISTOGRAM_MEDIUM_TIMES(kUMADelayPolicyTokenFetch, 95 UMA_HISTOGRAM_MEDIUM_TIMES(kUMADelayPolicyTokenFetch,
95 token_available_timestamp_ - start_timestamp_); 96 token_available_timestamp_ - start_timestamp_);
96 } 97 }
97 98
98 token_fetcher_.reset(); 99 token_fetcher_.reset();
99 StartUserInfoFetcher(access_token); 100 StartUserInfoFetcher(access_token);
100 } 101 }
101 102
102 void WildcardLoginChecker::StartUserInfoFetcher( 103 void WildcardLoginChecker::StartUserInfoFetcher(
103 const std::string& access_token) { 104 const std::string& access_token) {
104 user_info_fetcher_.reset( 105 user_info_fetcher_.reset(
105 new UserInfoFetcher(this, g_browser_process->system_request_context())); 106 new UserInfoFetcher(this, g_browser_process->system_request_context()));
106 user_info_fetcher_->Start(access_token); 107 user_info_fetcher_->Start(access_token);
107 } 108 }
108 109
109 void WildcardLoginChecker::OnCheckCompleted(bool result) { 110 void WildcardLoginChecker::OnCheckCompleted(Result result) {
110 if (!callback_.is_null()) 111 if (!callback_.is_null())
111 callback_.Run(result); 112 callback_.Run(result);
112 } 113 }
113 114
114 } // namespace policy 115 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698