| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 return; | 337 return; |
| 338 } | 338 } |
| 339 expecting_first_run_auth_needed_event_ = true; | 339 expecting_first_run_auth_needed_event_ = true; |
| 340 DCHECK(!data_type_manager_.get()); | 340 DCHECK(!data_type_manager_.get()); |
| 341 | 341 |
| 342 StartUp(); | 342 StartUp(); |
| 343 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); | 343 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); |
| 344 } | 344 } |
| 345 | 345 |
| 346 void ProfileSyncService::DisableForUser() { | 346 void ProfileSyncService::DisableForUser() { |
| 347 if (WizardIsVisible()) { | |
| 348 // TODO(timsteele): Focus wizard. | |
| 349 return; | |
| 350 } | |
| 351 | |
| 352 LOG(INFO) << "Clearing Sync DB."; | 347 LOG(INFO) << "Clearing Sync DB."; |
| 353 | 348 |
| 354 // Clear prefs (including SyncSetupHasCompleted) before shutting down so | 349 // Clear prefs (including SyncSetupHasCompleted) before shutting down so |
| 355 // PSS clients don't think we're set up while we're shutting down. | 350 // PSS clients don't think we're set up while we're shutting down. |
| 356 ClearPreferences(); | 351 ClearPreferences(); |
| 357 Shutdown(true); | 352 Shutdown(true); |
| 358 | 353 |
| 359 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); | 354 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); |
| 360 } | 355 } |
| 361 | 356 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 | 413 |
| 419 // Tell the wizard so it can inform the user only if it is already open. | 414 // Tell the wizard so it can inform the user only if it is already open. |
| 420 wizard_.Step(SyncSetupWizard::FATAL_ERROR); | 415 wizard_.Step(SyncSetupWizard::FATAL_ERROR); |
| 421 | 416 |
| 422 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); | 417 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); |
| 423 LOG(ERROR) << "Unrecoverable error detected -- ProfileSyncService unusable."; | 418 LOG(ERROR) << "Unrecoverable error detected -- ProfileSyncService unusable."; |
| 424 std::string location; | 419 std::string location; |
| 425 from_here.Write(true, true, &location); | 420 from_here.Write(true, true, &location); |
| 426 LOG(ERROR) << location; | 421 LOG(ERROR) << location; |
| 427 | 422 |
| 428 if (WizardIsVisible()) { | 423 if (SetupInProgress()) { |
| 429 // We've hit an error in the middle of a startup process- shutdown all the | 424 // We've hit an error in the middle of a startup process- shutdown all the |
| 430 // backend stuff, and then restart it, so we're in the same state as before. | 425 // backend stuff, and then restart it, so we're in the same state as before. |
| 431 MessageLoop::current()->PostTask(FROM_HERE, | 426 MessageLoop::current()->PostTask(FROM_HERE, |
| 432 scoped_runnable_method_factory_.NewRunnableMethod( | 427 scoped_runnable_method_factory_.NewRunnableMethod( |
| 433 &ProfileSyncService::Shutdown, true)); | 428 &ProfileSyncService::Shutdown, true)); |
| 434 MessageLoop::current()->PostTask(FROM_HERE, | 429 MessageLoop::current()->PostTask(FROM_HERE, |
| 435 scoped_runnable_method_factory_.NewRunnableMethod( | 430 scoped_runnable_method_factory_.NewRunnableMethod( |
| 436 &ProfileSyncService::StartUp)); | 431 &ProfileSyncService::StartUp)); |
| 437 } | 432 } |
| 438 } | 433 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 UMA_HISTOGRAM_TIMES("Sync.AuthorizationTimeInNetwork", | 478 UMA_HISTOGRAM_TIMES("Sync.AuthorizationTimeInNetwork", |
| 484 base::TimeTicks::Now() - auth_start_time_); | 479 base::TimeTicks::Now() - auth_start_time_); |
| 485 auth_start_time_ = base::TimeTicks(); | 480 auth_start_time_ = base::TimeTicks(); |
| 486 } | 481 } |
| 487 | 482 |
| 488 is_auth_in_progress_ = false; | 483 is_auth_in_progress_ = false; |
| 489 // Fan the notification out to interested UI-thread components. | 484 // Fan the notification out to interested UI-thread components. |
| 490 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); | 485 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); |
| 491 } | 486 } |
| 492 | 487 |
| 488 void ProfileSyncService::OnStopSyncingPermanently() { |
| 489 if (SetupInProgress()) |
| 490 wizard_.Step(SyncSetupWizard::FATAL_ERROR); |
| 491 |
| 492 DisableForUser(); |
| 493 } |
| 494 |
| 493 void ProfileSyncService::ShowLoginDialog() { | 495 void ProfileSyncService::ShowLoginDialog() { |
| 494 if (WizardIsVisible()) { | 496 if (WizardIsVisible()) { |
| 495 wizard_.Focus(); | 497 wizard_.Focus(); |
| 496 return; | 498 return; |
| 497 } | 499 } |
| 498 | 500 |
| 499 if (!auth_error_time_.is_null()) { | 501 if (!auth_error_time_.is_null()) { |
| 500 UMA_HISTOGRAM_LONG_TIMES("Sync.ReauthorizationTime", | 502 UMA_HISTOGRAM_LONG_TIMES("Sync.ReauthorizationTime", |
| 501 base::TimeTicks::Now() - auth_error_time_); | 503 base::TimeTicks::Now() - auth_error_time_); |
| 502 auth_error_time_ = base::TimeTicks(); // Reset auth_error_time_ to null. | 504 auth_error_time_ = base::TimeTicks(); // Reset auth_error_time_ to null. |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 // is initialized, all enabled data types are consistent with one | 783 // is initialized, all enabled data types are consistent with one |
| 782 // another, and no unrecoverable error has transpired. | 784 // another, and no unrecoverable error has transpired. |
| 783 if (unrecoverable_error_detected_) | 785 if (unrecoverable_error_detected_) |
| 784 return false; | 786 return false; |
| 785 | 787 |
| 786 if (!data_type_manager_.get()) | 788 if (!data_type_manager_.get()) |
| 787 return false; | 789 return false; |
| 788 | 790 |
| 789 return data_type_manager_->state() == DataTypeManager::CONFIGURED; | 791 return data_type_manager_->state() == DataTypeManager::CONFIGURED; |
| 790 } | 792 } |
| OLD | NEW |