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

Side by Side Diff: components/browser_sync/profile_sync_service.cc

Issue 2106743002: WIP: Local sync only... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix after rebase. Created 4 years, 2 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
« no previous file with comments | « no previous file | components/sync/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/browser_sync/profile_sync_service.h" 5 #include "components/browser_sync/profile_sync_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 encrypt_everything_allowed_(true), 225 encrypt_everything_allowed_(true),
226 encrypt_everything_(false), 226 encrypt_everything_(false),
227 encryption_pending_(false), 227 encryption_pending_(false),
228 configure_status_(DataTypeManager::UNKNOWN), 228 configure_status_(DataTypeManager::UNKNOWN),
229 oauth2_token_service_(init_params.oauth2_token_service), 229 oauth2_token_service_(init_params.oauth2_token_service),
230 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy), 230 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy),
231 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED), 231 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED),
232 last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()), 232 last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()),
233 gaia_cookie_manager_service_(init_params.gaia_cookie_manager_service), 233 gaia_cookie_manager_service_(init_params.gaia_cookie_manager_service),
234 network_resources_(new syncer::HttpBridgeNetworkResources), 234 network_resources_(new syncer::HttpBridgeNetworkResources),
235 start_behavior_(init_params.start_behavior), 235 start_behavior_(AUTO_START /*init_params.start_behavior*/),
236 directory_path_( 236 directory_path_(
237 base_directory_.Append(base::FilePath(kSyncDataFolderName))), 237 base_directory_.Append(base::FilePath(kSyncDataFolderName))),
238 catch_up_configure_in_progress_(false), 238 catch_up_configure_in_progress_(false),
239 passphrase_prompt_triggered_by_version_(false), 239 passphrase_prompt_triggered_by_version_(false),
240 sync_enabled_weak_factory_(this), 240 sync_enabled_weak_factory_(this),
241 weak_factory_(this) { 241 weak_factory_(this) {
242 DCHECK(thread_checker_.CalledOnValidThread()); 242 DCHECK(thread_checker_.CalledOnValidThread());
243 DCHECK(sync_client_); 243 DCHECK(sync_client_);
244 std::string last_version = sync_prefs_.GetLastRunVersion(); 244 std::string last_version = sync_prefs_.GetLastRunVersion();
245 std::string current_version = PRODUCT_VERSION; 245 std::string current_version = PRODUCT_VERSION;
246 sync_prefs_.SetLastRunVersion(current_version); 246 sync_prefs_.SetLastRunVersion(current_version);
247 247
248 // Check for a major version change. Note that the versions have format 248 // Check for a major version change. Note that the versions have format
249 // MAJOR.MINOR.BUILD.PATCH. 249 // MAJOR.MINOR.BUILD.PATCH.
250 if (last_version.substr(0, last_version.find('.')) != 250 if (last_version.substr(0, last_version.find('.')) !=
251 current_version.substr(0, current_version.find('.'))) { 251 current_version.substr(0, current_version.find('.'))) {
252 passphrase_prompt_triggered_by_version_ = true; 252 passphrase_prompt_triggered_by_version_ = true;
253 } 253 }
254 } 254 }
255 255
256 ProfileSyncService::~ProfileSyncService() { 256 ProfileSyncService::~ProfileSyncService() {
257 if (gaia_cookie_manager_service_) 257 if (gaia_cookie_manager_service_)
258 gaia_cookie_manager_service_->RemoveObserver(this); 258 gaia_cookie_manager_service_->RemoveObserver(this);
259 sync_prefs_.RemoveSyncPrefObserver(this); 259 sync_prefs_.RemoveSyncPrefObserver(this);
260 // Shutdown() should have been called before destruction. 260 // Shutdown() should have been called before destruction.
261 CHECK(!backend_initialized_); 261 CHECK(!backend_initialized_);
262 } 262 }
263 263
264 bool ProfileSyncService::CanSyncStart() const { 264 bool ProfileSyncService::CanSyncStart() const {
265 return IsSyncAllowed() && IsSyncRequested() && IsSignedIn(); 265 // ### Only if needed.
266 return IsSyncAllowed() && IsSyncRequested();// && IsSignedIn();
266 } 267 }
267 268
268 void ProfileSyncService::Initialize() { 269 void ProfileSyncService::Initialize() {
270 LOG(ERROR) << "@@@@ INIT CALLED";
271 //sync_prefs_.SetFirstSetupComplete();
269 sync_client_->Initialize(); 272 sync_client_->Initialize();
270 273
271 // We don't pass StartupController an Unretained reference to future-proof 274 // We don't pass StartupController an Unretained reference to future-proof
272 // against the controller impl changing to post tasks. 275 // against the controller impl changing to post tasks.
273 startup_controller_.reset(new browser_sync::StartupController( 276 startup_controller_.reset(new browser_sync::StartupController(
274 &sync_prefs_, 277 &sync_prefs_,
275 base::Bind(&ProfileSyncService::CanBackendStart, base::Unretained(this)), 278 base::Bind(&ProfileSyncService::CanBackendStart, base::Unretained(this)),
276 base::Bind(&ProfileSyncService::StartUpSlowBackendComponents, 279 base::Bind(&ProfileSyncService::StartUpSlowBackendComponents,
277 weak_factory_.GetWeakPtr()))); 280 weak_factory_.GetWeakPtr())));
278 std::unique_ptr<sync_sessions::LocalSessionEventRouter> router( 281 std::unique_ptr<sync_sessions::LocalSessionEventRouter> router(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 device_info_sync_service_.reset( 314 device_info_sync_service_.reset(
312 new DeviceInfoSyncService(local_device_.get())); 315 new DeviceInfoSyncService(local_device_.get()));
313 } 316 }
314 317
315 sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod 318 sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod
316 register_platform_types_callback = 319 register_platform_types_callback =
317 sync_client_->GetRegisterPlatformTypesCallback(); 320 sync_client_->GetRegisterPlatformTypesCallback();
318 sync_client_->GetSyncApiComponentFactory()->RegisterDataTypes( 321 sync_client_->GetSyncApiComponentFactory()->RegisterDataTypes(
319 this, register_platform_types_callback); 322 this, register_platform_types_callback);
320 323
321 if (gaia_cookie_manager_service_) 324
322 gaia_cookie_manager_service_->AddObserver(this); 325 // ### We have to change this to only do it if needed.
326 // if (gaia_cookie_manager_service_)
327 // gaia_cookie_manager_service_->AddObserver(this);
323 328
324 // We clear this here (vs Shutdown) because we want to remember that an error 329 // We clear this here (vs Shutdown) because we want to remember that an error
325 // happened on shutdown so we can display details (message, location) about it 330 // happened on shutdown so we can display details (message, location) about it
326 // in about:sync. 331 // in about:sync.
327 ClearStaleErrors(); 332 ClearStaleErrors();
328 333
329 sync_prefs_.AddSyncPrefObserver(this); 334 sync_prefs_.AddSyncPrefObserver(this);
330 335
336 // Only for UMA purposes :(
331 SyncInitialState sync_state = CAN_START; 337 SyncInitialState sync_state = CAN_START;
332 if (!IsSignedIn()) { 338 /*if (!IsSignedIn()) {
333 sync_state = NOT_SIGNED_IN; 339 sync_state = NOT_SIGNED_IN;
334 } else if (IsManaged()) { 340 } else*/ if (IsManaged()) {
335 sync_state = IS_MANAGED; 341 sync_state = IS_MANAGED;
336 } else if (!IsSyncAllowedByPlatform()) { 342 } else if (!IsSyncAllowedByPlatform()) {
337 // This case should currently never be hit, as Android's master sync isn't 343 // This case should currently never be hit, as Android's master sync isn't
338 // plumbed into PSS until after this function. See http://crbug.com/568771. 344 // plumbed into PSS until after this function. See http://crbug.com/568771.
339 sync_state = NOT_ALLOWED_BY_PLATFORM; 345 sync_state = NOT_ALLOWED_BY_PLATFORM;
340 } else if (!IsSyncRequested()) { 346 } else if (!IsSyncRequested()) {
341 if (IsFirstSetupComplete()) { 347 if (IsFirstSetupComplete()) {
342 sync_state = NOT_REQUESTED; 348 sync_state = NOT_REQUESTED;
343 } else { 349 } else {
344 sync_state = NOT_REQUESTED_NOT_SETUP; 350 sync_state = NOT_REQUESTED_NOT_SETUP;
345 } 351 }
346 } else if (!IsFirstSetupComplete()) { 352 } else if (!IsFirstSetupComplete()) {
347 sync_state = NEEDS_CONFIRMATION; 353 sync_state = NEEDS_CONFIRMATION;
348 } 354 }
349 UMA_HISTOGRAM_ENUMERATION("Sync.InitialState", sync_state, 355 UMA_HISTOGRAM_ENUMERATION("Sync.InitialState", sync_state,
350 SYNC_INITIAL_STATE_LIMIT); 356 SYNC_INITIAL_STATE_LIMIT);
351 357
352 // If sync isn't allowed, the only thing to do is to turn it off. 358 // If sync isn't allowed, the only thing to do is to turn it off.
353 if (!IsSyncAllowed()) { 359 if (!IsSyncAllowed()) {
354 // Only clear data if disallowed by policy. 360 // Only clear data if disallowed by policy.
355 RequestStop(IsManaged() ? CLEAR_DATA : KEEP_DATA); 361 RequestStop(IsManaged() ? CLEAR_DATA : KEEP_DATA);
356 return; 362 return;
357 } 363 }
358 364
359 RegisterAuthNotifications(); 365 // ### We should do this only if needed.
366 // RegisterAuthNotifications();
360 367
361 if (!IsSignedIn()) { 368 // ### We should do this only if needed.
362 // Clean up in case of previous crash during signout. 369 // if (!IsSignedIn()) {
363 StopImpl(CLEAR_DATA); 370 // // Clean up in case of previous crash during signout.
364 } 371 // StopImpl(CLEAR_DATA);
372 // }
365 373
366 #if defined(OS_CHROMEOS) 374 #if defined(OS_CHROMEOS)
367 std::string bootstrap_token = sync_prefs_.GetEncryptionBootstrapToken(); 375 std::string bootstrap_token = sync_prefs_.GetEncryptionBootstrapToken();
368 if (bootstrap_token.empty()) { 376 if (bootstrap_token.empty()) {
369 sync_prefs_.SetEncryptionBootstrapToken( 377 sync_prefs_.SetEncryptionBootstrapToken(
370 sync_prefs_.GetSpareBootstrapToken()); 378 sync_prefs_.GetSpareBootstrapToken());
371 } 379 }
372 #endif 380 #endif
373 381
374 #if !defined(OS_ANDROID) 382 #if !defined(OS_ANDROID)
375 DCHECK(sync_error_controller_ == NULL) 383 DCHECK(sync_error_controller_ == NULL)
376 << "Initialize() called more than once."; 384 << "Initialize() called more than once.";
377 sync_error_controller_.reset(new SyncErrorController(this)); 385 sync_error_controller_.reset(new SyncErrorController(this));
378 AddObserver(sync_error_controller_.get()); 386 AddObserver(sync_error_controller_.get());
379 #endif 387 #endif
380 388
381 memory_pressure_listener_.reset(new base::MemoryPressureListener( 389 memory_pressure_listener_.reset(new base::MemoryPressureListener(
382 base::Bind(&ProfileSyncService::OnMemoryPressure, 390 base::Bind(&ProfileSyncService::OnMemoryPressure,
383 sync_enabled_weak_factory_.GetWeakPtr()))); 391 sync_enabled_weak_factory_.GetWeakPtr())));
384 startup_controller_->Reset(GetRegisteredDataTypes()); 392 startup_controller_->Reset(GetRegisteredDataTypes());
385 393
386 // Auto-start means means the first time the profile starts up, sync should 394 // Auto-start means the first time the profile starts up, sync should start up
387 // start up immediately. 395 // immediately.
388 if (start_behavior_ == AUTO_START && IsSyncRequested() && 396 if (start_behavior_ == AUTO_START && IsSyncRequested() &&
389 !IsFirstSetupComplete()) { 397 !IsFirstSetupComplete()) {
390 startup_controller_->TryStartImmediately(); 398 startup_controller_->TryStartImmediately();
391 } else { 399 } else {
392 startup_controller_->TryStart(); 400 startup_controller_->TryStart();
393 } 401 }
394 } 402 }
395 403
396 void ProfileSyncService::StartSyncingWithServer() { 404 void ProfileSyncService::StartSyncingWithServer() {
397 DCHECK(thread_checker_.CalledOnValidThread()); 405 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 506
499 bool ProfileSyncService::ShouldDeleteSyncFolder() { 507 bool ProfileSyncService::ShouldDeleteSyncFolder() {
500 return !IsFirstSetupComplete(); 508 return !IsFirstSetupComplete();
501 } 509 }
502 510
503 void ProfileSyncService::InitializeBackend(bool delete_stale_data) { 511 void ProfileSyncService::InitializeBackend(bool delete_stale_data) {
504 if (!backend_) { 512 if (!backend_) {
505 NOTREACHED(); 513 NOTREACHED();
506 return; 514 return;
507 } 515 }
516 LOG(ERROR) << "@@@ ProfileSyncService::InitializeBackend";
508 517
509 SyncCredentials credentials = GetCredentials(); 518 // ### Only do this if needed.
519 SyncCredentials credentials;// = GetCredentials();
510 520
511 if (delete_stale_data) 521 if (delete_stale_data)
512 ClearStaleErrors(); 522 ClearStaleErrors();
513 523
524 // ### Only do this if needed.
514 SyncBackendHost::HttpPostProviderFactoryGetter 525 SyncBackendHost::HttpPostProviderFactoryGetter
515 http_post_provider_factory_getter = 526 http_post_provider_factory_getter =
516 base::Bind(&syncer::NetworkResources::GetHttpPostProviderFactory, 527 base::Bind(&syncer::NetworkResources::GetHttpPostProviderFactory,
517 base::Unretained(network_resources_.get()), 528 base::Unretained(network_resources_.get()),
518 url_request_context_, network_time_update_callback_); 529 url_request_context_, network_time_update_callback_);
519 530
520 backend_->Initialize( 531 backend_->Initialize(
521 this, std::move(sync_thread_), db_thread_, file_thread_, 532 this, std::move(sync_thread_), db_thread_, file_thread_,
522 GetJsEventHandler(), sync_service_url_, local_device_->GetSyncUserAgent(), 533 GetJsEventHandler(), sync_service_url_, local_device_->GetSyncUserAgent(),
523 credentials, delete_stale_data, 534 credentials, delete_stale_data,
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 std::vector<gaia::ListedAccount> accounts; 971 std::vector<gaia::ListedAccount> accounts;
961 std::vector<gaia::ListedAccount> signed_out_accounts; 972 std::vector<gaia::ListedAccount> signed_out_accounts;
962 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); 973 GoogleServiceAuthError error(GoogleServiceAuthError::NONE);
963 if (gaia_cookie_manager_service_ && 974 if (gaia_cookie_manager_service_ &&
964 gaia_cookie_manager_service_->ListAccounts( 975 gaia_cookie_manager_service_->ListAccounts(
965 &accounts, &signed_out_accounts, "ChromiumProfileSyncService")) { 976 &accounts, &signed_out_accounts, "ChromiumProfileSyncService")) {
966 OnGaiaAccountsInCookieUpdated(accounts, signed_out_accounts, error); 977 OnGaiaAccountsInCookieUpdated(accounts, signed_out_accounts, error);
967 } 978 }
968 979
969 NotifyObservers(); 980 NotifyObservers();
981 RequestStart();
970 } 982 }
971 983
972 void ProfileSyncService::OnBackendInitialized( 984 void ProfileSyncService::OnBackendInitialized(
973 const syncer::WeakHandle<syncer::JsBackend>& js_backend, 985 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
974 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& 986 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
975 debug_info_listener, 987 debug_info_listener,
976 const std::string& cache_guid, 988 const std::string& cache_guid,
977 bool success) { 989 bool success) {
978 UpdateBackendInitUMA(success); 990 UpdateBackendInitUMA(success);
991 LOG(ERROR) << "@@@@ ProfileSyncService::OnBackendInitialized is " << success;
979 992
980 if (!success) { 993 if (!success) {
981 // Something went unexpectedly wrong. Play it safe: stop syncing at once 994 // Something went unexpectedly wrong. Play it safe: stop syncing at once
982 // and surface error UI to alert the user sync has stopped. 995 // and surface error UI to alert the user sync has stopped.
983 // Keep the directory around for now so that on restart we will retry 996 // Keep the directory around for now so that on restart we will retry
984 // again and potentially succeed in presence of transient file IO failures 997 // again and potentially succeed in presence of transient file IO failures
985 // or permissions issues, etc. 998 // or permissions issues, etc.
986 // 999 //
987 // TODO(rlarocque): Consider making this UnrecoverableError less special. 1000 // TODO(rlarocque): Consider making this UnrecoverableError less special.
988 // Unlike every other UnrecoverableError, it does not delete our sync data. 1001 // Unlike every other UnrecoverableError, it does not delete our sync data.
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 migrator_->OnConfigureDone(result); 1408 migrator_->OnConfigureDone(result);
1396 return; 1409 return;
1397 } 1410 }
1398 1411
1399 if (catch_up_configure_in_progress_) { 1412 if (catch_up_configure_in_progress_) {
1400 catch_up_configure_in_progress_ = false; 1413 catch_up_configure_in_progress_ = false;
1401 ClearAndRestartSyncForPassphraseEncryption(); 1414 ClearAndRestartSyncForPassphraseEncryption();
1402 return; 1415 return;
1403 } 1416 }
1404 1417
1418 LOG(ERROR) << "@@@ Start syncing";
1405 StartSyncingWithServer(); 1419 StartSyncingWithServer();
1406 } 1420 }
1407 1421
1408 void ProfileSyncService::OnConfigureStart() { 1422 void ProfileSyncService::OnConfigureStart() {
1409 sync_configure_start_time_ = base::Time::Now(); 1423 sync_configure_start_time_ = base::Time::Now();
1410 NotifyObservers(); 1424 NotifyObservers();
1411 } 1425 }
1412 1426
1413 ProfileSyncService::SyncStatusSummary 1427 ProfileSyncService::SyncStatusSummary
1414 ProfileSyncService::QuerySyncStatusSummary() { 1428 ProfileSyncService::QuerySyncStatusSummary() {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 data_type_manager_->state() != DataTypeManager::STOPPED; 1522 data_type_manager_->state() != DataTypeManager::STOPPED;
1509 } 1523 }
1510 1524
1511 void ProfileSyncService::TriggerRefresh(const syncer::ModelTypeSet& types) { 1525 void ProfileSyncService::TriggerRefresh(const syncer::ModelTypeSet& types) {
1512 if (backend_initialized_) 1526 if (backend_initialized_)
1513 backend_->TriggerRefresh(types); 1527 backend_->TriggerRefresh(types);
1514 } 1528 }
1515 1529
1516 bool ProfileSyncService::IsSignedIn() const { 1530 bool ProfileSyncService::IsSignedIn() const {
1517 // Sync is logged in if there is a non-empty effective account id. 1531 // Sync is logged in if there is a non-empty effective account id.
1518 return !signin_->GetAccountIdToUse().empty(); 1532 NOTREACHED() << "@@@ WHy do you even ask";
1533 return true;
1534 //return !signin_->GetAccountIdToUse().empty();
1519 } 1535 }
1520 1536
1521 bool ProfileSyncService::CanBackendStart() const { 1537 bool ProfileSyncService::CanBackendStart() const {
1522 return CanSyncStart() && oauth2_token_service_ && 1538 // ### Only if needed.
1539 return CanSyncStart() /*&& oauth2_token_service_ &&
1523 oauth2_token_service_->RefreshTokenIsAvailable( 1540 oauth2_token_service_->RefreshTokenIsAvailable(
1524 signin_->GetAccountIdToUse()); 1541 signin_->GetAccountIdToUse())*/;
1525 } 1542 }
1526 1543
1527 bool ProfileSyncService::IsBackendInitialized() const { 1544 bool ProfileSyncService::IsBackendInitialized() const {
1528 return backend_initialized_; 1545 return backend_initialized_;
1529 } 1546 }
1530 1547
1531 bool ProfileSyncService::ConfigurationDone() const { 1548 bool ProfileSyncService::ConfigurationDone() const {
1532 return data_type_manager_ && 1549 return data_type_manager_ &&
1533 data_type_manager_->state() == DataTypeManager::CONFIGURED; 1550 data_type_manager_->state() == DataTypeManager::CONFIGURED;
1534 } 1551 }
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
2297 return sync_prefs_.IsSyncRequested(); 2314 return sync_prefs_.IsSyncRequested();
2298 } 2315 }
2299 2316
2300 SigninManagerBase* ProfileSyncService::signin() const { 2317 SigninManagerBase* ProfileSyncService::signin() const {
2301 if (!signin_) 2318 if (!signin_)
2302 return NULL; 2319 return NULL;
2303 return signin_->GetOriginal(); 2320 return signin_->GetOriginal();
2304 } 2321 }
2305 2322
2306 void ProfileSyncService::RequestStart() { 2323 void ProfileSyncService::RequestStart() {
2324 LOG(ERROR) << "@@@@ Requesting start";
2307 if (!IsSyncAllowed()) { 2325 if (!IsSyncAllowed()) {
2308 // Sync cannot be requested if it's not allowed. 2326 // Sync cannot be requested if it's not allowed.
2309 return; 2327 return;
2310 } 2328 }
2311 DCHECK(sync_client_); 2329 DCHECK(sync_client_);
2312 if (!IsSyncRequested()) { 2330 if (!IsSyncRequested()) {
2313 sync_prefs_.SetSyncRequested(true); 2331 sync_prefs_.SetSyncRequested(true);
2314 NotifyObservers(); 2332 NotifyObservers();
2315 } 2333 }
2316 startup_controller_->TryStartImmediately(); 2334 startup_controller_->TryStartImmediately();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 void ProfileSyncService::OverrideNetworkResourcesForTest( 2417 void ProfileSyncService::OverrideNetworkResourcesForTest(
2400 std::unique_ptr<syncer::NetworkResources> network_resources) { 2418 std::unique_ptr<syncer::NetworkResources> network_resources) {
2401 network_resources_ = std::move(network_resources); 2419 network_resources_ = std::move(network_resources);
2402 } 2420 }
2403 2421
2404 bool ProfileSyncService::HasSyncingBackend() const { 2422 bool ProfileSyncService::HasSyncingBackend() const {
2405 return backend_ != NULL; 2423 return backend_ != NULL;
2406 } 2424 }
2407 2425
2408 void ProfileSyncService::UpdateFirstSyncTimePref() { 2426 void ProfileSyncService::UpdateFirstSyncTimePref() {
2409 if (!IsSignedIn()) { 2427 // ### Only if needed.
2428 /*if (!IsSignedIn()) {
2410 sync_prefs_.ClearFirstSyncTime(); 2429 sync_prefs_.ClearFirstSyncTime();
2411 } else if (sync_prefs_.GetFirstSyncTime().is_null()) { 2430 } else*/ if (sync_prefs_.GetFirstSyncTime().is_null()) {
2412 // Set if not set before and it's syncing now. 2431 // Set if not set before and it's syncing now.
2413 sync_prefs_.SetFirstSyncTime(base::Time::Now()); 2432 sync_prefs_.SetFirstSyncTime(base::Time::Now());
2414 } 2433 }
2415 } 2434 }
2416 2435
2417 void ProfileSyncService::FlushDirectory() const { 2436 void ProfileSyncService::FlushDirectory() const {
2418 // backend_initialized_ implies backend_ isn't NULL and the manager exists. 2437 // backend_initialized_ implies backend_ isn't NULL and the manager exists.
2419 // If sync is not initialized yet, we fail silently. 2438 // If sync is not initialized yet, we fail silently.
2420 if (backend_initialized_) 2439 if (backend_initialized_)
2421 backend_->FlushDirectory(); 2440 backend_->FlushDirectory();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2503 if (--outstanding_setup_in_progress_handles_ != 0) 2522 if (--outstanding_setup_in_progress_handles_ != 0)
2504 return; 2523 return;
2505 2524
2506 DCHECK(startup_controller_->IsSetupInProgress()); 2525 DCHECK(startup_controller_->IsSetupInProgress());
2507 startup_controller_->SetSetupInProgress(false); 2526 startup_controller_->SetSetupInProgress(false);
2508 2527
2509 if (IsBackendInitialized()) 2528 if (IsBackendInitialized())
2510 ReconfigureDatatypeManager(); 2529 ReconfigureDatatypeManager();
2511 NotifyObservers(); 2530 NotifyObservers();
2512 } 2531 }
OLDNEW
« no previous file with comments | « no previous file | components/sync/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698