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

Unified Diff: components/sync_driver/startup_controller.cc

Issue 1858673002: [Sync] Inject startup dependencies into StartupController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/sync_driver/startup_controller.h ('k') | components/sync_driver/startup_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync_driver/startup_controller.cc
diff --git a/components/sync_driver/startup_controller.cc b/components/sync_driver/startup_controller.cc
index 631cdcce3466a2e60ab2bad542f0b951427be415..05532530cb2676b8b4b5f79961f8e1066964c527 100644
--- a/components/sync_driver/startup_controller.cc
+++ b/components/sync_driver/startup_controller.cc
@@ -12,8 +12,6 @@
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/thread_task_runner_handle.h"
-#include "components/signin/core/browser/profile_oauth2_token_service.h"
-#include "components/sync_driver/signin_manager_wrapper.h"
#include "components/sync_driver/sync_driver_switches.h"
#include "components/sync_driver/sync_prefs.h"
@@ -38,16 +36,13 @@ enum DeferredInitTrigger {
} // namespace
-StartupController::StartupController(
- const ProfileOAuth2TokenService* token_service,
- const sync_driver::SyncPrefs* sync_prefs,
- const SigninManagerWrapper* signin,
- base::Closure start_backend)
+StartupController::StartupController(const sync_driver::SyncPrefs* sync_prefs,
+ base::Callback<bool()> can_start,
+ base::Closure start_backend)
: received_start_request_(false),
setup_in_progress_(false),
sync_prefs_(sync_prefs),
- token_service_(token_service),
- signin_(signin),
+ can_start_(can_start),
start_backend_(start_backend),
fallback_timeout_(
base::TimeDelta::FromSeconds(kDeferredInitFallbackSeconds)),
@@ -119,29 +114,9 @@ void StartupController::OverrideFallbackTimeoutForTest(
}
bool StartupController::TryStart() {
- if (sync_prefs_->IsManaged())
+ if (!can_start_.Run())
return false;
- if (!sync_prefs_->IsSyncRequested())
- return false;
-
- if (signin_->GetAccountIdToUse().empty())
- return false;
-
- if (!token_service_)
- return false;
-
- if (!token_service_->RefreshTokenIsAvailable(signin_->GetAccountIdToUse())) {
- return false;
- }
-
- // TODO(tim): Seems wrong to always record this histogram here...
- // If we got here then tokens are loaded and user logged in and sync is
- // enabled. If OAuth refresh token is not available then something is wrong.
- // When PSS requests access token, OAuth2TokenService will return error and
- // PSS will show error to user asking to reauthenticate.
- UMA_HISTOGRAM_BOOLEAN("Sync.RefreshTokenAvailable", true);
-
// For performance reasons, defer the heavy lifting for sync init unless:
//
// - a datatype has requested an immediate start of sync, or
« no previous file with comments | « components/sync_driver/startup_controller.h ('k') | components/sync_driver/startup_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698