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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 void ProfileSyncService::Initialize() { | 146 void ProfileSyncService::Initialize() { |
147 InitSettings(); | 147 InitSettings(); |
148 RegisterPreferences(); | 148 RegisterPreferences(); |
149 | 149 |
150 // We clear this here (vs Shutdown) because we want to remember that an error | 150 // We clear this here (vs Shutdown) because we want to remember that an error |
151 // happened on shutdown so we can display details (message, location) about it | 151 // happened on shutdown so we can display details (message, location) about it |
152 // in about:sync. | 152 // in about:sync. |
153 unrecoverable_error_detected_ = false; | 153 unrecoverable_error_detected_ = false; |
154 unrecoverable_error_message_.clear(); | 154 unrecoverable_error_message_.clear(); |
155 unrecoverable_error_location_.reset(); | 155 unrecoverable_error_location_ = tracked_objects::Location(); |
156 last_actionable_error_ = SyncProtocolError(); | 156 last_actionable_error_ = SyncProtocolError(); |
157 | 157 |
158 // Watch the preference that indicates sync is managed so we can take | 158 // Watch the preference that indicates sync is managed so we can take |
159 // appropriate action. | 159 // appropriate action. |
160 pref_sync_managed_.Init(prefs::kSyncManaged, profile_->GetPrefs(), this); | 160 pref_sync_managed_.Init(prefs::kSyncManaged, profile_->GetPrefs(), this); |
161 | 161 |
162 // For now, the only thing we can do through policy is to turn sync off. | 162 // For now, the only thing we can do through policy is to turn sync off. |
163 if (IsManaged()) { | 163 if (IsManaged()) { |
164 DisableForUser(); | 164 DisableForUser(); |
165 return; | 165 return; |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 NOTREACHED(); | 606 NOTREACHED(); |
607 } | 607 } |
608 | 608 |
609 // An invariant has been violated. Transition to an error state where we try | 609 // An invariant has been violated. Transition to an error state where we try |
610 // to do as little work as possible, to avoid further corruption or crashes. | 610 // to do as little work as possible, to avoid further corruption or crashes. |
611 void ProfileSyncService::OnUnrecoverableError( | 611 void ProfileSyncService::OnUnrecoverableError( |
612 const tracked_objects::Location& from_here, | 612 const tracked_objects::Location& from_here, |
613 const std::string& message) { | 613 const std::string& message) { |
614 unrecoverable_error_detected_ = true; | 614 unrecoverable_error_detected_ = true; |
615 unrecoverable_error_message_ = message; | 615 unrecoverable_error_message_ = message; |
616 unrecoverable_error_location_.reset( | 616 unrecoverable_error_location_ = from_here; |
617 new tracked_objects::Location(from_here.function_name(), | |
618 from_here.file_name(), | |
619 from_here.line_number(), | |
620 from_here.program_counter())); | |
621 | 617 |
622 // Tell the wizard so it can inform the user only if it is already open. | 618 // Tell the wizard so it can inform the user only if it is already open. |
623 wizard_.Step(SyncSetupWizard::FATAL_ERROR); | 619 wizard_.Step(SyncSetupWizard::FATAL_ERROR); |
624 | 620 |
625 NotifyObservers(); | 621 NotifyObservers(); |
626 std::string location; | 622 std::string location; |
627 from_here.Write(true, true, &location); | 623 from_here.Write(true, true, &location); |
628 LOG(ERROR) | 624 LOG(ERROR) |
629 << "Unrecoverable error detected at " << location | 625 << "Unrecoverable error detected at " << location |
630 << " -- ProfileSyncService unusable: " << message; | 626 << " -- ProfileSyncService unusable: " << message; |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 syncable::ModelTypeBitSetFromValue( | 1610 syncable::ModelTypeBitSetFromValue( |
1615 *profile_->GetPrefs()->GetList(prefs::kAcknowledgedSyncTypes)); | 1611 *profile_->GetPrefs()->GetList(prefs::kAcknowledgedSyncTypes)); |
1616 syncable::ModelTypeSet registered; | 1612 syncable::ModelTypeSet registered; |
1617 GetRegisteredDataTypes(®istered); | 1613 GetRegisteredDataTypes(®istered); |
1618 syncable::ModelTypeBitSet registered_bit_set = | 1614 syncable::ModelTypeBitSet registered_bit_set = |
1619 syncable::ModelTypeBitSetFromSet(registered); | 1615 syncable::ModelTypeBitSetFromSet(registered); |
1620 unacknowledged = registered_bit_set & ~acknowledged; | 1616 unacknowledged = registered_bit_set & ~acknowledged; |
1621 } | 1617 } |
1622 return unacknowledged; | 1618 return unacknowledged; |
1623 } | 1619 } |
OLD | NEW |