| OLD | NEW |
| 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/engine/apply_updates_command.h" | 5 #include "chrome/browser/sync/engine/apply_updates_command.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "chrome/browser/sync/engine/update_applicator.h" | 8 #include "chrome/browser/sync/engine/update_applicator.h" |
| 9 #include "chrome/browser/sync/sessions/sync_session.h" | 9 #include "chrome/browser/sync/sessions/sync_session.h" |
| 10 #include "chrome/browser/sync/syncable/directory_manager.h" | 10 #include "chrome/browser/sync/syncable/directory_manager.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); | 27 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); |
| 28 syncable::Directory::UnappliedUpdateMetaHandles handles; | 28 syncable::Directory::UnappliedUpdateMetaHandles handles; |
| 29 dir->GetUnappliedUpdateMetaHandles(&trans, &handles); | 29 dir->GetUnappliedUpdateMetaHandles(&trans, &handles); |
| 30 | 30 |
| 31 UpdateApplicator applicator( | 31 UpdateApplicator applicator( |
| 32 session->context()->resolver(), | 32 session->context()->resolver(), |
| 33 session->context()->directory_manager()->GetCryptographer(&trans), | 33 session->context()->directory_manager()->GetCryptographer(&trans), |
| 34 handles.begin(), handles.end(), session->routing_info(), | 34 handles.begin(), handles.end(), session->routing_info(), |
| 35 session->status_controller()->group_restriction()); | 35 session->status_controller()->group_restriction()); |
| 36 while (applicator.AttemptOneApplication(&trans)) {} | 36 while (applicator.AttemptOneApplication(&trans)) {} |
| 37 |
| 38 if (applicator.failed_update()) { |
| 39 // TODO(lipalani): Pipe in the failed line number from the syncable layer. |
| 40 |
| 41 // We could be in any thread here. So set the unrecoverable error in. |
| 42 // session. ModelChangingSyncerCommand object will send it on the right |
| 43 // thread. |
| 44 session->SetUnrecoverableError(FROM_HERE, "Failed to apply update.", |
| 45 &trans); |
| 46 return; |
| 47 } |
| 48 |
| 37 applicator.SaveProgressIntoSessionState( | 49 applicator.SaveProgressIntoSessionState( |
| 38 session->status_controller()->mutable_conflict_progress(), | 50 session->status_controller()->mutable_conflict_progress(), |
| 39 session->status_controller()->mutable_update_progress()); | 51 session->status_controller()->mutable_update_progress()); |
| 40 | 52 |
| 41 // This might be the first time we've fully completed a sync cycle, for | 53 // This might be the first time we've fully completed a sync cycle, for |
| 42 // some subset of the currently synced datatypes. | 54 // some subset of the currently synced datatypes. |
| 43 sessions::StatusController* status(session->status_controller()); | 55 sessions::StatusController* status(session->status_controller()); |
| 44 if (status->ServerSaysNothingMoreToDownload()) { | 56 if (status->ServerSaysNothingMoreToDownload()) { |
| 45 syncable::ScopedDirLookup dir(session->context()->directory_manager(), | 57 syncable::ScopedDirLookup dir(session->context()->directory_manager(), |
| 46 session->context()->account_name()); | 58 session->context()->account_name()); |
| 47 if (!dir.good()) { | 59 if (!dir.good()) { |
| 48 LOG(ERROR) << "Scoped dir lookup failed!"; | 60 LOG(ERROR) << "Scoped dir lookup failed!"; |
| 49 return; | 61 return; |
| 50 } | 62 } |
| 51 | 63 |
| 52 for (int i = syncable::FIRST_REAL_MODEL_TYPE; | 64 for (int i = syncable::FIRST_REAL_MODEL_TYPE; |
| 53 i < syncable::MODEL_TYPE_COUNT; ++i) { | 65 i < syncable::MODEL_TYPE_COUNT; ++i) { |
| 54 syncable::ModelType model_type = syncable::ModelTypeFromInt(i); | 66 syncable::ModelType model_type = syncable::ModelTypeFromInt(i); |
| 55 if (status->updates_request_types()[i]) { | 67 if (status->updates_request_types()[i]) { |
| 56 // This gets persisted to the directory's backing store. | 68 // This gets persisted to the directory's backing store. |
| 57 dir->set_initial_sync_ended_for_type(model_type, true); | 69 dir->set_initial_sync_ended_for_type(model_type, true); |
| 58 } | 70 } |
| 59 } | 71 } |
| 60 } | 72 } |
| 61 } | 73 } |
| 62 | 74 |
| 63 } // namespace browser_sync | 75 } // namespace browser_sync |
| OLD | NEW |