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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "chrome/browser/sync/glue/sync_backend_host.h" | 7 #include "chrome/browser/sync/glue/sync_backend_host.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 DCHECK(sync_loop_); | 1039 DCHECK(sync_loop_); |
1040 | 1040 |
1041 // Blow away the partial or corrupt sync data folder before doing any more | 1041 // Blow away the partial or corrupt sync data folder before doing any more |
1042 // initialization, if necessary. | 1042 // initialization, if necessary. |
1043 if (options.delete_sync_data_folder) { | 1043 if (options.delete_sync_data_folder) { |
1044 DeleteSyncDataFolder(); | 1044 DeleteSyncDataFolder(); |
1045 } | 1045 } |
1046 | 1046 |
1047 // Make sure that the directory exists before initializing the backend. | 1047 // Make sure that the directory exists before initializing the backend. |
1048 // If it already exists, this will do no harm. | 1048 // If it already exists, this will do no harm. |
1049 bool success = file_util::CreateDirectory(sync_data_folder_path_); | 1049 if (!file_util::CreateDirectory(sync_data_folder_path_)) { |
1050 DCHECK(success); | 1050 DLOG(FATAL) << "Sync Data directory creation failed."; |
| 1051 } |
1051 | 1052 |
1052 DCHECK(!registrar_); | 1053 DCHECK(!registrar_); |
1053 registrar_ = options.registrar; | 1054 registrar_ = options.registrar; |
1054 DCHECK(registrar_); | 1055 DCHECK(registrar_); |
1055 | 1056 |
1056 DCHECK(!chrome_sync_notification_bridge_); | 1057 DCHECK(!chrome_sync_notification_bridge_); |
1057 chrome_sync_notification_bridge_ = options.chrome_sync_notification_bridge; | 1058 chrome_sync_notification_bridge_ = options.chrome_sync_notification_bridge; |
1058 DCHECK(chrome_sync_notification_bridge_); | 1059 DCHECK(chrome_sync_notification_bridge_); |
1059 | 1060 |
1060 sync_manager_ = options.sync_manager_factory->CreateSyncManager(name_); | 1061 sync_manager_ = options.sync_manager_factory->CreateSyncManager(name_); |
1061 sync_manager_->AddObserver(this); | 1062 sync_manager_->AddObserver(this); |
1062 success = sync_manager_->Init( | 1063 sync_manager_->Init( |
1063 sync_data_folder_path_, | 1064 sync_data_folder_path_, |
1064 options.event_handler, | 1065 options.event_handler, |
1065 options.service_url.host() + options.service_url.path(), | 1066 options.service_url.host() + options.service_url.path(), |
1066 options.service_url.EffectiveIntPort(), | 1067 options.service_url.EffectiveIntPort(), |
1067 options.service_url.SchemeIsSecure(), | 1068 options.service_url.SchemeIsSecure(), |
1068 BrowserThread::GetBlockingPool(), | 1069 BrowserThread::GetBlockingPool(), |
1069 options.make_http_bridge_factory_fn.Run().Pass(), | 1070 options.make_http_bridge_factory_fn.Run().Pass(), |
1070 options.workers, | 1071 options.workers, |
1071 options.extensions_activity_monitor, | 1072 options.extensions_activity_monitor, |
1072 options.registrar /* as SyncManager::ChangeDelegate */, | 1073 options.registrar /* as SyncManager::ChangeDelegate */, |
1073 options.credentials, | 1074 options.credentials, |
1074 scoped_ptr<syncer::SyncNotifier>(new BridgedSyncNotifier( | 1075 scoped_ptr<syncer::SyncNotifier>(new BridgedSyncNotifier( |
1075 options.chrome_sync_notification_bridge, | 1076 options.chrome_sync_notification_bridge, |
1076 options.sync_notifier_factory->CreateSyncNotifier())), | 1077 options.sync_notifier_factory->CreateSyncNotifier())), |
1077 options.restored_key_for_bootstrapping, | 1078 options.restored_key_for_bootstrapping, |
1078 options.restored_keystore_key_for_bootstrapping, | 1079 options.restored_keystore_key_for_bootstrapping, |
1079 CommandLine::ForCurrentProcess()->HasSwitch( | 1080 CommandLine::ForCurrentProcess()->HasSwitch( |
1080 switches::kSyncKeystoreEncryption), | 1081 switches::kSyncKeystoreEncryption), |
1081 scoped_ptr<InternalComponentsFactory>( | 1082 scoped_ptr<InternalComponentsFactory>( |
1082 options.internal_components_factory), | 1083 options.internal_components_factory), |
1083 &encryptor_, | 1084 &encryptor_, |
1084 options.unrecoverable_error_handler, | 1085 options.unrecoverable_error_handler, |
1085 options.report_unrecoverable_error_function); | 1086 options.report_unrecoverable_error_function); |
1086 LOG_IF(ERROR, !success) << "Sync manager initialization failed!"; | |
1087 | 1087 |
1088 // Now check the command line to see if we need to simulate an | 1088 // Now check the command line to see if we need to simulate an |
1089 // unrecoverable error for testing purpose. Note the error is thrown | 1089 // unrecoverable error for testing purpose. Note the error is thrown |
1090 // only if the initialization succeeded. Also it makes sense to use this | 1090 // only if the initialization succeeded. Also it makes sense to use this |
1091 // flag only when restarting the browser with an account already setup. If | 1091 // flag only when restarting the browser with an account already setup. If |
1092 // you use this before setting up the setup would not succeed as an error | 1092 // you use this before setting up the setup would not succeed as an error |
1093 // would be encountered. | 1093 // would be encountered. |
1094 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1094 if (CommandLine::ForCurrentProcess()->HasSwitch( |
1095 switches::kSyncThrowUnrecoverableError)) { | 1095 switches::kSyncThrowUnrecoverableError)) { |
1096 sync_manager_->ThrowUnrecoverableError(); | 1096 sync_manager_->ThrowUnrecoverableError(); |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 FROM_HERE, | 1512 FROM_HERE, |
1513 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, | 1513 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, |
1514 core_.get(), sync_thread_done_callback)); | 1514 core_.get(), sync_thread_done_callback)); |
1515 } | 1515 } |
1516 | 1516 |
1517 #undef SDVLOG | 1517 #undef SDVLOG |
1518 | 1518 |
1519 #undef SLOG | 1519 #undef SLOG |
1520 | 1520 |
1521 } // namespace browser_sync | 1521 } // namespace browser_sync |
OLD | NEW |