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_harness.h" | 5 #include "chrome/browser/sync/profile_sync_service_harness.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <ostream> | 9 #include <ostream> |
10 #include <set> | 10 #include <set> |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } | 127 } |
128 | 128 |
129 // static | 129 // static |
130 ProfileSyncServiceHarness* ProfileSyncServiceHarness::CreateAndAttach( | 130 ProfileSyncServiceHarness* ProfileSyncServiceHarness::CreateAndAttach( |
131 Profile* profile) { | 131 Profile* profile) { |
132 ProfileSyncServiceFactory* f = ProfileSyncServiceFactory::GetInstance(); | 132 ProfileSyncServiceFactory* f = ProfileSyncServiceFactory::GetInstance(); |
133 if (!f->HasProfileSyncService(profile)) { | 133 if (!f->HasProfileSyncService(profile)) { |
134 NOTREACHED() << "Profile has never signed into sync."; | 134 NOTREACHED() << "Profile has never signed into sync."; |
135 return NULL; | 135 return NULL; |
136 } | 136 } |
137 return new ProfileSyncServiceHarness(profile, "", ""); | 137 return new ProfileSyncServiceHarness(profile, std::string(), std::string()); |
138 } | 138 } |
139 | 139 |
140 void ProfileSyncServiceHarness::SetCredentials(const std::string& username, | 140 void ProfileSyncServiceHarness::SetCredentials(const std::string& username, |
141 const std::string& password) { | 141 const std::string& password) { |
142 username_ = username; | 142 username_ = username; |
143 password_ = password; | 143 password_ = password; |
144 } | 144 } |
145 | 145 |
146 bool ProfileSyncServiceHarness::IsSyncAlreadySetup() { | 146 bool ProfileSyncServiceHarness::IsSyncAlreadySetup() { |
147 return ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( | 147 return ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( |
(...skipping 24 matching lines...) Expand all Loading... |
172 | 172 |
173 // Subscribe sync client to notifications from the profile sync service. | 173 // Subscribe sync client to notifications from the profile sync service. |
174 if (!service_->HasObserver(this)) | 174 if (!service_->HasObserver(this)) |
175 service_->AddObserver(this); | 175 service_->AddObserver(this); |
176 | 176 |
177 // Tell the sync service that setup is in progress so we don't start syncing | 177 // Tell the sync service that setup is in progress so we don't start syncing |
178 // until we've finished configuration. | 178 // until we've finished configuration. |
179 service_->SetSetupInProgress(true); | 179 service_->SetSetupInProgress(true); |
180 | 180 |
181 // Authenticate sync client using GAIA credentials. | 181 // Authenticate sync client using GAIA credentials. |
182 service_->signin()->StartSignIn(username_, password_, "", ""); | 182 service_->signin() |
| 183 ->StartSignIn(username_, password_, std::string(), std::string()); |
183 | 184 |
184 // Wait for the OnBackendInitialized() callback. | 185 // Wait for the OnBackendInitialized() callback. |
185 if (!AwaitBackendInitialized()) { | 186 if (!AwaitBackendInitialized()) { |
186 LOG(ERROR) << "OnBackendInitialized() not seen after " | 187 LOG(ERROR) << "OnBackendInitialized() not seen after " |
187 << kLiveSyncOperationTimeoutMs / 1000 | 188 << kLiveSyncOperationTimeoutMs / 1000 |
188 << " seconds."; | 189 << " seconds."; |
189 return false; | 190 return false; |
190 } | 191 } |
191 | 192 |
192 // Make sure that initial sync wasn't blocked by a missing passphrase. | 193 // Make sure that initial sync wasn't blocked by a missing passphrase. |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 } | 1008 } |
1008 | 1009 |
1009 std::string ProfileSyncServiceHarness::GetSerializedProgressMarker( | 1010 std::string ProfileSyncServiceHarness::GetSerializedProgressMarker( |
1010 syncer::ModelType model_type) const { | 1011 syncer::ModelType model_type) const { |
1011 const SyncSessionSnapshot& snap = GetLastSessionSnapshot(); | 1012 const SyncSessionSnapshot& snap = GetLastSessionSnapshot(); |
1012 const syncer::ProgressMarkerMap& markers_map = | 1013 const syncer::ProgressMarkerMap& markers_map = |
1013 snap.download_progress_markers(); | 1014 snap.download_progress_markers(); |
1014 | 1015 |
1015 syncer::ProgressMarkerMap::const_iterator it = | 1016 syncer::ProgressMarkerMap::const_iterator it = |
1016 markers_map.find(model_type); | 1017 markers_map.find(model_type); |
1017 return (it != markers_map.end()) ? it->second : ""; | 1018 return (it != markers_map.end()) ? it->second : std::string(); |
1018 } | 1019 } |
1019 | 1020 |
1020 std::string ProfileSyncServiceHarness::GetClientInfoString( | 1021 std::string ProfileSyncServiceHarness::GetClientInfoString( |
1021 const std::string& message) { | 1022 const std::string& message) { |
1022 std::stringstream os; | 1023 std::stringstream os; |
1023 os << profile_debug_name_ << ": " << message << ": "; | 1024 os << profile_debug_name_ << ": " << message << ": "; |
1024 if (service()) { | 1025 if (service()) { |
1025 const SyncSessionSnapshot& snap = GetLastSessionSnapshot(); | 1026 const SyncSessionSnapshot& snap = GetLastSessionSnapshot(); |
1026 const ProfileSyncService::Status& status = GetStatus(); | 1027 const ProfileSyncService::Status& status = GetStatus(); |
1027 // Capture select info from the sync session snapshot and syncer status. | 1028 // Capture select info from the sync session snapshot and syncer status. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 | 1133 |
1133 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 1134 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
1134 scoped_ptr<DictionaryValue> value( | 1135 scoped_ptr<DictionaryValue> value( |
1135 sync_ui_util::ConstructAboutInformation(service_)); | 1136 sync_ui_util::ConstructAboutInformation(service_)); |
1136 std::string service_status; | 1137 std::string service_status; |
1137 base::JSONWriter::WriteWithOptions(value.get(), | 1138 base::JSONWriter::WriteWithOptions(value.get(), |
1138 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 1139 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
1139 &service_status); | 1140 &service_status); |
1140 return service_status; | 1141 return service_status; |
1141 } | 1142 } |
OLD | NEW |