| 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/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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |