| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/syncer_end_command.h" | 5 #include "chrome/browser/sync/engine/syncer_end_command.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/engine/syncer_types.h" | 7 #include "chrome/browser/sync/engine/syncer_types.h" |
| 8 #include "chrome/browser/sync/sessions/sync_session.h" | 8 #include "chrome/browser/sync/sessions/sync_session.h" |
| 9 #include "chrome/browser/sync/syncable/directory_manager.h" | 9 #include "chrome/browser/sync/syncable/directory_manager.h" |
| 10 #include "chrome/common/deprecated/event_sys-inl.h" | 10 #include "chrome/common/deprecated/event_sys-inl.h" |
| 11 | 11 |
| 12 namespace browser_sync { | 12 namespace browser_sync { |
| 13 | 13 |
| 14 SyncerEndCommand::SyncerEndCommand() {} | 14 SyncerEndCommand::SyncerEndCommand() {} |
| 15 SyncerEndCommand::~SyncerEndCommand() {} | 15 SyncerEndCommand::~SyncerEndCommand() {} |
| 16 | 16 |
| 17 void SyncerEndCommand::ExecuteImpl(sessions::SyncSession* session) { | 17 void SyncerEndCommand::ExecuteImpl(sessions::SyncSession* session) { |
| 18 sessions::StatusController* status(session->status_controller()); | 18 sessions::StatusController* status(session->status_controller()); |
| 19 status->set_syncing(false); | 19 status->set_syncing(false); |
| 20 session->context()->set_previous_session_routing_info( |
| 21 session->routing_info()); |
| 20 | 22 |
| 21 // This might be the first time we've fully completed a sync cycle, for | 23 // This might be the first time we've fully completed a sync cycle, for |
| 22 // some subset of the currently synced datatypes. | 24 // some subset of the currently synced datatypes. |
| 23 if (!session->HasMoreToSync() && | 25 if (!session->HasMoreToSync() && |
| 24 status->ServerSaysNothingMoreToDownload()) { | 26 status->ServerSaysNothingMoreToDownload()) { |
| 25 syncable::ScopedDirLookup dir(session->context()->directory_manager(), | 27 syncable::ScopedDirLookup dir(session->context()->directory_manager(), |
| 26 session->context()->account_name()); | 28 session->context()->account_name()); |
| 27 if (!dir.good()) { | 29 if (!dir.good()) { |
| 28 LOG(ERROR) << "Scoped dir lookup failed!"; | 30 LOG(ERROR) << "Scoped dir lookup failed!"; |
| 29 return; | 31 return; |
| 30 } | 32 } |
| 31 | 33 |
| 32 for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) { | 34 for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) { |
| 33 syncable::ModelType model_type = syncable::ModelTypeFromInt(i); | 35 syncable::ModelType model_type = syncable::ModelTypeFromInt(i); |
| 34 if (status->updates_request_parameters().data_types[i]) { | 36 if (status->updates_request_parameters().data_types[i]) { |
| 35 // This gets persisted to the directory's backing store. | 37 // This gets persisted to the directory's backing store. |
| 36 dir->set_initial_sync_ended_for_type(model_type, true); | 38 dir->set_initial_sync_ended_for_type(model_type, true); |
| 37 } | 39 } |
| 38 } | 40 } |
| 39 } | 41 } |
| 40 | 42 |
| 41 SyncerEvent event(SyncerEvent::SYNC_CYCLE_ENDED); | 43 SyncerEvent event(SyncerEvent::SYNC_CYCLE_ENDED); |
| 42 sessions::SyncSessionSnapshot snapshot(session->TakeSnapshot()); | 44 sessions::SyncSessionSnapshot snapshot(session->TakeSnapshot()); |
| 43 event.snapshot = &snapshot; | 45 event.snapshot = &snapshot; |
| 44 session->context()->syncer_event_channel()->Notify(event); | 46 session->context()->syncer_event_channel()->Notify(event); |
| 45 } | 47 } |
| 46 | 48 |
| 47 } // namespace browser_sync | 49 } // namespace browser_sync |
| OLD | NEW |