#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/strings/string_number_conversions.h"
-#include "chrome/browser/sync/managed_user_signin_manager_wrapper.h"
+#include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h"
#include "chrome/common/chrome_switches.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/sync_driver/sync_prefs.h"
ProfileSyncServiceStartBehavior start_behavior,
const ProfileOAuth2TokenService* token_service,
const sync_driver::SyncPrefs* sync_prefs,
- const ManagedUserSigninManagerWrapper* signin,
+ const SupervisedUserSigninManagerWrapper* signin,
base::Closure start_backend)
: received_start_request_(false),
setup_in_progress_(false),
start_backend_(start_backend),
fallback_timeout_(
base::TimeDelta::FromSeconds(kDeferredInitFallbackSeconds)),
+ first_start_(true),
weak_factory_(this) {
if (CommandLine::ForCurrentProcess()->HasSwitch(
int timeout = kDeferredInitFallbackSeconds;
if (base::StringToInt(CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kSyncDeferredStartupTimeoutSeconds), &timeout)) {
- DCHECK_GE(0, timeout);
+ DCHECK_GE(timeout, 0);
DVLOG(2) << "Sync StartupController overriding startup timeout to "
<< timeout << " seconds.";
fallback_timeout_ = base::TimeDelta::FromSeconds(timeout);
void StartupController::Reset(const syncer::ModelTypeSet registered_types) {
received_start_request_ = false;
- setup_in_progress_ = false;
start_up_time_ = base::Time();
start_backend_time_ = base::Time();
// Don't let previous timers affect us post-reset.
if (start_backend_time_.is_null()) {
start_backend_time_ = base::Time::Now();
start_backend_.Run();
+ first_start_ = false;
}
return true;
// for performance reasons and maximizing parallelism at chrome startup, we
// defer the heavy lifting for sync init until things have calmed down.
if (sync_prefs_->HasSyncSetupCompleted()) {
- if (!received_start_request_)
+ // For first time, defer start if data type hasn't requested sync to avoid
+ // stressing browser start. If |first_start_| is false, most likely the
+ // first attempt to start is intercepted by backup. When backup finishes,
+ // TryStart() is called again and we should start immediately to avoid
+ // unnecessary delay.
+ if (!received_start_request_ && first_start_)
return StartUp(STARTUP_BACKEND_DEFERRED);
else
return StartUp(STARTUP_IMMEDIATE);