Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: sync/notifier/p2p_notifier.cc

Issue 10824161: [Sync] Avoid unregistering object IDs on shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 (http://crbug.com/140411).
163 helper_.UpdateRegisteredIds(handler, ids)); 169 DCHECK(thread_checker_.CalledOnValidThread());
170 helper_.UpdateRegisteredIds(handler_name, ids);
171 const ModelTypeSet enabled_types =
msw 2012/08/07 20:09:30 ditto nit: comment why |ids| != |enabled_types|?
akalin 2012/08/07 23:38:05 ditto
172 ObjectIdSetToModelTypeSet(helper_.GetAllRegisteredIds());
164 const ModelTypeSet new_enabled_types = 173 const ModelTypeSet new_enabled_types =
165 Difference(enabled_types, enabled_types_); 174 Difference(enabled_types, enabled_types_);
166 const P2PNotificationData notification_data( 175 const P2PNotificationData notification_data(
167 unique_id_, NOTIFY_SELF, new_enabled_types); 176 unique_id_, NOTIFY_SELF, new_enabled_types);
168 SendNotificationData(notification_data); 177 SendNotificationData(notification_data);
169 enabled_types_ = enabled_types; 178 enabled_types_ = enabled_types;
170 } 179 }
171 180
172 void P2PNotifier::SetUniqueId(const std::string& unique_id) { 181 void P2PNotifier::SetUniqueId(const std::string& unique_id) {
173 DCHECK(thread_checker_.CalledOnValidThread()); 182 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 return; 286 return;
278 } 287 }
279 notifier::Notification notification; 288 notifier::Notification notification;
280 notification.channel = kSyncP2PNotificationChannel; 289 notification.channel = kSyncP2PNotificationChannel;
281 notification.data = notification_data.ToString(); 290 notification.data = notification_data.ToString();
282 DVLOG(1) << "Sending XMPP notification: " << notification.ToString(); 291 DVLOG(1) << "Sending XMPP notification: " << notification.ToString();
283 push_client_->SendNotification(notification); 292 push_client_->SendNotification(notification);
284 } 293 }
285 294
286 } // namespace syncer 295 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698