Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / sync / test / integration / p2p_invalidation_forwarder.cc
blob4f5ba6e6148e05ac10f1ed6dbde8d81cebef5478
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
3 // found in the LICENSE file.
5 #include "chrome/browser/sync/test/integration/p2p_invalidation_forwarder.h"
7 #include "chrome/browser/sync/profile_sync_service.h"
8 #include "components/invalidation/impl/p2p_invalidation_service.h"
9 #include "components/sync_driver/invalidation_helper.h"
10 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
12 P2PInvalidationForwarder::P2PInvalidationForwarder(
13 ProfileSyncService* sync_service,
14 invalidation::P2PInvalidationService* invalidation_service)
15 : sync_service_(sync_service),
16 invalidation_service_(invalidation_service) {
17 sync_service_->AddObserver(this);
20 P2PInvalidationForwarder::~P2PInvalidationForwarder() {
21 sync_service_->RemoveObserver(this);
24 void P2PInvalidationForwarder::OnStateChanged() {}
26 void P2PInvalidationForwarder::OnSyncCycleCompleted() {
27 const syncer::sessions::SyncSessionSnapshot& snap =
28 sync_service_->GetLastSessionSnapshot();
29 bool is_notifiable_commit =
30 (snap.model_neutral_state().num_successful_commits > 0);
31 if (is_notifiable_commit && invalidation_service_) {
32 syncer::ModelTypeSet model_types =
33 snap.model_neutral_state().commit_request_types;
34 syncer::ObjectIdSet ids = ModelTypeSetToObjectIdSet(model_types);
35 invalidation_service_->SendInvalidation(ids);