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