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/extensions/api/push_messaging/push_messaging_invalidati
on_handler.h" | 5 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } | 105 } |
106 | 106 |
107 void PushMessagingInvalidationHandler::UnregisterExtension( | 107 void PushMessagingInvalidationHandler::UnregisterExtension( |
108 const std::string& extension_id) { | 108 const std::string& extension_id) { |
109 DCHECK(thread_checker_.CalledOnValidThread()); | 109 DCHECK(thread_checker_.CalledOnValidThread()); |
110 DCHECK(Extension::IdIsValid(extension_id)); | 110 DCHECK(Extension::IdIsValid(extension_id)); |
111 registered_extensions_.erase(extension_id); | 111 registered_extensions_.erase(extension_id); |
112 UpdateRegistrations(); | 112 UpdateRegistrations(); |
113 } | 113 } |
114 | 114 |
115 void PushMessagingInvalidationHandler::OnNotificationsEnabled() { | 115 void PushMessagingInvalidationHandler::OnInvalidatorStateChange( |
| 116 syncer::InvalidatorState state) { |
116 DCHECK(thread_checker_.CalledOnValidThread()); | 117 DCHECK(thread_checker_.CalledOnValidThread()); |
117 // Nothing to do. | 118 // Nothing to do. |
118 } | 119 } |
119 | 120 |
120 void PushMessagingInvalidationHandler::OnNotificationsDisabled( | 121 void PushMessagingInvalidationHandler::OnIncomingInvalidation( |
121 syncer::NotificationsDisabledReason reason) { | |
122 DCHECK(thread_checker_.CalledOnValidThread()); | |
123 // Nothing to do. | |
124 } | |
125 | |
126 void PushMessagingInvalidationHandler::OnIncomingNotification( | |
127 const syncer::ObjectIdStateMap& id_state_map, | 122 const syncer::ObjectIdStateMap& id_state_map, |
128 syncer::IncomingNotificationSource source) { | 123 syncer::IncomingInvalidationSource source) { |
129 DCHECK(thread_checker_.CalledOnValidThread()); | 124 DCHECK(thread_checker_.CalledOnValidThread()); |
130 for (syncer::ObjectIdStateMap::const_iterator it = id_state_map.begin(); | 125 for (syncer::ObjectIdStateMap::const_iterator it = id_state_map.begin(); |
131 it != id_state_map.end(); ++it) { | 126 it != id_state_map.end(); ++it) { |
132 std::string extension_id; | 127 std::string extension_id; |
133 int subchannel; | 128 int subchannel; |
134 if (ObjectIdToExtensionAndSubchannel(it->first, | 129 if (ObjectIdToExtensionAndSubchannel(it->first, |
135 &extension_id, | 130 &extension_id, |
136 &subchannel)) { | 131 &subchannel)) { |
137 delegate_->OnMessage(extension_id, subchannel, it->second.payload); | 132 delegate_->OnMessage(extension_id, subchannel, it->second.payload); |
138 } | 133 } |
139 } | 134 } |
140 } | 135 } |
141 | 136 |
142 void PushMessagingInvalidationHandler::UpdateRegistrations() { | 137 void PushMessagingInvalidationHandler::UpdateRegistrations() { |
143 syncer::ObjectIdSet ids; | 138 syncer::ObjectIdSet ids; |
144 for (std::set<std::string>::const_iterator it = | 139 for (std::set<std::string>::const_iterator it = |
145 registered_extensions_.begin(); it != registered_extensions_.end(); | 140 registered_extensions_.begin(); it != registered_extensions_.end(); |
146 ++it) { | 141 ++it) { |
147 const syncer::ObjectIdSet& object_ids = ExtensionIdToObjectIds(*it); | 142 const syncer::ObjectIdSet& object_ids = ExtensionIdToObjectIds(*it); |
148 ids.insert(object_ids.begin(), object_ids.end()); | 143 ids.insert(object_ids.begin(), object_ids.end()); |
149 } | 144 } |
150 service_->UpdateRegisteredInvalidationIds(this, ids); | 145 service_->UpdateRegisteredInvalidationIds(this, ids); |
151 } | 146 } |
152 | 147 |
153 } // namespace extensions | 148 } // namespace extensions |
OLD | NEW |