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

Side by Side Diff: chrome/browser/sync/glue/session_change_processor.cc

Issue 8341094: Changed change processors to use ScopedStopObserving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed unnecessary call to StartObserving(). Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/sync/glue/session_change_processor.h" 5 #include "chrome/browser/sync/glue/session_change_processor.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 207 }
208 208
209 void SessionChangeProcessor::ApplyChangesFromSyncModel( 209 void SessionChangeProcessor::ApplyChangesFromSyncModel(
210 const sync_api::BaseTransaction* trans, 210 const sync_api::BaseTransaction* trans,
211 const sync_api::ImmutableChangeRecordList& changes) { 211 const sync_api::ImmutableChangeRecordList& changes) {
212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
213 if (!running()) { 213 if (!running()) {
214 return; 214 return;
215 } 215 }
216 216
217 StopObserving(); 217 ScopedStopObserving<SessionChangeProcessor> stop_observing(this);
218 218
219 sync_api::ReadNode root(trans); 219 sync_api::ReadNode root(trans);
220 if (!root.InitByTagLookup(kSessionsTag)) { 220 if (!root.InitByTagLookup(kSessionsTag)) {
221 error_handler()->OnUnrecoverableError(FROM_HERE, 221 error_handler()->OnUnrecoverableError(FROM_HERE,
222 "Sessions root node lookup failed."); 222 "Sessions root node lookup failed.");
223 return; 223 return;
224 } 224 }
225 225
226 for (sync_api::ChangeRecordList::const_iterator it = 226 for (sync_api::ChangeRecordList::const_iterator it =
227 changes.Get().begin(); it != changes.Get().end(); ++it) { 227 changes.Get().begin(); it != changes.Get().end(); ++it) {
(...skipping 26 matching lines...) Expand all
254 254
255 const sync_pb::SessionSpecifics& specifics( 255 const sync_pb::SessionSpecifics& specifics(
256 sync_node.GetSessionSpecifics()); 256 sync_node.GetSessionSpecifics());
257 if (specifics.session_tag() == 257 if (specifics.session_tag() ==
258 session_model_associator_->GetCurrentMachineTag() && 258 session_model_associator_->GetCurrentMachineTag() &&
259 !setup_for_test_) { 259 !setup_for_test_) {
260 // We should only ever receive a change to our own machine's session info 260 // We should only ever receive a change to our own machine's session info
261 // if encryption was turned on. In that case, the data is still the same, 261 // if encryption was turned on. In that case, the data is still the same,
262 // so we can ignore. 262 // so we can ignore.
263 LOG(WARNING) << "Dropping modification to local session."; 263 LOG(WARNING) << "Dropping modification to local session.";
264 StartObserving();
265 return; 264 return;
266 } 265 }
267 const base::Time& mtime = sync_node.GetModificationTime(); 266 const base::Time& mtime = sync_node.GetModificationTime();
268 // The model associator handles foreign session updates and adds the same. 267 // The model associator handles foreign session updates and adds the same.
269 session_model_associator_->AssociateForeignSpecifics(specifics, mtime); 268 session_model_associator_->AssociateForeignSpecifics(specifics, mtime);
270 } 269 }
271 270
272 // Notify foreign session handlers that there are new sessions. 271 // Notify foreign session handlers that there are new sessions.
273 content::NotificationService::current()->Notify( 272 content::NotificationService::current()->Notify(
274 chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED, 273 chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED,
275 content::Source<Profile>(profile_), 274 content::Source<Profile>(profile_),
276 content::NotificationService::NoDetails()); 275 content::NotificationService::NoDetails());
277
278 StartObserving();
279 } 276 }
280 277
281 void SessionChangeProcessor::StartImpl(Profile* profile) { 278 void SessionChangeProcessor::StartImpl(Profile* profile) {
282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
283 DCHECK(profile); 280 DCHECK(profile);
284 DCHECK(profile_ == NULL); 281 DCHECK(profile_ == NULL);
285 profile_ = profile; 282 profile_ = profile;
286 StartObserving(); 283 StartObserving();
287 } 284 }
288 285
(...skipping 26 matching lines...) Expand all
315 content::NotificationService::AllBrowserContextsAndSources()); 312 content::NotificationService::AllBrowserContextsAndSources());
316 } 313 }
317 314
318 void SessionChangeProcessor::StopObserving() { 315 void SessionChangeProcessor::StopObserving() {
319 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
320 DCHECK(profile_); 317 DCHECK(profile_);
321 notification_registrar_.RemoveAll(); 318 notification_registrar_.RemoveAll();
322 } 319 }
323 320
324 } // namespace browser_sync 321 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/session_change_processor.h ('k') | chrome/browser/sync/glue/theme_change_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698