Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <cstddef> | 7 #include <cstddef> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 #include "chrome/common/net/gaia/gaia_constants.h" | 52 #include "chrome/common/net/gaia/gaia_constants.h" |
| 53 #include "chrome/common/time_format.h" | 53 #include "chrome/common/time_format.h" |
| 54 #include "chrome/common/url_constants.h" | 54 #include "chrome/common/url_constants.h" |
| 55 #include "content/public/browser/notification_details.h" | 55 #include "content/public/browser/notification_details.h" |
| 56 #include "content/public/browser/notification_source.h" | 56 #include "content/public/browser/notification_source.h" |
| 57 #include "grit/generated_resources.h" | 57 #include "grit/generated_resources.h" |
| 58 #include "net/cookies/cookie_monster.h" | 58 #include "net/cookies/cookie_monster.h" |
| 59 #include "sync/api/sync_error.h" | 59 #include "sync/api/sync_error.h" |
| 60 #include "sync/internal_api/public/configure_reason.h" | 60 #include "sync/internal_api/public/configure_reason.h" |
| 61 #include "sync/internal_api/public/util/experiments.h" | 61 #include "sync/internal_api/public/util/experiments.h" |
| 62 #include "sync/internal_api/public/util/sync_string_conversions.h" | |
| 62 #include "sync/js/js_arg_list.h" | 63 #include "sync/js/js_arg_list.h" |
| 63 #include "sync/js/js_event_details.h" | 64 #include "sync/js/js_event_details.h" |
| 64 #include "sync/util/cryptographer.h" | 65 #include "sync/util/cryptographer.h" |
| 65 #include "ui/base/l10n/l10n_util.h" | 66 #include "ui/base/l10n/l10n_util.h" |
| 66 | 67 |
| 67 using browser_sync::ChangeProcessor; | 68 using browser_sync::ChangeProcessor; |
| 68 using browser_sync::DataTypeController; | 69 using browser_sync::DataTypeController; |
| 69 using browser_sync::DataTypeManager; | 70 using browser_sync::DataTypeManager; |
| 70 using browser_sync::SyncBackendHost; | 71 using browser_sync::SyncBackendHost; |
| 71 using syncer::ModelType; | 72 using syncer::ModelType; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 new browser_sync::BackendUnrecoverableErrorHandler( | 346 new browser_sync::BackendUnrecoverableErrorHandler( |
| 346 MakeWeakHandle(weak_factory_.GetWeakPtr()))); | 347 MakeWeakHandle(weak_factory_.GetWeakPtr()))); |
| 347 | 348 |
| 348 backend_->Initialize( | 349 backend_->Initialize( |
| 349 this, | 350 this, |
| 350 MakeWeakHandle(sync_js_controller_.AsWeakPtr()), | 351 MakeWeakHandle(sync_js_controller_.AsWeakPtr()), |
| 351 sync_service_url_, | 352 sync_service_url_, |
| 352 initial_types, | 353 initial_types, |
| 353 credentials, | 354 credentials, |
| 354 delete_stale_data, | 355 delete_stale_data, |
| 356 &sync_manager_factory_, | |
| 355 backend_unrecoverable_error_handler_.get(), | 357 backend_unrecoverable_error_handler_.get(), |
| 356 &browser_sync::ChromeReportUnrecoverableError); | 358 &browser_sync::ChromeReportUnrecoverableError); |
| 357 } | 359 } |
| 358 | 360 |
| 359 void ProfileSyncService::CreateBackend() { | 361 void ProfileSyncService::CreateBackend() { |
| 360 backend_.reset( | 362 backend_.reset( |
| 361 new SyncBackendHost(profile_->GetDebugName(), | 363 new SyncBackendHost(profile_->GetDebugName(), |
| 362 profile_, sync_prefs_.AsWeakPtr(), | 364 profile_, sync_prefs_.AsWeakPtr(), |
| 363 invalidator_storage_.AsWeakPtr())); | 365 invalidator_storage_.AsWeakPtr())); |
| 364 } | 366 } |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1188 // We need a passphrase still. We don't bother to attempt to configure | 1190 // We need a passphrase still. We don't bother to attempt to configure |
| 1189 // until we receive an OnPassphraseAccepted (which triggers a configure). | 1191 // until we receive an OnPassphraseAccepted (which triggers a configure). |
| 1190 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out " | 1192 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out " |
| 1191 << "because a passphrase required"; | 1193 << "because a passphrase required"; |
| 1192 NotifyObservers(); | 1194 NotifyObservers(); |
| 1193 return; | 1195 return; |
| 1194 } | 1196 } |
| 1195 syncer::ConfigureReason reason = syncer::CONFIGURE_REASON_UNKNOWN; | 1197 syncer::ConfigureReason reason = syncer::CONFIGURE_REASON_UNKNOWN; |
| 1196 if (!HasSyncSetupCompleted()) { | 1198 if (!HasSyncSetupCompleted()) { |
| 1197 reason = syncer::CONFIGURE_REASON_NEW_CLIENT; | 1199 reason = syncer::CONFIGURE_REASON_NEW_CLIENT; |
| 1198 } else if (restart == false || | 1200 } else if (restart) { |
| 1199 syncer::InitialSyncEndedForTypes(types, GetUserShare())) { | 1201 // If no datatype was actually enabled, this configuration call shouldn't |
| 1202 // download any types, and will just activate the existing datatypes. | |
| 1203 reason = syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE; | |
|
tim (not reviewing)
2012/07/16 23:07:47
Hmm. restart == true doesn't imply a newly enable
Nicolas Zea
2012/07/17 00:56:17
Discussed offline. I adjusted the comments, and ad
| |
| 1204 } else { | |
| 1200 reason = syncer::CONFIGURE_REASON_RECONFIGURATION; | 1205 reason = syncer::CONFIGURE_REASON_RECONFIGURATION; |
| 1201 } else { | |
| 1202 DCHECK(restart); | |
| 1203 reason = syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE; | |
| 1204 } | 1206 } |
| 1205 DCHECK(reason != syncer::CONFIGURE_REASON_UNKNOWN); | |
| 1206 | 1207 |
| 1207 data_type_manager_->Configure(types, reason); | 1208 data_type_manager_->Configure(types, reason); |
| 1208 } | 1209 } |
| 1209 | 1210 |
| 1210 syncer::UserShare* ProfileSyncService::GetUserShare() const { | 1211 syncer::UserShare* ProfileSyncService::GetUserShare() const { |
| 1211 if (backend_.get() && backend_initialized_) { | 1212 if (backend_.get() && backend_initialized_) { |
| 1212 return backend_->GetUserShare(); | 1213 return backend_->GetUserShare(); |
| 1213 } | 1214 } |
| 1214 NOTREACHED(); | 1215 NOTREACHED(); |
| 1215 return NULL; | 1216 return NULL; |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1722 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. | 1723 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. |
| 1723 ProfileSyncService* old_this = this; | 1724 ProfileSyncService* old_this = this; |
| 1724 this->~ProfileSyncService(); | 1725 this->~ProfileSyncService(); |
| 1725 new(old_this) ProfileSyncService( | 1726 new(old_this) ProfileSyncService( |
| 1726 new ProfileSyncComponentsFactoryImpl(profile, | 1727 new ProfileSyncComponentsFactoryImpl(profile, |
| 1727 CommandLine::ForCurrentProcess()), | 1728 CommandLine::ForCurrentProcess()), |
| 1728 profile, | 1729 profile, |
| 1729 signin, | 1730 signin, |
| 1730 behavior); | 1731 behavior); |
| 1731 } | 1732 } |
| OLD | NEW |