Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 10704214: [Sync] Refactor sync manager into interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Comments Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
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 // Datatype downloads on restart are generally due to newly supported
1202 // datatypes (although it's also possible we're picking up where a failed
1203 // previous configuration left off).
1204 // TODO(sync): consider detecting configuration recovery and setting
1205 // the reason here appropriately.
1206 reason = syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE;
1207 } else {
1208 // The user initiated a reconfiguration (either to add or remove types).
1200 reason = syncer::CONFIGURE_REASON_RECONFIGURATION; 1209 reason = syncer::CONFIGURE_REASON_RECONFIGURATION;
1201 } else {
1202 DCHECK(restart);
1203 reason = syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE;
1204 } 1210 }
1205 DCHECK(reason != syncer::CONFIGURE_REASON_UNKNOWN);
1206 1211
1207 data_type_manager_->Configure(types, reason); 1212 data_type_manager_->Configure(types, reason);
1208 } 1213 }
1209 1214
1210 syncer::UserShare* ProfileSyncService::GetUserShare() const { 1215 syncer::UserShare* ProfileSyncService::GetUserShare() const {
1211 if (backend_.get() && backend_initialized_) { 1216 if (backend_.get() && backend_initialized_) {
1212 return backend_->GetUserShare(); 1217 return backend_->GetUserShare();
1213 } 1218 }
1214 NOTREACHED(); 1219 NOTREACHED();
1215 return NULL; 1220 return NULL;
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 1727 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
1723 ProfileSyncService* old_this = this; 1728 ProfileSyncService* old_this = this;
1724 this->~ProfileSyncService(); 1729 this->~ProfileSyncService();
1725 new(old_this) ProfileSyncService( 1730 new(old_this) ProfileSyncService(
1726 new ProfileSyncComponentsFactoryImpl(profile, 1731 new ProfileSyncComponentsFactoryImpl(profile,
1727 CommandLine::ForCurrentProcess()), 1732 CommandLine::ForCurrentProcess()),
1728 profile, 1733 profile,
1729 signin, 1734 signin,
1730 behavior); 1735 behavior);
1731 } 1736 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698