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

Side by Side Diff: chrome/browser/sync/test/integration/profile_sync_service_harness.cc

Issue 167913002: sync: Add helper class for P2P invalidations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/test/integration/profile_sync_service_harness.h" 5 #include "chrome/browser/sync/test/integration/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 13 matching lines...) Expand all
24 #include "base/timer/timer.h" 24 #include "base/timer/timer.h"
25 #include "chrome/browser/chrome_notification_types.h" 25 #include "chrome/browser/chrome_notification_types.h"
26 #include "chrome/browser/invalidation/p2p_invalidation_service.h" 26 #include "chrome/browser/invalidation/p2p_invalidation_service.h"
27 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/signin/profile_oauth2_token_service.h" 28 #include "chrome/browser/signin/profile_oauth2_token_service.h"
29 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 29 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
30 #include "chrome/browser/signin/signin_manager_base.h" 30 #include "chrome/browser/signin/signin_manager_base.h"
31 #include "chrome/browser/sync/about_sync_util.h" 31 #include "chrome/browser/sync/about_sync_util.h"
32 #include "chrome/browser/sync/backend_migrator.h" 32 #include "chrome/browser/sync/backend_migrator.h"
33 #include "chrome/browser/sync/profile_sync_service_factory.h" 33 #include "chrome/browser/sync/profile_sync_service_factory.h"
34 #include "chrome/browser/sync/test/integration/p2p_invalidation_forwarder.h"
34 #include "chrome/browser/sync/test/integration/status_change_checker.h" 35 #include "chrome/browser/sync/test/integration/status_change_checker.h"
35 #include "chrome/common/chrome_switches.h" 36 #include "chrome/common/chrome_switches.h"
36 #include "chrome/common/pref_names.h" 37 #include "chrome/common/pref_names.h"
37 #include "components/sync_driver/data_type_controller.h" 38 #include "components/sync_driver/data_type_controller.h"
38 #include "content/public/browser/notification_service.h" 39 #include "content/public/browser/notification_service.h"
39 #include "google_apis/gaia/gaia_constants.h" 40 #include "google_apis/gaia/gaia_constants.h"
40 #include "sync/internal_api/public/base/progress_marker_map.h" 41 #include "sync/internal_api/public/base/progress_marker_map.h"
41 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" 42 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
42 #include "sync/internal_api/public/util/sync_string_conversions.h" 43 #include "sync/internal_api/public/util/sync_string_conversions.h"
43 44
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 syncer::ModelTypeSet synced_datatypes) { 199 syncer::ModelTypeSet synced_datatypes) {
199 // Initialize the sync client's profile sync service object. 200 // Initialize the sync client's profile sync service object.
200 if (service() == NULL) { 201 if (service() == NULL) {
201 LOG(ERROR) << "SetupSync(): service() is null."; 202 LOG(ERROR) << "SetupSync(): service() is null.";
202 return false; 203 return false;
203 } 204 }
204 205
205 // Subscribe sync client to notifications from the profile sync service. 206 // Subscribe sync client to notifications from the profile sync service.
206 if (!service()->HasObserver(this)) 207 if (!service()->HasObserver(this))
207 service()->AddObserver(this); 208 service()->AddObserver(this);
209 // Start listening for and emitting notifications of commits.
210 p2p_invalidation_forwarder_.reset(
211 new P2PInvalidationForwarder(service(), p2p_invalidation_service_));
haitaol1 2014/02/19 21:15:21 You don't need p2p_invalidation_service_ if creati
rlarocque 2014/02/19 22:21:14 Good point. I hadn't thought of that. Fixed.
208 212
209 // Tell the sync service that setup is in progress so we don't start syncing 213 // Tell the sync service that setup is in progress so we don't start syncing
210 // until we've finished configuration. 214 // until we've finished configuration.
211 service()->SetSetupInProgress(true); 215 service()->SetSetupInProgress(true);
212 216
213 // Authenticate sync client using GAIA credentials. 217 // Authenticate sync client using GAIA credentials.
214 service()->signin()->SetAuthenticatedUsername(username_); 218 service()->signin()->SetAuthenticatedUsername(username_);
215 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, 219 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
216 username_); 220 username_);
217 GoogleServiceSigninSuccessDetails details(username_, password_); 221 GoogleServiceSigninSuccessDetails details(username_, password_);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 void ProfileSyncServiceHarness::OnStateChanged() { 308 void ProfileSyncServiceHarness::OnStateChanged() {
305 if (!status_change_checker_) 309 if (!status_change_checker_)
306 return; 310 return;
307 311
308 DVLOG(1) << GetClientInfoString(status_change_checker_->source()); 312 DVLOG(1) << GetClientInfoString(status_change_checker_->source());
309 if (status_change_checker_->IsExitConditionSatisfied()) 313 if (status_change_checker_->IsExitConditionSatisfied())
310 QuitMessageLoop(); 314 QuitMessageLoop();
311 } 315 }
312 316
313 void ProfileSyncServiceHarness::OnSyncCycleCompleted() { 317 void ProfileSyncServiceHarness::OnSyncCycleCompleted() {
314 // Integration tests still use p2p notifications. 318 // Integration tests still use p2p notifications.
haitaol1 2014/02/19 21:15:21 obsolete comment?
rlarocque 2014/02/19 22:21:14 Correct. Removed.
315 const SyncSessionSnapshot& snap = GetLastSessionSnapshot();
316 bool is_notifiable_commit =
317 (snap.model_neutral_state().num_successful_commits > 0);
318 if (is_notifiable_commit && p2p_invalidation_service_) {
319 syncer::ModelTypeSet model_types =
320 snap.model_neutral_state().commit_request_types;
321 syncer::ObjectIdSet ids = ModelTypeSetToObjectIdSet(model_types);
322 p2p_invalidation_service_->SendInvalidation(ids);
323 }
324 OnStateChanged(); 319 OnStateChanged();
325 } 320 }
326 321
327 bool ProfileSyncServiceHarness::AwaitPassphraseRequired() { 322 bool ProfileSyncServiceHarness::AwaitPassphraseRequired() {
328 DVLOG(1) << GetClientInfoString("AwaitPassphraseRequired"); 323 DVLOG(1) << GetClientInfoString("AwaitPassphraseRequired");
329 CallbackStatusChecker passphrase_required_checker( 324 CallbackStatusChecker passphrase_required_checker(
330 base::Bind(&::IsPassphraseRequired, base::Unretained(this)), 325 base::Bind(&::IsPassphraseRequired, base::Unretained(this)),
331 "IsPassphraseRequired"); 326 "IsPassphraseRequired");
332 return AwaitStatusChange(&passphrase_required_checker, 327 return AwaitStatusChange(&passphrase_required_checker,
333 "AwaitPassphraseRequired"); 328 "AwaitPassphraseRequired");
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 793
799 std::string ProfileSyncServiceHarness::GetServiceStatus() { 794 std::string ProfileSyncServiceHarness::GetServiceStatus() {
800 scoped_ptr<base::DictionaryValue> value( 795 scoped_ptr<base::DictionaryValue> value(
801 sync_ui_util::ConstructAboutInformation(service())); 796 sync_ui_util::ConstructAboutInformation(service()));
802 std::string service_status; 797 std::string service_status;
803 base::JSONWriter::WriteWithOptions(value.get(), 798 base::JSONWriter::WriteWithOptions(value.get(),
804 base::JSONWriter::OPTIONS_PRETTY_PRINT, 799 base::JSONWriter::OPTIONS_PRETTY_PRINT,
805 &service_status); 800 &service_status);
806 return service_status; 801 return service_status;
807 } 802 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/profile_sync_service_harness.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698