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

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

Issue 2657673004: Add shutdown notification and service refs to SyncServiceObserver. (Closed)
Patch Set: Chromeos fix Created 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/p2p_invalidation_forwarder.h" 5 #include "chrome/browser/sync/test/integration/p2p_invalidation_forwarder.h"
6 6
7 #include "components/browser_sync/profile_sync_service.h" 7 #include "components/browser_sync/profile_sync_service.h"
8 #include "components/invalidation/impl/p2p_invalidation_service.h" 8 #include "components/invalidation/impl/p2p_invalidation_service.h"
9 #include "components/sync/base/invalidation_helper.h" 9 #include "components/sync/base/invalidation_helper.h"
10 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" 10 #include "components/sync/engine/cycle/sync_cycle_snapshot.h"
11 11
12 P2PInvalidationForwarder::P2PInvalidationForwarder( 12 P2PInvalidationForwarder::P2PInvalidationForwarder(
13 browser_sync::ProfileSyncService* sync_service, 13 browser_sync::ProfileSyncService* sync_service,
14 invalidation::P2PInvalidationService* invalidation_service) 14 invalidation::P2PInvalidationService* invalidation_service)
15 : sync_service_(sync_service), invalidation_service_(invalidation_service) { 15 : sync_service_(sync_service), invalidation_service_(invalidation_service) {
16 sync_service_->AddObserver(this); 16 sync_service_->AddObserver(this);
17 } 17 }
18 18
19 P2PInvalidationForwarder::~P2PInvalidationForwarder() { 19 P2PInvalidationForwarder::~P2PInvalidationForwarder() {
20 sync_service_->RemoveObserver(this); 20 sync_service_->RemoveObserver(this);
21 } 21 }
22 22
23 void P2PInvalidationForwarder::OnStateChanged() {} 23 void P2PInvalidationForwarder::OnSyncCycleCompleted(syncer::SyncService* sync) {
24
25 void P2PInvalidationForwarder::OnSyncCycleCompleted() {
26 const syncer::SyncCycleSnapshot& snap = sync_service_->GetLastCycleSnapshot(); 24 const syncer::SyncCycleSnapshot& snap = sync_service_->GetLastCycleSnapshot();
27 bool is_notifiable_commit = 25 bool is_notifiable_commit =
28 (snap.model_neutral_state().num_successful_commits > 0); 26 (snap.model_neutral_state().num_successful_commits > 0);
29 if (is_notifiable_commit && invalidation_service_) { 27 if (is_notifiable_commit && invalidation_service_) {
30 syncer::ModelTypeSet model_types = 28 syncer::ModelTypeSet model_types =
31 snap.model_neutral_state().commit_request_types; 29 snap.model_neutral_state().commit_request_types;
32 syncer::ObjectIdSet ids = ModelTypeSetToObjectIdSet(model_types); 30 syncer::ObjectIdSet ids = ModelTypeSetToObjectIdSet(model_types);
33 invalidation_service_->SendInvalidation(ids); 31 invalidation_service_->SendInvalidation(ids);
34 } 32 }
35 } 33 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698