| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 case syncable::TYPED_URLS: | 393 case syncable::TYPED_URLS: |
| 394 return prefs::kSyncTypedUrls; | 394 return prefs::kSyncTypedUrls; |
| 395 default: | 395 default: |
| 396 NOTREACHED(); | 396 NOTREACHED(); |
| 397 return NULL; | 397 return NULL; |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| 401 // An invariant has been violated. Transition to an error state where we try | 401 // An invariant has been violated. Transition to an error state where we try |
| 402 // to do as little work as possible, to avoid further corruption or crashes. | 402 // to do as little work as possible, to avoid further corruption or crashes. |
| 403 void ProfileSyncService::OnUnrecoverableError() { | 403 void ProfileSyncService::OnUnrecoverableError( |
| 404 const tracked_objects::Location& from_here, |
| 405 const std::string& message) { |
| 404 unrecoverable_error_detected_ = true; | 406 unrecoverable_error_detected_ = true; |
| 405 // TODO(sync) remove this unrecoverable_error_detected_ variable_ as it only | 407 unrecoverable_error_message_ = message; |
| 406 // affects ShouldPushChanges(). | 408 unrecoverable_error_location_.reset( |
| 409 new tracked_objects::Location(from_here.function_name(), |
| 410 from_here.file_name(), |
| 411 from_here.line_number())); |
| 407 | 412 |
| 408 // Shut all data types down. | 413 // Shut all data types down. |
| 409 if (data_type_manager_.get()) | 414 if (data_type_manager_.get()) |
| 410 data_type_manager_->Stop(); | 415 data_type_manager_->Stop(); |
| 411 | 416 |
| 412 // Tell the wizard so it can inform the user only if it is already open. | 417 // Tell the wizard so it can inform the user only if it is already open. |
| 413 wizard_.Step(SyncSetupWizard::FATAL_ERROR); | 418 wizard_.Step(SyncSetupWizard::FATAL_ERROR); |
| 414 | 419 |
| 415 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); | 420 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); |
| 416 LOG(ERROR) << "Unrecoverable error detected -- ProfileSyncService unusable."; | 421 LOG(ERROR) << "Unrecoverable error detected -- ProfileSyncService unusable."; |
| 422 std::string location; |
| 423 from_here.Write(true, true, &location); |
| 424 LOG(ERROR) << location; |
| 417 | 425 |
| 418 if (WizardIsVisible()) { | 426 if (WizardIsVisible()) { |
| 419 // We've hit an error in the middle of a startup process- shutdown all the | 427 // We've hit an error in the middle of a startup process- shutdown all the |
| 420 // backend stuff, and then restart it, so we're in the same state as before. | 428 // backend stuff, and then restart it, so we're in the same state as before. |
| 421 MessageLoop::current()->PostTask(FROM_HERE, | 429 MessageLoop::current()->PostTask(FROM_HERE, |
| 422 scoped_runnable_method_factory_.NewRunnableMethod( | 430 scoped_runnable_method_factory_.NewRunnableMethod( |
| 423 &ProfileSyncService::Shutdown, true)); | 431 &ProfileSyncService::Shutdown, true)); |
| 424 MessageLoop::current()->PostTask(FROM_HERE, | 432 MessageLoop::current()->PostTask(FROM_HERE, |
| 425 scoped_runnable_method_factory_.NewRunnableMethod( | 433 scoped_runnable_method_factory_.NewRunnableMethod( |
| 426 &ProfileSyncService::StartUp)); | 434 &ProfileSyncService::StartUp)); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 switch (type.value) { | 679 switch (type.value) { |
| 672 case NotificationType::SYNC_CONFIGURE_START: { | 680 case NotificationType::SYNC_CONFIGURE_START: { |
| 673 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); | 681 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); |
| 674 // TODO(sync): Maybe toast? | 682 // TODO(sync): Maybe toast? |
| 675 break; | 683 break; |
| 676 } | 684 } |
| 677 case NotificationType::SYNC_CONFIGURE_DONE: { | 685 case NotificationType::SYNC_CONFIGURE_DONE: { |
| 678 DataTypeManager::ConfigureResult result = | 686 DataTypeManager::ConfigureResult result = |
| 679 *(Details<DataTypeManager::ConfigureResult>(details).ptr()); | 687 *(Details<DataTypeManager::ConfigureResult>(details).ptr()); |
| 680 if (result != DataTypeManager::OK) { | 688 if (result != DataTypeManager::OK) { |
| 681 OnUnrecoverableError(); | 689 OnUnrecoverableError(FROM_HERE, "Sync Configuration failed."); |
| 682 return; | 690 return; |
| 683 } | 691 } |
| 684 | 692 |
| 685 // TODO(sync): Less wizard, more toast. | 693 // TODO(sync): Less wizard, more toast. |
| 686 wizard_.Step(SyncSetupWizard::DONE); | 694 wizard_.Step(SyncSetupWizard::DONE); |
| 687 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); | 695 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); |
| 688 break; | 696 break; |
| 689 } | 697 } |
| 690 default: { | 698 default: { |
| 691 NOTREACHED(); | 699 NOTREACHED(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 716 // is initialized, all enabled data types are consistent with one | 724 // is initialized, all enabled data types are consistent with one |
| 717 // another, and no unrecoverable error has transpired. | 725 // another, and no unrecoverable error has transpired. |
| 718 if (unrecoverable_error_detected_) | 726 if (unrecoverable_error_detected_) |
| 719 return false; | 727 return false; |
| 720 | 728 |
| 721 if (!data_type_manager_.get()) | 729 if (!data_type_manager_.get()) |
| 722 return false; | 730 return false; |
| 723 | 731 |
| 724 return data_type_manager_->state() == DataTypeManager::CONFIGURED; | 732 return data_type_manager_->state() == DataTypeManager::CONFIGURED; |
| 725 } | 733 } |
| OLD | NEW |