| 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 backend_->Initialize( | 385 backend_->Initialize( |
| 386 this, | 386 this, |
| 387 WeakHandle<JsEventHandler>(sync_js_controller_.AsWeakPtr()), | 387 WeakHandle<JsEventHandler>(sync_js_controller_.AsWeakPtr()), |
| 388 sync_service_url_, | 388 sync_service_url_, |
| 389 initial_types, | 389 initial_types, |
| 390 credentials, | 390 credentials, |
| 391 delete_sync_data_folder); | 391 delete_sync_data_folder); |
| 392 } | 392 } |
| 393 | 393 |
| 394 void ProfileSyncService::CreateBackend() { | 394 void ProfileSyncService::CreateBackend() { |
| 395 backend_.reset(new SyncBackendHost(profile_)); | 395 backend_.reset(new SyncBackendHost(profile_->GetDebugName(), profile_)); |
| 396 } | 396 } |
| 397 | 397 |
| 398 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { | 398 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { |
| 399 if (HasPendingEncryptedTypes()) | 399 if (HasPendingEncryptedTypes()) |
| 400 return true; | 400 return true; |
| 401 syncable::ModelTypeSet preferred_types; | 401 syncable::ModelTypeSet preferred_types; |
| 402 GetPreferredDataTypes(&preferred_types); | 402 GetPreferredDataTypes(&preferred_types); |
| 403 syncable::ModelTypeSet encrypted_types; | 403 syncable::ModelTypeSet encrypted_types; |
| 404 GetEncryptedDataTypes(&encrypted_types); | 404 GetEncryptedDataTypes(&encrypted_types); |
| 405 syncable::ModelTypeBitSet preferred_types_bitset = | 405 syncable::ModelTypeBitSet preferred_types_bitset = |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 unrecoverable_error_location_.reset( | 597 unrecoverable_error_location_.reset( |
| 598 new tracked_objects::Location(from_here.function_name(), | 598 new tracked_objects::Location(from_here.function_name(), |
| 599 from_here.file_name(), | 599 from_here.file_name(), |
| 600 from_here.line_number(), | 600 from_here.line_number(), |
| 601 from_here.program_counter())); | 601 from_here.program_counter())); |
| 602 | 602 |
| 603 // Tell the wizard so it can inform the user only if it is already open. | 603 // Tell the wizard so it can inform the user only if it is already open. |
| 604 wizard_.Step(SyncSetupWizard::FATAL_ERROR); | 604 wizard_.Step(SyncSetupWizard::FATAL_ERROR); |
| 605 | 605 |
| 606 NotifyObservers(); | 606 NotifyObservers(); |
| 607 LOG(ERROR) << "Unrecoverable error detected -- ProfileSyncService unusable." | |
| 608 << message; | |
| 609 std::string location; | 607 std::string location; |
| 610 from_here.Write(true, true, &location); | 608 from_here.Write(true, true, &location); |
| 611 LOG(ERROR) << location; | 609 LOG(ERROR) |
| 610 << "Unrecoverable error detected at " << location |
| 611 << " -- ProfileSyncService unusable: " << message; |
| 612 | 612 |
| 613 // Shut all data types down. | 613 // Shut all data types down. |
| 614 MessageLoop::current()->PostTask(FROM_HERE, | 614 MessageLoop::current()->PostTask(FROM_HERE, |
| 615 scoped_runnable_method_factory_.NewRunnableMethod( | 615 scoped_runnable_method_factory_.NewRunnableMethod( |
| 616 &ProfileSyncService::Shutdown, true)); | 616 &ProfileSyncService::Shutdown, true)); |
| 617 } | 617 } |
| 618 | 618 |
| 619 void ProfileSyncService::OnBackendInitialized( | 619 void ProfileSyncService::OnBackendInitialized( |
| 620 const WeakHandle<JsBackend>& js_backend, bool success) { | 620 const WeakHandle<JsBackend>& js_backend, bool success) { |
| 621 if (!success) { | 621 if (!success) { |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 &data_type_controllers_)); | 1220 &data_type_controllers_)); |
| 1221 registrar_.Add(this, | 1221 registrar_.Add(this, |
| 1222 chrome::NOTIFICATION_SYNC_CONFIGURE_START, | 1222 chrome::NOTIFICATION_SYNC_CONFIGURE_START, |
| 1223 Source<DataTypeManager>(data_type_manager_.get())); | 1223 Source<DataTypeManager>(data_type_manager_.get())); |
| 1224 registrar_.Add(this, | 1224 registrar_.Add(this, |
| 1225 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, | 1225 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, |
| 1226 Source<DataTypeManager>(data_type_manager_.get())); | 1226 Source<DataTypeManager>(data_type_manager_.get())); |
| 1227 | 1227 |
| 1228 // We create the migrator at the same time. | 1228 // We create the migrator at the same time. |
| 1229 migrator_.reset( | 1229 migrator_.reset( |
| 1230 new browser_sync::BackendMigrator(this, data_type_manager_.get())); | 1230 new browser_sync::BackendMigrator( |
| 1231 profile_->GetDebugName(), GetUserShare(), |
| 1232 this, data_type_manager_.get())); |
| 1231 } | 1233 } |
| 1232 | 1234 |
| 1233 syncable::ModelTypeSet types; | 1235 syncable::ModelTypeSet types; |
| 1234 GetPreferredDataTypes(&types); | 1236 GetPreferredDataTypes(&types); |
| 1235 if (IsPassphraseRequiredForDecryption()) { | 1237 if (IsPassphraseRequiredForDecryption()) { |
| 1236 if (IsEncryptedDatatypeEnabled()) { | 1238 if (IsEncryptedDatatypeEnabled()) { |
| 1237 // We need a passphrase still. We don't bother to attempt to configure | 1239 // We need a passphrase still. We don't bother to attempt to configure |
| 1238 // until we receive an OnPassphraseAccepted (which triggers a configure). | 1240 // until we receive an OnPassphraseAccepted (which triggers a configure). |
| 1239 VLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out " | 1241 VLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out " |
| 1240 << "because a passphrase required"; | 1242 << "because a passphrase required"; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 } | 1291 } |
| 1290 | 1292 |
| 1291 void ProfileSyncService::LogUnsyncedItems(int level) const { | 1293 void ProfileSyncService::LogUnsyncedItems(int level) const { |
| 1292 if (backend_.get() && backend_initialized_) { | 1294 if (backend_.get() && backend_initialized_) { |
| 1293 return backend_->LogUnsyncedItems(level); | 1295 return backend_->LogUnsyncedItems(level); |
| 1294 } | 1296 } |
| 1295 VLOG(level) << "Unsynced items not printed because backend is not " | 1297 VLOG(level) << "Unsynced items not printed because backend is not " |
| 1296 << "initialized"; | 1298 << "initialized"; |
| 1297 } | 1299 } |
| 1298 | 1300 |
| 1299 bool ProfileSyncService::HasPendingBackendMigration() const { | 1301 browser_sync::BackendMigrator* |
| 1300 return migrator_.get() && | 1302 ProfileSyncService::GetBackendMigratorForTest() { |
| 1301 migrator_->state() != browser_sync::BackendMigrator::IDLE; | 1303 return migrator_.get(); |
| 1302 } | 1304 } |
| 1303 | 1305 |
| 1304 void ProfileSyncService::GetModelSafeRoutingInfo( | 1306 void ProfileSyncService::GetModelSafeRoutingInfo( |
| 1305 browser_sync::ModelSafeRoutingInfo* out) const { | 1307 browser_sync::ModelSafeRoutingInfo* out) const { |
| 1306 if (backend_.get() && backend_initialized_) { | 1308 if (backend_.get() && backend_initialized_) { |
| 1307 backend_->GetModelSafeRoutingInfo(out); | 1309 backend_->GetModelSafeRoutingInfo(out); |
| 1308 } else { | 1310 } else { |
| 1309 NOTREACHED(); | 1311 NOTREACHED(); |
| 1310 } | 1312 } |
| 1311 } | 1313 } |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 *profile_->GetPrefs()->GetList(prefs::kAcknowledgedSyncTypes)); | 1576 *profile_->GetPrefs()->GetList(prefs::kAcknowledgedSyncTypes)); |
| 1575 syncable::ModelTypeSet registered; | 1577 syncable::ModelTypeSet registered; |
| 1576 GetRegisteredDataTypes(®istered); | 1578 GetRegisteredDataTypes(®istered); |
| 1577 syncable::ModelTypeBitSet registered_bit_set = | 1579 syncable::ModelTypeBitSet registered_bit_set = |
| 1578 syncable::ModelTypeBitSetFromSet(registered); | 1580 syncable::ModelTypeBitSetFromSet(registered); |
| 1579 unacknowledged = registered_bit_set & ~acknowledged; | 1581 unacknowledged = registered_bit_set & ~acknowledged; |
| 1580 } | 1582 } |
| 1581 return unacknowledged; | 1583 return unacknowledged; |
| 1582 } | 1584 } |
| 1583 | 1585 |
| OLD | NEW |