| 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/glue/bridged_sync_notifier.h" | 5 #include "chrome/browser/sync/glue/bridged_sync_notifier.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h" | 7 #include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h" |
| 8 | 8 |
| 9 namespace browser_sync { | 9 namespace browser_sync { |
| 10 | 10 |
| 11 BridgedSyncNotifier::BridgedSyncNotifier( | 11 BridgedSyncNotifier::BridgedSyncNotifier( |
| 12 ChromeSyncNotificationBridge* bridge, | 12 ChromeSyncNotificationBridge* bridge, |
| 13 syncer::SyncNotifier* delegate) | 13 syncer::SyncNotifier* delegate) |
| 14 : bridge_(bridge), delegate_(delegate) { | 14 : bridge_(bridge), delegate_(delegate) { |
| 15 DCHECK(bridge_); | 15 DCHECK(bridge_); |
| 16 } | 16 } |
| 17 | 17 |
| 18 BridgedSyncNotifier::~BridgedSyncNotifier() { | 18 BridgedSyncNotifier::~BridgedSyncNotifier() { |
| 19 } | 19 } |
| 20 | 20 |
| 21 void BridgedSyncNotifier::AddObserver( | 21 void BridgedSyncNotifier::UpdateRegisteredIds( |
| 22 syncer::SyncNotifierObserver* observer) { | 22 syncer::SyncNotifierObserver* handler, |
| 23 const syncer::ObjectIdSet& ids) { |
| 23 if (delegate_.get()) | 24 if (delegate_.get()) |
| 24 delegate_->AddObserver(observer); | 25 delegate_->UpdateRegisteredIds(handler, ids); |
| 25 bridge_->AddObserver(observer); | 26 bridge_->UpdateRegisteredIds(handler, ids); |
| 26 } | |
| 27 | |
| 28 void BridgedSyncNotifier::RemoveObserver( | |
| 29 syncer::SyncNotifierObserver* observer) { | |
| 30 bridge_->RemoveObserver(observer); | |
| 31 if (delegate_.get()) | |
| 32 delegate_->RemoveObserver(observer); | |
| 33 } | 27 } |
| 34 | 28 |
| 35 void BridgedSyncNotifier::SetUniqueId(const std::string& unique_id) { | 29 void BridgedSyncNotifier::SetUniqueId(const std::string& unique_id) { |
| 36 if (delegate_.get()) | 30 if (delegate_.get()) |
| 37 delegate_->SetUniqueId(unique_id); | 31 delegate_->SetUniqueId(unique_id); |
| 38 } | 32 } |
| 39 | 33 |
| 40 void BridgedSyncNotifier::SetStateDeprecated(const std::string& state) { | 34 void BridgedSyncNotifier::SetStateDeprecated(const std::string& state) { |
| 41 if (delegate_.get()) | 35 if (delegate_.get()) |
| 42 delegate_->SetStateDeprecated(state); | 36 delegate_->SetStateDeprecated(state); |
| 43 } | 37 } |
| 44 | 38 |
| 45 void BridgedSyncNotifier::UpdateCredentials( | 39 void BridgedSyncNotifier::UpdateCredentials( |
| 46 const std::string& email, const std::string& token) { | 40 const std::string& email, const std::string& token) { |
| 47 if (delegate_.get()) | 41 if (delegate_.get()) |
| 48 delegate_->UpdateCredentials(email, token); | 42 delegate_->UpdateCredentials(email, token); |
| 49 } | 43 } |
| 50 | 44 |
| 51 void BridgedSyncNotifier::UpdateEnabledTypes( | |
| 52 syncer::ModelTypeSet enabled_types) { | |
| 53 if (delegate_.get()) | |
| 54 delegate_->UpdateEnabledTypes(enabled_types); | |
| 55 } | |
| 56 | |
| 57 void BridgedSyncNotifier::SendNotification( | 45 void BridgedSyncNotifier::SendNotification( |
| 58 syncer::ModelTypeSet changed_types) { | 46 syncer::ModelTypeSet changed_types) { |
| 59 if (delegate_.get()) | 47 if (delegate_.get()) |
| 60 delegate_->SendNotification(changed_types); | 48 delegate_->SendNotification(changed_types); |
| 61 } | 49 } |
| 62 | 50 |
| 63 } // namespace browser_sync | 51 } // namespace browser_sync |
| OLD | NEW |