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/p2p_notifier.h" | 5 #include "sync/notifier/p2p_notifier.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 DCHECK(send_notification_target_ == NOTIFY_OTHERS || | 150 DCHECK(send_notification_target_ == NOTIFY_OTHERS || |
151 send_notification_target_ == NOTIFY_ALL); | 151 send_notification_target_ == NOTIFY_ALL); |
152 push_client_->AddObserver(this); | 152 push_client_->AddObserver(this); |
153 } | 153 } |
154 | 154 |
155 P2PNotifier::~P2PNotifier() { | 155 P2PNotifier::~P2PNotifier() { |
156 DCHECK(thread_checker_.CalledOnValidThread()); | 156 DCHECK(thread_checker_.CalledOnValidThread()); |
157 push_client_->RemoveObserver(this); | 157 push_client_->RemoveObserver(this); |
158 } | 158 } |
159 | 159 |
160 void P2PNotifier::UpdateRegisteredIds(SyncNotifierObserver* handler, | 160 void P2PNotifier::SetHandler(const std::string& handler_name, |
161 SyncNotifierObserver* handler) { | |
162 DCHECK(thread_checker_.CalledOnValidThread()); | |
163 helper_.SetHandler(handler_name, handler); | |
164 } | |
165 | |
166 void P2PNotifier::UpdateRegisteredIds(const std::string& handler_name, | |
161 const ObjectIdSet& ids) { | 167 const ObjectIdSet& ids) { |
162 const ModelTypeSet enabled_types = ObjectIdSetToModelTypeSet( | 168 // TODO(akalin): Handle arbitrary object IDs |
msw
2012/08/03 23:30:46
nit: line breaks :)
akalin
2012/08/07 07:25:19
Done.
| |
163 helper_.UpdateRegisteredIds(handler, ids)); | 169 // (http://crbug.com/140411). |
170 DCHECK(thread_checker_.CalledOnValidThread()); | |
171 helper_.UpdateRegisteredIds(handler_name, ids); | |
172 const ModelTypeSet enabled_types = | |
173 ObjectIdSetToModelTypeSet(helper_.GetAllRegisteredIds()); | |
164 const ModelTypeSet new_enabled_types = | 174 const ModelTypeSet new_enabled_types = |
165 Difference(enabled_types, enabled_types_); | 175 Difference(enabled_types, enabled_types_); |
166 const P2PNotificationData notification_data( | 176 const P2PNotificationData notification_data( |
167 unique_id_, NOTIFY_SELF, new_enabled_types); | 177 unique_id_, NOTIFY_SELF, new_enabled_types); |
168 SendNotificationData(notification_data); | 178 SendNotificationData(notification_data); |
169 enabled_types_ = enabled_types; | 179 enabled_types_ = enabled_types; |
170 } | 180 } |
171 | 181 |
172 void P2PNotifier::SetUniqueId(const std::string& unique_id) { | 182 void P2PNotifier::SetUniqueId(const std::string& unique_id) { |
173 DCHECK(thread_checker_.CalledOnValidThread()); | 183 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 return; | 287 return; |
278 } | 288 } |
279 notifier::Notification notification; | 289 notifier::Notification notification; |
280 notification.channel = kSyncP2PNotificationChannel; | 290 notification.channel = kSyncP2PNotificationChannel; |
281 notification.data = notification_data.ToString(); | 291 notification.data = notification_data.ToString(); |
282 DVLOG(1) << "Sending XMPP notification: " << notification.ToString(); | 292 DVLOG(1) << "Sending XMPP notification: " << notification.ToString(); |
283 push_client_->SendNotification(notification); | 293 push_client_->SendNotification(notification); |
284 } | 294 } |
285 | 295 |
286 } // namespace syncer | 296 } // namespace syncer |
OLD | NEW |