OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 using browser_sync::SyncBackendHost; | 44 using browser_sync::SyncBackendHost; |
45 | 45 |
46 typedef GoogleServiceAuthError AuthError; | 46 typedef GoogleServiceAuthError AuthError; |
47 | 47 |
48 const char* ProfileSyncService::kSyncServerUrl = | 48 const char* ProfileSyncService::kSyncServerUrl = |
49 "https://clients4.google.com/chrome-sync"; | 49 "https://clients4.google.com/chrome-sync"; |
50 | 50 |
51 const char* ProfileSyncService::kDevServerUrl = | 51 const char* ProfileSyncService::kDevServerUrl = |
52 "https://clients4.google.com/chrome-sync/dev"; | 52 "https://clients4.google.com/chrome-sync/dev"; |
53 | 53 |
54 ProfileSyncService::ProfileSyncService( | 54 ProfileSyncService::ProfileSyncService(ProfileSyncFactory* factory, |
55 ProfileSyncFactory* factory, | 55 Profile* profile, |
56 Profile* profile, | 56 bool bootstrap_sync_authentication) |
57 chrome_common_net::NetworkChangeNotifierThread* | |
58 network_change_notifier_thread, | |
59 bool bootstrap_sync_authentication) | |
60 : last_auth_error_(AuthError::None()), | 57 : last_auth_error_(AuthError::None()), |
61 factory_(factory), | 58 factory_(factory), |
62 profile_(profile), | 59 profile_(profile), |
63 network_change_notifier_thread_(network_change_notifier_thread), | |
64 bootstrap_sync_authentication_(bootstrap_sync_authentication), | 60 bootstrap_sync_authentication_(bootstrap_sync_authentication), |
65 sync_service_url_(kDevServerUrl), | 61 sync_service_url_(kDevServerUrl), |
66 backend_initialized_(false), | 62 backend_initialized_(false), |
67 expecting_first_run_auth_needed_event_(false), | 63 expecting_first_run_auth_needed_event_(false), |
68 is_auth_in_progress_(false), | 64 is_auth_in_progress_(false), |
69 ALLOW_THIS_IN_INITIALIZER_LIST(wizard_(this)), | 65 ALLOW_THIS_IN_INITIALIZER_LIST(wizard_(this)), |
70 unrecoverable_error_detected_(false), | 66 unrecoverable_error_detected_(false), |
71 notification_method_(browser_sync::kDefaultNotificationMethod), | 67 notification_method_(browser_sync::kDefaultNotificationMethod), |
72 ALLOW_THIS_IN_INITIALIZER_LIST(scoped_runnable_method_factory_(this)) { | 68 ALLOW_THIS_IN_INITIALIZER_LIST(scoped_runnable_method_factory_(this)) { |
73 DCHECK(factory); | 69 DCHECK(factory); |
74 DCHECK(profile); | 70 DCHECK(profile); |
75 DCHECK(network_change_notifier_thread_); | |
76 registrar_.Add(this, | 71 registrar_.Add(this, |
77 NotificationType::SYNC_CONFIGURE_START, | 72 NotificationType::SYNC_CONFIGURE_START, |
78 NotificationService::AllSources()); | 73 NotificationService::AllSources()); |
79 registrar_.Add(this, | 74 registrar_.Add(this, |
80 NotificationType::SYNC_CONFIGURE_DONE, | 75 NotificationType::SYNC_CONFIGURE_DONE, |
81 NotificationService::AllSources()); | 76 NotificationService::AllSources()); |
82 registrar_.Add(this, | 77 registrar_.Add(this, |
83 NotificationType::SYNC_PASSPHRASE_REQUIRED, | 78 NotificationType::SYNC_PASSPHRASE_REQUIRED, |
84 NotificationService::AllSources()); | 79 NotificationService::AllSources()); |
85 registrar_.Add(this, | 80 registrar_.Add(this, |
(...skipping 17 matching lines...) Expand all Loading... |
103 } | 98 } |
104 #else | 99 #else |
105 LOG(INFO) << "Unofficial build, using dev channel sync server."; | 100 LOG(INFO) << "Unofficial build, using dev channel sync server."; |
106 #endif | 101 #endif |
107 } | 102 } |
108 | 103 |
109 ProfileSyncService::ProfileSyncService() | 104 ProfileSyncService::ProfileSyncService() |
110 : last_auth_error_(AuthError::None()), | 105 : last_auth_error_(AuthError::None()), |
111 factory_(NULL), | 106 factory_(NULL), |
112 profile_(NULL), | 107 profile_(NULL), |
113 network_change_notifier_thread_(NULL), | |
114 bootstrap_sync_authentication_(false), | 108 bootstrap_sync_authentication_(false), |
115 sync_service_url_(kSyncServerUrl), | 109 sync_service_url_(kSyncServerUrl), |
116 backend_initialized_(false), | 110 backend_initialized_(false), |
117 expecting_first_run_auth_needed_event_(false), | 111 expecting_first_run_auth_needed_event_(false), |
118 is_auth_in_progress_(false), | 112 is_auth_in_progress_(false), |
119 ALLOW_THIS_IN_INITIALIZER_LIST(wizard_(this)), | 113 ALLOW_THIS_IN_INITIALIZER_LIST(wizard_(this)), |
120 unrecoverable_error_detected_(false), | 114 unrecoverable_error_detected_(false), |
121 notification_method_(browser_sync::kDefaultNotificationMethod), | 115 notification_method_(browser_sync::kDefaultNotificationMethod), |
122 ALLOW_THIS_IN_INITIALIZER_LIST(scoped_runnable_method_factory_(this)) { | 116 ALLOW_THIS_IN_INITIALIZER_LIST(scoped_runnable_method_factory_(this)) { |
123 } | 117 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 invalidate_sync_login = CommandLine::ForCurrentProcess()->HasSwitch( | 261 invalidate_sync_login = CommandLine::ForCurrentProcess()->HasSwitch( |
268 switches::kInvalidateSyncLogin); | 262 switches::kInvalidateSyncLogin); |
269 invalidate_sync_xmpp_login = CommandLine::ForCurrentProcess()->HasSwitch( | 263 invalidate_sync_xmpp_login = CommandLine::ForCurrentProcess()->HasSwitch( |
270 switches::kInvalidateSyncXmppLogin); | 264 switches::kInvalidateSyncXmppLogin); |
271 #endif | 265 #endif |
272 | 266 |
273 syncable::ModelTypeSet types; | 267 syncable::ModelTypeSet types; |
274 GetPreferredDataTypes(&types); | 268 GetPreferredDataTypes(&types); |
275 backend_->Initialize(sync_service_url_, | 269 backend_->Initialize(sync_service_url_, |
276 types, | 270 types, |
277 network_change_notifier_thread_, | |
278 profile_->GetRequestContext(), | 271 profile_->GetRequestContext(), |
279 GetLsidForAuthBootstraping(), | 272 GetLsidForAuthBootstraping(), |
280 delete_sync_data_folder, | 273 delete_sync_data_folder, |
281 invalidate_sync_login, | 274 invalidate_sync_login, |
282 invalidate_sync_xmpp_login, | 275 invalidate_sync_xmpp_login, |
283 notification_method_); | 276 notification_method_); |
284 } | 277 } |
285 | 278 |
286 void ProfileSyncService::StartUp() { | 279 void ProfileSyncService::StartUp() { |
287 // Don't start up multiple times. | 280 // Don't start up multiple times. |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 // is initialized, all enabled data types are consistent with one | 780 // is initialized, all enabled data types are consistent with one |
788 // another, and no unrecoverable error has transpired. | 781 // another, and no unrecoverable error has transpired. |
789 if (unrecoverable_error_detected_) | 782 if (unrecoverable_error_detected_) |
790 return false; | 783 return false; |
791 | 784 |
792 if (!data_type_manager_.get()) | 785 if (!data_type_manager_.get()) |
793 return false; | 786 return false; |
794 | 787 |
795 return data_type_manager_->state() == DataTypeManager::CONFIGURED; | 788 return data_type_manager_->state() == DataTypeManager::CONFIGURED; |
796 } | 789 } |
OLD | NEW |