Chromium Code Reviews| 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 "sync/notifier/invalidation_notifier.h" | 5 #include "sync/notifier/invalidation_notifier.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "jingle/notifier/listener/push_client.h" | 10 #include "jingle/notifier/listener/push_client.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 invalidation_state_tracker_(invalidation_state_tracker), | 27 invalidation_state_tracker_(invalidation_state_tracker), |
| 28 client_info_(client_info), | 28 client_info_(client_info), |
| 29 invalidation_state_(initial_invalidation_state), | 29 invalidation_state_(initial_invalidation_state), |
| 30 invalidation_client_(push_client.Pass()) { | 30 invalidation_client_(push_client.Pass()) { |
| 31 } | 31 } |
| 32 | 32 |
| 33 InvalidationNotifier::~InvalidationNotifier() { | 33 InvalidationNotifier::~InvalidationNotifier() { |
| 34 DCHECK(CalledOnValidThread()); | 34 DCHECK(CalledOnValidThread()); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void InvalidationNotifier::RegisterHandler(SyncNotifierObserver* handler) { | |
| 38 DCHECK(CalledOnValidThread()); | |
| 39 registrar_.RegisterHandler(handler); | |
| 40 } | |
| 41 | |
| 37 void InvalidationNotifier::UpdateRegisteredIds(SyncNotifierObserver* handler, | 42 void InvalidationNotifier::UpdateRegisteredIds(SyncNotifierObserver* handler, |
| 38 const ObjectIdSet& ids) { | 43 const ObjectIdSet& ids) { |
| 39 DCHECK(CalledOnValidThread()); | 44 DCHECK(CalledOnValidThread()); |
| 40 invalidation_client_.RegisterIds(helper_.UpdateRegisteredIds(handler, ids)); | 45 registrar_.UpdateRegisteredIds(handler, ids); |
| 46 const ObjectIdSet& all_registered_ids = registrar_.GetAllRegisteredIds(); | |
| 47 invalidation_client_.RegisterIds(all_registered_ids); | |
|
msw
2012/08/09 05:20:26
nit: pass registrar_.GetAllRegisteredIds() and nix
akalin
2012/08/10 01:28:08
Done.
| |
| 48 } | |
| 49 | |
| 50 void InvalidationNotifier::UnregisterHandler(SyncNotifierObserver* handler) { | |
| 51 DCHECK(CalledOnValidThread()); | |
| 52 registrar_.UnregisterHandler(handler); | |
| 41 } | 53 } |
| 42 | 54 |
| 43 void InvalidationNotifier::SetUniqueId(const std::string& unique_id) { | 55 void InvalidationNotifier::SetUniqueId(const std::string& unique_id) { |
| 44 DCHECK(CalledOnValidThread()); | 56 DCHECK(CalledOnValidThread()); |
| 45 invalidation_client_id_ = unique_id; | 57 invalidation_client_id_ = unique_id; |
| 46 DVLOG(1) << "Setting unique ID to " << unique_id; | 58 DVLOG(1) << "Setting unique ID to " << unique_id; |
| 47 CHECK(!invalidation_client_id_.empty()); | 59 CHECK(!invalidation_client_id_.empty()); |
| 48 } | 60 } |
| 49 | 61 |
| 50 void InvalidationNotifier::SetStateDeprecated(const std::string& state) { | 62 void InvalidationNotifier::SetStateDeprecated(const std::string& state) { |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 81 invalidation_client_.UpdateCredentials(email, token); | 93 invalidation_client_.UpdateCredentials(email, token); |
| 82 } | 94 } |
| 83 | 95 |
| 84 void InvalidationNotifier::SendNotification(ModelTypeSet changed_types) { | 96 void InvalidationNotifier::SendNotification(ModelTypeSet changed_types) { |
| 85 DCHECK(CalledOnValidThread()); | 97 DCHECK(CalledOnValidThread()); |
| 86 // Do nothing. | 98 // Do nothing. |
| 87 } | 99 } |
| 88 | 100 |
| 89 void InvalidationNotifier::OnInvalidate(const ObjectIdPayloadMap& id_payloads) { | 101 void InvalidationNotifier::OnInvalidate(const ObjectIdPayloadMap& id_payloads) { |
| 90 DCHECK(CalledOnValidThread()); | 102 DCHECK(CalledOnValidThread()); |
| 91 helper_.DispatchInvalidationsToHandlers(id_payloads, REMOTE_NOTIFICATION); | 103 registrar_.DispatchInvalidationsToHandlers(id_payloads, REMOTE_NOTIFICATION); |
| 92 } | 104 } |
| 93 | 105 |
| 94 void InvalidationNotifier::OnNotificationsEnabled() { | 106 void InvalidationNotifier::OnNotificationsEnabled() { |
| 95 DCHECK(CalledOnValidThread()); | 107 DCHECK(CalledOnValidThread()); |
| 96 helper_.EmitOnNotificationsEnabled(); | 108 registrar_.EmitOnNotificationsEnabled(); |
| 97 } | 109 } |
| 98 | 110 |
| 99 void InvalidationNotifier::OnNotificationsDisabled( | 111 void InvalidationNotifier::OnNotificationsDisabled( |
| 100 NotificationsDisabledReason reason) { | 112 NotificationsDisabledReason reason) { |
| 101 DCHECK(CalledOnValidThread()); | 113 DCHECK(CalledOnValidThread()); |
| 102 helper_.EmitOnNotificationsDisabled(reason); | 114 registrar_.EmitOnNotificationsDisabled(reason); |
| 103 } | 115 } |
| 104 | 116 |
| 105 } // namespace syncer | 117 } // namespace syncer |
| OLD | NEW |