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

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

Issue 10152003: sync: Make BaseNode lookup-related Init functions return specific failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 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 "chrome/browser/sync/glue/session_change_processor.h" 5 #include "chrome/browser/sync/glue/session_change_processor.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 const sync_api::BaseTransaction* trans, 262 const sync_api::BaseTransaction* trans,
263 const sync_api::ImmutableChangeRecordList& changes) { 263 const sync_api::ImmutableChangeRecordList& changes) {
264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
265 if (!running()) { 265 if (!running()) {
266 return; 266 return;
267 } 267 }
268 268
269 ScopedStopObserving<SessionChangeProcessor> stop_observing(this); 269 ScopedStopObserving<SessionChangeProcessor> stop_observing(this);
270 270
271 sync_api::ReadNode root(trans); 271 sync_api::ReadNode root(trans);
272 if (!root.InitByTagLookup(kSessionsTag)) { 272 if (root.InitByTagLookup(kSessionsTag) != sync_api::BaseNode::INIT_OK) {
273 error_handler()->OnUnrecoverableError(FROM_HERE, 273 error_handler()->OnUnrecoverableError(FROM_HERE,
274 "Sessions root node lookup failed."); 274 "Sessions root node lookup failed.");
275 return; 275 return;
276 } 276 }
277 277
278 std::string local_tag = session_model_associator_->GetCurrentMachineTag(); 278 std::string local_tag = session_model_associator_->GetCurrentMachineTag();
279 for (sync_api::ChangeRecordList::const_iterator it = 279 for (sync_api::ChangeRecordList::const_iterator it =
280 changes.Get().begin(); it != changes.Get().end(); ++it) { 280 changes.Get().begin(); it != changes.Get().end(); ++it) {
281 const sync_api::ChangeRecord& change = *it; 281 const sync_api::ChangeRecord& change = *it;
282 sync_api::ChangeRecord::Action action(change.action); 282 sync_api::ChangeRecord::Action action(change.action);
(...skipping 12 matching lines...) Expand all
295 << "navigation event."; 295 << "navigation event.";
296 } else { 296 } else {
297 session_model_associator_->DisassociateForeignSession( 297 session_model_associator_->DisassociateForeignSession(
298 specifics.session_tag()); 298 specifics.session_tag());
299 } 299 }
300 continue; 300 continue;
301 } 301 }
302 302
303 // Handle an update or add. 303 // Handle an update or add.
304 sync_api::ReadNode sync_node(trans); 304 sync_api::ReadNode sync_node(trans);
305 if (!sync_node.InitByIdLookup(change.id)) { 305 if (sync_node.InitByIdLookup(change.id) != sync_api::BaseNode::INIT_OK) {
306 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, 306 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
307 "Session node lookup failed."); 307 "Session node lookup failed.");
308 return; 308 return;
309 } 309 }
310 310
311 // Check that the changed node is a child of the session folder. 311 // Check that the changed node is a child of the session folder.
312 DCHECK(root.GetId() == sync_node.GetParentId()); 312 DCHECK(root.GetId() == sync_node.GetParentId());
313 DCHECK(syncable::SESSIONS == sync_node.GetModelType()); 313 DCHECK(syncable::SESSIONS == sync_node.GetModelType());
314 314
315 const sync_pb::SessionSpecifics& specifics( 315 const sync_pb::SessionSpecifics& specifics(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 notification_registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED, 374 notification_registrar_.Add(this, chrome::NOTIFICATION_FAVICON_CHANGED,
375 content::Source<Profile>(profile_)); 375 content::Source<Profile>(profile_));
376 } 376 }
377 377
378 void SessionChangeProcessor::StopObserving() { 378 void SessionChangeProcessor::StopObserving() {
379 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 379 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
380 notification_registrar_.RemoveAll(); 380 notification_registrar_.RemoveAll();
381 } 381 }
382 382
383 } // namespace browser_sync 383 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/password_model_associator.cc ('k') | chrome/browser/sync/glue/session_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698