From f190b80b1fc8f964bdb14966b75c1b4c51a7b7f1 Mon Sep 17 00:00:00 2001 From: "dzhioev@chromium.org" Date: Tue, 18 Jun 2013 17:37:43 +0000 Subject: [PATCH] Refactored network prewarm for authentication. Signing profile not created during LoginUtils construction. LoginDisplayHost owns prewarm object. Prewarm object has certain lifetime. BUG=242592 TEST=manually Review URL: https://chromiumcodereview.appspot.com/17032004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207024 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/chromeos/login/auth_prewarmer.cc | 117 +++++++++++++++++ chrome/browser/chromeos/login/auth_prewarmer.h | 53 ++++++++ .../chromeos/login/existing_user_controller.cc | 1 - .../login/existing_user_controller_browsertest.cc | 2 - chrome/browser/chromeos/login/fake_login_utils.cc | 4 - chrome/browser/chromeos/login/fake_login_utils.h | 1 - chrome/browser/chromeos/login/login_display_host.h | 3 + .../chromeos/login/login_display_host_impl.cc | 16 ++- .../chromeos/login/login_display_host_impl.h | 8 ++ chrome/browser/chromeos/login/login_utils.cc | 140 +-------------------- chrome/browser/chromeos/login/login_utils.h | 3 - .../chromeos/login/mock_login_display_host.h | 1 + chrome/browser/chromeos/login/mock_login_utils.h | 1 - chrome/browser/chromeos/login/test_login_utils.h | 2 - chrome/browser/chromeos/login/wizard_controller.cc | 1 + chrome/chrome_browser_chromeos.gypi | 2 + 16 files changed, 201 insertions(+), 154 deletions(-) create mode 100644 chrome/browser/chromeos/login/auth_prewarmer.cc create mode 100644 chrome/browser/chromeos/login/auth_prewarmer.h diff --git a/chrome/browser/chromeos/login/auth_prewarmer.cc b/chrome/browser/chromeos/login/auth_prewarmer.cc new file mode 100644 index 000000000000..9f4471b88ae8 --- /dev/null +++ b/chrome/browser/chromeos/login/auth_prewarmer.cc @@ -0,0 +1,117 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/login/auth_prewarmer.h" + +#include "chrome/browser/chromeos/net/connectivity_state_helper.h" +#include "chrome/browser/chromeos/profiles/profile_helper.h" +#include "chrome/browser/net/chrome_url_request_context.h" +#include "chrome/browser/net/preconnect.h" +#include "chrome/common/chrome_notification_types.h" +#include "content/public/browser/browser_thread.h" +#include "google_apis/gaia/gaia_urls.h" +#include "googleurl/src/gurl.h" + +namespace chromeos { + +AuthPrewarmer::AuthPrewarmer() + : doing_prewarm_(false) { +} + +AuthPrewarmer::~AuthPrewarmer() { + if (registrar_.IsRegistered( + this, + chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, + content::Source(ProfileHelper::GetSigninProfile()))) { + registrar_.Remove( + this, + chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, + content::Source(ProfileHelper::GetSigninProfile())); + } + ConnectivityStateHelper::Get()->RemoveNetworkManagerObserver(this); +} + +void AuthPrewarmer::PrewarmAuthentication( + const base::Closure& completion_callback) { + if (doing_prewarm_) { + LOG(ERROR) << "PrewarmAuthentication called twice."; + return; + } + doing_prewarm_ = true; + completion_callback_ = completion_callback; + if (GetRequestContext() && IsNetworkConnected()) { + DoPrewarm(); + return; + } + if (!IsNetworkConnected()) + ConnectivityStateHelper::Get()->AddNetworkManagerObserver(this); + if (!GetRequestContext()) { + registrar_.Add( + this, + chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, + content::Source(ProfileHelper::GetSigninProfile())); + } +} + +void AuthPrewarmer::NetworkManagerChanged() { + if (IsNetworkConnected()) { + ConnectivityStateHelper::Get()->RemoveNetworkManagerObserver(this); + if (GetRequestContext()) + DoPrewarm(); + } +} + +void AuthPrewarmer::DefaultNetworkChanged() { + NetworkManagerChanged(); +} + +void AuthPrewarmer::Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) { + switch (type) { + case chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED: + registrar_.Remove( + this, + chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, + content::Source(ProfileHelper::GetSigninProfile())); + if (IsNetworkConnected()) + DoPrewarm(); + break; + default: + NOTREACHED(); + } +} + +void AuthPrewarmer::DoPrewarm() { + const int kConnectionsNeeded = 1; + + std::vector urls; + urls.push_back(GURL(GaiaUrls::GetInstance()->client_login_url())); + urls.push_back(GURL(GaiaUrls::GetInstance()->service_login_url())); + + for (size_t i = 0; i < urls.size(); ++i) { + chrome_browser_net::PreconnectOnUIThread( + urls[i], + urls[i], + chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, + kConnectionsNeeded, + GetRequestContext()); + } + if (!completion_callback_.is_null()) { + content::BrowserThread::PostTask(content::BrowserThread::UI, + FROM_HERE, + completion_callback_); + } +} + +bool AuthPrewarmer::IsNetworkConnected() const { + return ConnectivityStateHelper::Get()->IsConnected(); +} + +net::URLRequestContextGetter* AuthPrewarmer::GetRequestContext() const { + return ProfileHelper::GetSigninProfile()->GetRequestContext(); +} + +} // namespace chromeos + diff --git a/chrome/browser/chromeos/login/auth_prewarmer.h b/chrome/browser/chromeos/login/auth_prewarmer.h new file mode 100644 index 000000000000..aa77fa8b81a8 --- /dev/null +++ b/chrome/browser/chromeos/login/auth_prewarmer.h @@ -0,0 +1,53 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_PREWARMER_H_ +#define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_PREWARMER_H_ + +#include "base/basictypes.h" +#include "base/callback.h" +#include "chrome/browser/chromeos/net/connectivity_state_helper_observer.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" + +namespace net { +class URLRequestContextGetter; +} // namespace net + +namespace chromeos { + +// Class for prewarming authentication network connection. +class AuthPrewarmer : public ConnectivityStateHelperObserver, + public content::NotificationObserver { + public: + AuthPrewarmer(); + virtual ~AuthPrewarmer(); + + void PrewarmAuthentication(const base::Closure& completion_callback); + + private: + // chromeos::ConnectivityStateHelperObserver overrides. + virtual void NetworkManagerChanged() OVERRIDE; + virtual void DefaultNetworkChanged() OVERRIDE; + + // content::NotificationObserver overrides. + virtual void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) OVERRIDE; + + bool IsNetworkConnected() const; + net::URLRequestContextGetter* GetRequestContext() const; + void DoPrewarm(); + + content::NotificationRegistrar registrar_; + base::Closure completion_callback_; + bool doing_prewarm_; + + DISALLOW_COPY_AND_ASSIGN(AuthPrewarmer); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_PREWARMER_H_ + diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc index 7919b1bf25ac..505746bb46f2 100644 --- a/chrome/browser/chromeos/login/existing_user_controller.cc +++ b/chrome/browser/chromeos/login/existing_user_controller.cc @@ -169,7 +169,6 @@ void ExistingUserController::Init(const UserList& users) { UpdateLoginDisplay(users); ConfigurePublicSessionAutoLogin(); - LoginUtils::Get()->PrewarmAuthentication(); DBusThreadManager::Get()->GetSessionManagerClient()->EmitLoginPromptReady(); } diff --git a/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc b/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc index ce76b0d823c5..6acaf15b4665 100644 --- a/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc +++ b/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc @@ -102,8 +102,6 @@ class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest, mock_login_utils_ = new MockLoginUtils(); LoginUtils::Set(mock_login_utils_); - EXPECT_CALL(*mock_login_utils_, PrewarmAuthentication()) - .Times(AnyNumber()); EXPECT_CALL(*mock_login_utils_, StopBackgroundFetchers()) .Times(AnyNumber()); EXPECT_CALL(*mock_login_utils_, DelegateDeleted(_)) diff --git a/chrome/browser/chromeos/login/fake_login_utils.cc b/chrome/browser/chromeos/login/fake_login_utils.cc index b774f7dc9bed..675c9e2d152c 100644 --- a/chrome/browser/chromeos/login/fake_login_utils.cc +++ b/chrome/browser/chromeos/login/fake_login_utils.cc @@ -81,10 +81,6 @@ scoped_refptr FakeLoginUtils::CreateAuthenticator( return authenticator_; } -void FakeLoginUtils::PrewarmAuthentication() { - NOTREACHED() << "Method not implemented."; -} - void FakeLoginUtils::RestoreAuthenticationSession(Profile* profile) { NOTREACHED() << "Method not implemented."; } diff --git a/chrome/browser/chromeos/login/fake_login_utils.h b/chrome/browser/chromeos/login/fake_login_utils.h index 50977d8e4460..10f303679f66 100644 --- a/chrome/browser/chromeos/login/fake_login_utils.h +++ b/chrome/browser/chromeos/login/fake_login_utils.h @@ -33,7 +33,6 @@ class FakeLoginUtils : public LoginUtils { virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE; virtual scoped_refptr CreateAuthenticator( LoginStatusConsumer* consumer) OVERRIDE; - virtual void PrewarmAuthentication() OVERRIDE; virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; virtual void StopBackgroundFetchers() OVERRIDE; virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE; diff --git a/chrome/browser/chromeos/login/login_display_host.h b/chrome/browser/chromeos/login/login_display_host.h index 06117c97902b..72b83c589391 100644 --- a/chrome/browser/chromeos/login/login_display_host.h +++ b/chrome/browser/chromeos/login/login_display_host.h @@ -95,6 +95,9 @@ class LoginDisplayHost { // Invoked when system preferences that affect the signin screen have changed. virtual void OnPreferencesChanged() = 0; + + // Initiates authentication network prewarming. + virtual void PrewarmAuthentication() = 0; }; } // namespace chromeos diff --git a/chrome/browser/chromeos/login/login_display_host_impl.cc b/chrome/browser/chromeos/login/login_display_host_impl.cc index 124bb0d84a22..aa656d229775 100644 --- a/chrome/browser/chromeos/login/login_display_host_impl.cc +++ b/chrome/browser/chromeos/login/login_display_host_impl.cc @@ -171,7 +171,7 @@ LoginDisplayHostImpl::LoginDisplayHostImpl(const gfx::Rect& background_bounds) crash_count_(0), restore_path_(RESTORE_UNKNOWN), old_ignore_solo_window_frame_painter_policy_value_(false) { - // We need to listen to CLOSE_ALL_BROWSERS_REQUEST but not APP_TERMINATIN + // We need to listen to CLOSE_ALL_BROWSERS_REQUEST but not APP_TERMINATING // because/ APP_TERMINATING will never be fired as long as this keeps // ref-count. CLOSE_ALL_BROWSERS_REQUEST is safe here because there will be no // browser instance that will block the shutdown. @@ -431,6 +431,8 @@ void LoginDisplayHostImpl::StartSignInScreen() { restore_path_ = RESTORE_SIGN_IN; is_showing_login_ = true; + PrewarmAuthentication(); + if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_) { LOG(WARNING) << "Login WebUI >> sign in postponed"; return; @@ -499,6 +501,13 @@ void LoginDisplayHostImpl::OnPreferencesChanged() { webui_login_display_->OnPreferencesChanged(); } +void LoginDisplayHostImpl::PrewarmAuthentication() { + auth_prewarmer_.reset(new AuthPrewarmer()); + auth_prewarmer_->PrewarmAuthentication( + base::Bind(&LoginDisplayHostImpl::OnAuthPrewarmDone, + pointer_factory_.GetWeakPtr())); +} + //////////////////////////////////////////////////////////////////////////////// // LoginDisplayHostImpl, public @@ -810,6 +819,10 @@ bool LoginDisplayHostImpl::IsRunningUserAdding() { return restore_path_ == RESTORE_ADD_USER_INTO_SESSION; } +void LoginDisplayHostImpl::OnAuthPrewarmDone() { + auth_prewarmer_.reset(); +} + //////////////////////////////////////////////////////////////////////////////// // external @@ -937,7 +950,6 @@ void ShowLoginWizard(const std::string& first_screen_name) { scoped_ptr params; display_host->StartWizard(first_screen_name, params.Pass()); - chromeos::LoginUtils::Get()->PrewarmAuthentication(); chromeos::DBusThreadManager::Get()->GetSessionManagerClient() ->EmitLoginPromptReady(); TRACE_EVENT0("chromeos", "ShowLoginWizard::EmitLoginPromptReady"); diff --git a/chrome/browser/chromeos/login/login_display_host_impl.h b/chrome/browser/chromeos/login/login_display_host_impl.h index 59a431f6a5eb..14d8251ef77f 100644 --- a/chrome/browser/chromeos/login/login_display_host_impl.h +++ b/chrome/browser/chromeos/login/login_display_host_impl.h @@ -10,6 +10,7 @@ #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" +#include "chrome/browser/chromeos/login/auth_prewarmer.h" #include "chrome/browser/chromeos/login/existing_user_controller.h" #include "chrome/browser/chromeos/login/login_display.h" #include "chrome/browser/chromeos/login/login_display_host.h" @@ -69,6 +70,7 @@ class LoginDisplayHostImpl : public LoginDisplayHost, virtual void StartSignInScreen() OVERRIDE; virtual void ResumeSignInScreen() OVERRIDE; virtual void OnPreferencesChanged() OVERRIDE; + virtual void PrewarmAuthentication() OVERRIDE; // Creates WizardController instance. WizardController* CreateWizardController(); @@ -127,6 +129,9 @@ class LoginDisplayHostImpl : public LoginDisplayHost, // Returns true if hosr running UI for adding users into session. bool IsRunningUserAdding(); + // Deletes |auth_prewarmer_|. + void OnAuthPrewarmDone(); + // Used to calculate position of the screens and background. gfx::Rect background_bounds_; @@ -213,6 +218,9 @@ class LoginDisplayHostImpl : public LoginDisplayHost, // Called before host deletion. base::Closure completion_callback_; + // Active instance of authentication prewarmer. + scoped_ptr auth_prewarmer_; + DISALLOW_COPY_AND_ASSIGN(LoginDisplayHostImpl); }; diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc index 24cc11f62396..b6ec005608f3 100644 --- a/chrome/browser/chromeos/login/login_utils.cc +++ b/chrome/browser/chromeos/login/login_utils.cc @@ -16,6 +16,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" +#include "base/memory/weak_ptr.h" #include "base/path_service.h" #include "base/prefs/pref_member.h" #include "base/prefs/pref_registry_simple.h" @@ -40,9 +41,6 @@ #include "chrome/browser/chromeos/login/profile_auth_data.h" #include "chrome/browser/chromeos/login/screen_locker.h" #include "chrome/browser/chromeos/login/user_manager.h" -#include "chrome/browser/chromeos/net/connectivity_state_helper.h" -#include "chrome/browser/chromeos/net/connectivity_state_helper_observer.h" -#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/settings/cros_settings.h" #include "chrome/browser/chromeos/settings/cros_settings_names.h" #include "chrome/browser/extensions/extension_service.h" @@ -50,8 +48,6 @@ #include "chrome/browser/google/google_util_chromeos.h" #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/managed_mode/managed_mode.h" -#include "chrome/browser/net/chrome_url_request_context.h" -#include "chrome/browser/net/preconnect.h" #include "chrome/browser/pref_service_flags_storage.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" @@ -74,11 +70,8 @@ #include "chromeos/dbus/session_manager_client.h" #include "chromeos/ime/input_method_manager.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_service.h" #include "google_apis/gaia/gaia_auth_consumer.h" -#include "google_apis/gaia/gaia_constants.h" -#include "google_apis/gaia/gaia_urls.h" #include "googleurl/src/gurl.h" #include "net/base/network_change_notifier.h" #include "net/url_request/url_request_context.h" @@ -90,10 +83,6 @@ namespace chromeos { namespace { -// Affixes for Auth token received from ClientLogin request. -const char kAuthPrefix[] = "Auth="; -const char kAuthSuffix[] = "\n"; - #if defined(ENABLE_RLZ) // Flag file that disables RLZ tracking, when present. const base::FilePath::CharType kRLZDisabledFlagName[] = @@ -110,7 +99,6 @@ class LoginUtilsImpl : public LoginUtils, public OAuthLoginManager::Delegate, public net::NetworkChangeNotifier::ConnectionTypeObserver, - public content::NotificationObserver, public base::SupportsWeakPtr { public: LoginUtilsImpl() @@ -120,20 +108,8 @@ class LoginUtilsImpl delegate_(NULL), should_restore_auth_session_(false), session_restore_strategy_( - OAuthLoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN), - url_request_context_getter_(NULL) { + OAuthLoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN) { net::NetworkChangeNotifier::AddConnectionTypeObserver(this); - // During tests, the browser_process may not be initialized yet causing - // this to fail. - // TODO(dzhioev): Disabled in tests for a while. - // TODO(dzhioev): Move prewarm out of LoginUtils. - if (g_browser_process && - !CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType)) { - registrar_.Add( - this, - chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, - content::Source(ProfileHelper::GetSigninProfile())); - } } virtual ~LoginUtilsImpl() { @@ -155,7 +131,6 @@ class LoginUtilsImpl virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE; virtual scoped_refptr CreateAuthenticator( LoginStatusConsumer* consumer) OVERRIDE; - virtual void PrewarmAuthentication() OVERRIDE; virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; virtual void StopBackgroundFetchers() OVERRIDE; virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE; @@ -169,11 +144,6 @@ class LoginUtilsImpl virtual void OnConnectionTypeChanged( net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; - // content::NotificationObserver overrides. - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; - private: // Restarts OAuth session authentication check. void KickStartAuthentication(Profile* profile); @@ -240,12 +210,6 @@ class LoginUtilsImpl // OAuth2 refresh token for session restore. std::string oauth2_refresh_token_; - content::NotificationRegistrar registrar_; - - // This is set via a notification after the profile has initialized the - // getter. - net::URLRequestContextGetter* url_request_context_getter_; - DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl); }; @@ -750,88 +714,6 @@ scoped_refptr LoginUtilsImpl::CreateAuthenticator( return authenticator_; } -// We use a special class for this so that it can be safely leaked if we -// never connect. At shutdown the order is not well defined, and it's possible -// for the infrastructure needed to unregister might be unstable and crash. -class WarmingObserver : public ConnectivityStateHelperObserver, - public content::NotificationObserver { - public: - WarmingObserver() - : url_request_context_getter_(NULL) { - ConnectivityStateHelper::Get()->AddNetworkManagerObserver(this); - // During tests, the browser_process may not be initialized yet causing - // this to fail. - if (g_browser_process) { - registrar_.Add( - this, - chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, - content::Source(ProfileHelper::GetSigninProfile())); - } - } - - virtual ~WarmingObserver() {} - - // If we're now connected, prewarm the auth url. - virtual void NetworkManagerChanged() OVERRIDE { - ConnectivityStateHelper* csh = ConnectivityStateHelper::Get(); - if (csh->IsConnected()) { - const int kConnectionsNeeded = 1; - GURL url(GaiaUrls::GetInstance()->client_login_url()); - chrome_browser_net::PreconnectOnUIThread( - url, - url, - chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, - kConnectionsNeeded, - url_request_context_getter_); - csh->RemoveNetworkManagerObserver(this); - delete this; - } - } - - virtual void DefaultNetworkChanged() OVERRIDE { - NetworkManagerChanged(); - } - - // content::NotificationObserver overrides. - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE { - switch (type) { - case chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED: { - Profile* profile = content::Source(source).ptr(); - url_request_context_getter_ = profile->GetRequestContext(); - registrar_.Remove( - this, - chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, - content::Source(profile)); - - break; - } - default: - NOTREACHED(); - } -} - private: - net::URLRequestContextGetter* url_request_context_getter_; - content::NotificationRegistrar registrar_; -}; - -void LoginUtilsImpl::PrewarmAuthentication() { - ConnectivityStateHelper* csh = ConnectivityStateHelper::Get(); - if (csh->IsConnected()) { - const int kConnectionsNeeded = 1; - GURL url(GaiaUrls::GetInstance()->client_login_url()); - chrome_browser_net::PreconnectOnUIThread( - url, - url, - chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, - kConnectionsNeeded, - url_request_context_getter_); - } else { - new WarmingObserver(); - } -} - void LoginUtilsImpl::RestoreAuthenticationSession(Profile* user_profile) { // We don't need to restore session for demo/guest/stub/public account users. if (!UserManager::Get()->IsUserLoggedIn() || @@ -893,24 +775,6 @@ void LoginUtilsImpl::OnConnectionTypeChanged( } } -void LoginUtilsImpl::Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { - switch (type) { - case chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED: { - Profile* profile = content::Source(source).ptr(); - url_request_context_getter_ = profile->GetRequestContext(); - registrar_.Remove( - this, - chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, - content::Source(profile)); - break; - } - default: - NOTREACHED(); - } -} - // static void LoginUtils::RegisterPrefs(PrefRegistrySimple* registry) { registry->RegisterBooleanPref(prefs::kFactoryResetRequested, false); diff --git a/chrome/browser/chromeos/login/login_utils.h b/chrome/browser/chromeos/login/login_utils.h index f38a70cf7a68..b543e233a4fb 100644 --- a/chrome/browser/chromeos/login/login_utils.h +++ b/chrome/browser/chromeos/login/login_utils.h @@ -99,9 +99,6 @@ class LoginUtils { virtual scoped_refptr CreateAuthenticator( LoginStatusConsumer* consumer) = 0; - // Prewarms the authentication network connection. - virtual void PrewarmAuthentication() = 0; - // Restores authentication session after crash. virtual void RestoreAuthenticationSession(Profile* profile) = 0; diff --git a/chrome/browser/chromeos/login/mock_login_display_host.h b/chrome/browser/chromeos/login/mock_login_display_host.h index 3d2a574a64dd..1a03afb4b284 100644 --- a/chrome/browser/chromeos/login/mock_login_display_host.h +++ b/chrome/browser/chromeos/login/mock_login_display_host.h @@ -41,6 +41,7 @@ class MockLoginDisplayHost : public LoginDisplayHost { MOCK_METHOD0(StartSignInScreen, void(void)); MOCK_METHOD0(ResumeSignInScreen, void(void)); MOCK_METHOD0(OnPreferencesChanged, void(void)); + MOCK_METHOD0(PrewarmAuthentication, void(void)); private: DISALLOW_COPY_AND_ASSIGN(MockLoginDisplayHost); diff --git a/chrome/browser/chromeos/login/mock_login_utils.h b/chrome/browser/chromeos/login/mock_login_utils.h index a642ad549b8a..0710c9bfdab2 100644 --- a/chrome/browser/chromeos/login/mock_login_utils.h +++ b/chrome/browser/chromeos/login/mock_login_utils.h @@ -39,7 +39,6 @@ class MockLoginUtils : public LoginUtils { MOCK_METHOD1(SetFirstLoginPrefs, void(PrefService*)); MOCK_METHOD1(CreateAuthenticator, scoped_refptr(LoginStatusConsumer*)); - MOCK_METHOD0(PrewarmAuthentication, void(void)); MOCK_METHOD1(RestoreAuthenticationSession, void(Profile*)); MOCK_METHOD1(StartTokenServices, void(Profile*)); MOCK_METHOD2(TransferDefaultCookiesAndServerBoundCerts, diff --git a/chrome/browser/chromeos/login/test_login_utils.h b/chrome/browser/chromeos/login/test_login_utils.h index 74f8373ce804..b768d30d4eb2 100644 --- a/chrome/browser/chromeos/login/test_login_utils.h +++ b/chrome/browser/chromeos/login/test_login_utils.h @@ -43,8 +43,6 @@ class TestLoginUtils : public LoginUtils { virtual scoped_refptr CreateAuthenticator( LoginStatusConsumer* consumer) OVERRIDE; - virtual void PrewarmAuthentication() OVERRIDE {} - virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE {} virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE; diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc index 3e237f8a8a2f..bd835787095e 100644 --- a/chrome/browser/chromeos/login/wizard_controller.cc +++ b/chrome/browser/chromeos/login/wizard_controller.cc @@ -649,6 +649,7 @@ void WizardController::PerformPostEulaActions() { NetworkHandler::Get()->network_state_handler()->SetCheckPortalList( NetworkStateHandler::kDefaultCheckPortalList); host_->CheckForAutoEnrollment(); + host_->PrewarmAuthentication(); NetworkPortalDetector* detector = NetworkPortalDetector::GetInstance(); if (NetworkPortalDetector::IsEnabledInCommandLine() && detector) detector->Enable(true); diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi index 65f6cf1f28c6..687236085080 100644 --- a/chrome/chrome_browser_chromeos.gypi +++ b/chrome/chrome_browser_chromeos.gypi @@ -383,6 +383,8 @@ 'browser/chromeos/login/auth_attempt_state.h', 'browser/chromeos/login/auth_attempt_state_resolver.cc', 'browser/chromeos/login/auth_attempt_state_resolver.h', + 'browser/chromeos/login/auth_prewarmer.cc', + 'browser/chromeos/login/auth_prewarmer.h', 'browser/chromeos/login/authentication_notification_details.h', 'browser/chromeos/login/authenticator.cc', 'browser/chromeos/login/authenticator.h', -- 2.11.4.GIT