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

Side by Side Diff: chrome/browser/chromeos/login/oauth2_login_verifier.cc

Issue 22264004: Remove ConnectivityStateHelper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang errors + fix nits Created 7 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/login/oauth2_login_verifier.h" 5 #include "chrome/browser/chromeos/login/oauth2_login_verifier.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "chrome/browser/chromeos/net/connectivity_state_helper.h"
15 #include "chrome/browser/signin/profile_oauth2_token_service.h" 14 #include "chrome/browser/signin/profile_oauth2_token_service.h"
16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 15 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
16 #include "chromeos/network/network_handler.h"
17 #include "chromeos/network/network_state.h"
18 #include "chromeos/network/network_state_handler.h"
17 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
18 #include "google_apis/gaia/gaia_constants.h" 20 #include "google_apis/gaia/gaia_constants.h"
19 #include "google_apis/gaia/gaia_urls.h" 21 #include "google_apis/gaia/gaia_urls.h"
22 #include "third_party/cros_system_api/dbus/service_constants.h"
20 23
21 using content::BrowserThread; 24 using content::BrowserThread;
22 25
23 namespace { 26 namespace {
24 27
25 // OAuth token request max retry count. 28 // OAuth token request max retry count.
26 const int kMaxRequestAttemptCount = 5; 29 const int kMaxRequestAttemptCount = 5;
27 // OAuth token request retry delay in milliseconds. 30 // OAuth token request retry delay in milliseconds.
28 const int kRequestRestartDelay = 3000; 31 const int kRequestRestartDelay = 3000;
29 32
(...skipping 13 matching lines...) Expand all
43 } 46 }
44 47
45 OAuth2LoginVerifier::~OAuth2LoginVerifier() { 48 OAuth2LoginVerifier::~OAuth2LoginVerifier() {
46 } 49 }
47 50
48 void OAuth2LoginVerifier::VerifyProfileTokens(Profile* profile) { 51 void OAuth2LoginVerifier::VerifyProfileTokens(Profile* profile) {
49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
50 53
51 // Delay the verification if the network is not connected or on a captive 54 // Delay the verification if the network is not connected or on a captive
52 // portal. 55 // portal.
53 ConnectivityStateHelper* csh = ConnectivityStateHelper::Get(); 56 const NetworkState* default_network =
54 if (!csh->DefaultNetworkOnline()) { 57 NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
58 if (!default_network ||
59 default_network->connection_state() == flimflam::kStatePortal) {
Nikita (slow) 2013/08/08 10:47:28 Previous implementation was: 173 bool Connectivit
gauravsh 2013/08/08 16:59:20 The check was redundant. A non-NULL DefaultNetwork
Nikita (slow) 2013/08/08 17:50:01 This block should be executed in 3 cases: 1. Netwo
gauravsh 2013/08/08 18:02:41 DefaultNetwork() already does the IsConnected() ch
stevenjb 2013/08/08 18:10:23 default_network is still NULL. With the new Netwo
Nikita (slow) 2013/08/09 09:44:00 Thanks for explanation.
55 // If network is offline, defer the token fetching until online. 60 // If network is offline, defer the token fetching until online.
56 VLOG(1) << "Network is offline. Deferring OAuth2 access token fetch."; 61 VLOG(1) << "Network is offline. Deferring OAuth2 access token fetch.";
57 BrowserThread::PostDelayedTask( 62 BrowserThread::PostDelayedTask(
58 BrowserThread::UI, 63 BrowserThread::UI,
59 FROM_HERE, 64 FROM_HERE,
60 base::Bind( 65 base::Bind(
61 &OAuth2LoginVerifier::VerifyProfileTokens, AsWeakPtr(), profile), 66 &OAuth2LoginVerifier::VerifyProfileTokens, AsWeakPtr(), profile),
62 base::TimeDelta::FromMilliseconds(kRequestRestartDelay)); 67 base::TimeDelta::FromMilliseconds(kRequestRestartDelay));
63 return; 68 return;
64 } 69 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 LOG(ERROR) << "Unrecoverable error or retry count max reached for " 223 LOG(ERROR) << "Unrecoverable error or retry count max reached for "
219 << operation_id; 224 << operation_id;
220 UMA_HISTOGRAM_ENUMERATION( 225 UMA_HISTOGRAM_ENUMERATION(
221 base::StringPrintf("OAuth2Login.%sFailure", operation_id), 226 base::StringPrintf("OAuth2Login.%sFailure", operation_id),
222 error.state(), 227 error.state(),
223 GoogleServiceAuthError::NUM_STATES); 228 GoogleServiceAuthError::NUM_STATES);
224 error_handler.Run(); 229 error_handler.Run();
225 } 230 }
226 231
227 } // namespace chromeos 232 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698