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