| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); | 558 FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); |
| 559 // TODO(akalin): Make an Observer subclass that listens and does the | 559 // TODO(akalin): Make an Observer subclass that listens and does the |
| 560 // event routing. | 560 // event routing. |
| 561 sync_js_controller_.HandleJsEvent( | 561 sync_js_controller_.HandleJsEvent( |
| 562 "onServiceStateChanged", JsEventDetails()); | 562 "onServiceStateChanged", JsEventDetails()); |
| 563 } | 563 } |
| 564 | 564 |
| 565 void ProfileSyncService::ClearStaleErrors() { | 565 void ProfileSyncService::ClearStaleErrors() { |
| 566 unrecoverable_error_detected_ = false; | 566 unrecoverable_error_detected_ = false; |
| 567 unrecoverable_error_message_.clear(); | 567 unrecoverable_error_message_.clear(); |
| 568 unrecoverable_error_location_.reset(); | 568 unrecoverable_error_location_ = tracked_objects::Location(); |
| 569 last_actionable_error_ = SyncProtocolError(); | 569 last_actionable_error_ = SyncProtocolError(); |
| 570 } | 570 } |
| 571 | 571 |
| 572 // static | 572 // static |
| 573 const char* ProfileSyncService::GetPrefNameForDataType( | 573 const char* ProfileSyncService::GetPrefNameForDataType( |
| 574 syncable::ModelType data_type) { | 574 syncable::ModelType data_type) { |
| 575 switch (data_type) { | 575 switch (data_type) { |
| 576 case syncable::BOOKMARKS: | 576 case syncable::BOOKMARKS: |
| 577 return prefs::kSyncBookmarks; | 577 return prefs::kSyncBookmarks; |
| 578 case syncable::PASSWORDS: | 578 case syncable::PASSWORDS: |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 NOTREACHED(); | 637 NOTREACHED(); |
| 638 } | 638 } |
| 639 | 639 |
| 640 // An invariant has been violated. Transition to an error state where we try | 640 // An invariant has been violated. Transition to an error state where we try |
| 641 // to do as little work as possible, to avoid further corruption or crashes. | 641 // to do as little work as possible, to avoid further corruption or crashes. |
| 642 void ProfileSyncService::OnUnrecoverableError( | 642 void ProfileSyncService::OnUnrecoverableError( |
| 643 const tracked_objects::Location& from_here, | 643 const tracked_objects::Location& from_here, |
| 644 const std::string& message) { | 644 const std::string& message) { |
| 645 unrecoverable_error_detected_ = true; | 645 unrecoverable_error_detected_ = true; |
| 646 unrecoverable_error_message_ = message; | 646 unrecoverable_error_message_ = message; |
| 647 unrecoverable_error_location_.reset( | 647 unrecoverable_error_location_ = from_here; |
| 648 new tracked_objects::Location(from_here.function_name(), | |
| 649 from_here.file_name(), | |
| 650 from_here.line_number(), | |
| 651 from_here.program_counter())); | |
| 652 | 648 |
| 653 // Tell the wizard so it can inform the user only if it is already open. | 649 // Tell the wizard so it can inform the user only if it is already open. |
| 654 wizard_.Step(SyncSetupWizard::FATAL_ERROR); | 650 wizard_.Step(SyncSetupWizard::FATAL_ERROR); |
| 655 | 651 |
| 656 NotifyObservers(); | 652 NotifyObservers(); |
| 657 std::string location; | 653 std::string location; |
| 658 from_here.Write(true, true, &location); | 654 from_here.Write(true, true, &location); |
| 659 LOG(ERROR) | 655 LOG(ERROR) |
| 660 << "Unrecoverable error detected at " << location | 656 << "Unrecoverable error detected at " << location |
| 661 << " -- ProfileSyncService unusable: " << message; | 657 << " -- ProfileSyncService unusable: " << message; |
| (...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 syncable::ModelTypeBitSetFromValue( | 1650 syncable::ModelTypeBitSetFromValue( |
| 1655 *profile_->GetPrefs()->GetList(prefs::kAcknowledgedSyncTypes)); | 1651 *profile_->GetPrefs()->GetList(prefs::kAcknowledgedSyncTypes)); |
| 1656 syncable::ModelTypeSet registered; | 1652 syncable::ModelTypeSet registered; |
| 1657 GetRegisteredDataTypes(®istered); | 1653 GetRegisteredDataTypes(®istered); |
| 1658 syncable::ModelTypeBitSet registered_bit_set = | 1654 syncable::ModelTypeBitSet registered_bit_set = |
| 1659 syncable::ModelTypeBitSetFromSet(registered); | 1655 syncable::ModelTypeBitSetFromSet(registered); |
| 1660 unacknowledged = registered_bit_set & ~acknowledged; | 1656 unacknowledged = registered_bit_set & ~acknowledged; |
| 1661 } | 1657 } |
| 1662 return unacknowledged; | 1658 return unacknowledged; |
| 1663 } | 1659 } |
| OLD | NEW |