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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 DCHECK(CalledOnValidThread()); | 45 DCHECK(CalledOnValidThread()); |
46 registrar_.UpdateRegisteredIds(handler, ids); | 46 registrar_.UpdateRegisteredIds(handler, ids); |
47 invalidation_listener_.UpdateRegisteredIds(registrar_.GetAllRegisteredIds()); | 47 invalidation_listener_.UpdateRegisteredIds(registrar_.GetAllRegisteredIds()); |
48 } | 48 } |
49 | 49 |
50 void InvalidationNotifier::UnregisterHandler(InvalidationHandler* handler) { | 50 void InvalidationNotifier::UnregisterHandler(InvalidationHandler* handler) { |
51 DCHECK(CalledOnValidThread()); | 51 DCHECK(CalledOnValidThread()); |
52 registrar_.UnregisterHandler(handler); | 52 registrar_.UnregisterHandler(handler); |
53 } | 53 } |
54 | 54 |
| 55 InvalidatorState InvalidationNotifier::GetInvalidatorState() const { |
| 56 DCHECK(CalledOnValidThread()); |
| 57 return registrar_.GetInvalidatorState(); |
| 58 } |
| 59 |
55 void InvalidationNotifier::SetUniqueId(const std::string& unique_id) { | 60 void InvalidationNotifier::SetUniqueId(const std::string& unique_id) { |
56 DCHECK(CalledOnValidThread()); | 61 DCHECK(CalledOnValidThread()); |
57 client_id_ = unique_id; | 62 client_id_ = unique_id; |
58 DVLOG(1) << "Setting unique ID to " << unique_id; | 63 DVLOG(1) << "Setting unique ID to " << unique_id; |
59 CHECK(!client_id_.empty()); | 64 CHECK(!client_id_.empty()); |
60 } | 65 } |
61 | 66 |
62 void InvalidationNotifier::SetStateDeprecated(const std::string& state) { | 67 void InvalidationNotifier::SetStateDeprecated(const std::string& state) { |
63 DCHECK(CalledOnValidThread()); | 68 DCHECK(CalledOnValidThread()); |
64 DCHECK_LT(state_, STARTED); | 69 DCHECK_LT(state_, STARTED); |
(...skipping 22 matching lines...) Expand all Loading... |
87 client_id_, client_info_, invalidation_state_, | 92 client_id_, client_info_, invalidation_state_, |
88 initial_max_invalidation_versions_, | 93 initial_max_invalidation_versions_, |
89 invalidation_state_tracker_, | 94 invalidation_state_tracker_, |
90 this); | 95 this); |
91 invalidation_state_.clear(); | 96 invalidation_state_.clear(); |
92 state_ = STARTED; | 97 state_ = STARTED; |
93 } | 98 } |
94 invalidation_listener_.UpdateCredentials(email, token); | 99 invalidation_listener_.UpdateCredentials(email, token); |
95 } | 100 } |
96 | 101 |
97 void InvalidationNotifier::SendNotification( | 102 void InvalidationNotifier::SendInvalidation( |
98 const ObjectIdStateMap& id_state_map) { | 103 const ObjectIdStateMap& id_state_map) { |
99 DCHECK(CalledOnValidThread()); | 104 DCHECK(CalledOnValidThread()); |
100 // Do nothing. | 105 // Do nothing. |
101 } | 106 } |
102 | 107 |
103 void InvalidationNotifier::OnInvalidate(const ObjectIdStateMap& id_state_map) { | 108 void InvalidationNotifier::OnInvalidate(const ObjectIdStateMap& id_state_map) { |
104 DCHECK(CalledOnValidThread()); | 109 DCHECK(CalledOnValidThread()); |
105 registrar_.DispatchInvalidationsToHandlers(id_state_map, REMOTE_NOTIFICATION); | 110 registrar_.DispatchInvalidationsToHandlers(id_state_map, REMOTE_INVALIDATION); |
106 } | 111 } |
107 | 112 |
108 void InvalidationNotifier::OnNotificationsEnabled() { | 113 void InvalidationNotifier::OnInvalidatorStateChange(InvalidatorState state) { |
109 DCHECK(CalledOnValidThread()); | 114 DCHECK(CalledOnValidThread()); |
110 registrar_.EmitOnNotificationsEnabled(); | 115 registrar_.UpdateInvalidatorState(state); |
111 } | |
112 | |
113 void InvalidationNotifier::OnNotificationsDisabled( | |
114 NotificationsDisabledReason reason) { | |
115 DCHECK(CalledOnValidThread()); | |
116 registrar_.EmitOnNotificationsDisabled(reason); | |
117 } | 116 } |
118 | 117 |
119 } // namespace syncer | 118 } // namespace syncer |
OLD | NEW |