| 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 "sync/sessions/sync_session.h" | 5 #include "sync/sessions/sync_session.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 // All enabled groups should have a corresponding worker. | 42 // All enabled groups should have a corresponding worker. |
| 43 DCHECK(std::includes( | 43 DCHECK(std::includes( |
| 44 groups_with_workers.begin(), groups_with_workers.end(), | 44 groups_with_workers.begin(), groups_with_workers.end(), |
| 45 enabled_groups.begin(), enabled_groups.end())); | 45 enabled_groups.begin(), enabled_groups.end())); |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 return enabled_groups; | 48 return enabled_groups; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void PurgeStalePayload(syncer::ModelTypePayloadMap* original, | 51 void PurgeStalePayload(ModelTypePayloadMap* original, |
| 52 const ModelSafeRoutingInfo& routing_info) { | 52 const ModelSafeRoutingInfo& routing_info) { |
| 53 std::vector<syncer::ModelTypePayloadMap::iterator> iterators_to_delete; | 53 std::vector<ModelTypePayloadMap::iterator> iterators_to_delete; |
| 54 for (syncer::ModelTypePayloadMap::iterator i = original->begin(); | 54 for (ModelTypePayloadMap::iterator i = original->begin(); |
| 55 i != original->end(); ++i) { | 55 i != original->end(); ++i) { |
| 56 if (routing_info.end() == routing_info.find(i->first)) { | 56 if (routing_info.end() == routing_info.find(i->first)) { |
| 57 iterators_to_delete.push_back(i); | 57 iterators_to_delete.push_back(i); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 for (std::vector<syncer::ModelTypePayloadMap::iterator>::iterator | 61 for (std::vector<ModelTypePayloadMap::iterator>::iterator |
| 62 it = iterators_to_delete.begin(); it != iterators_to_delete.end(); | 62 it = iterators_to_delete.begin(); it != iterators_to_delete.end(); |
| 63 ++it) { | 63 ++it) { |
| 64 original->erase(*it); | 64 original->erase(*it); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 } // namesepace | 68 } // namesepace |
| 69 | 69 |
| 70 SyncSession::SyncSession(SyncSessionContext* context, Delegate* delegate, | 70 SyncSession::SyncSession(SyncSessionContext* context, Delegate* delegate, |
| 71 const SyncSourceInfo& source, | 71 const SyncSourceInfo& source, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 finished_ = false; | 149 finished_ = false; |
| 150 source_.updates_source = | 150 source_.updates_source = |
| 151 sync_pb::GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION; | 151 sync_pb::GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION; |
| 152 status_controller_.reset(new StatusController(routing_info_)); | 152 status_controller_.reset(new StatusController(routing_info_)); |
| 153 } | 153 } |
| 154 | 154 |
| 155 SyncSessionSnapshot SyncSession::TakeSnapshot() const { | 155 SyncSessionSnapshot SyncSession::TakeSnapshot() const { |
| 156 syncable::Directory* dir = context_->directory(); | 156 syncable::Directory* dir = context_->directory(); |
| 157 | 157 |
| 158 bool is_share_useable = true; | 158 bool is_share_useable = true; |
| 159 syncer::ModelTypeSet initial_sync_ended; | 159 ModelTypeSet initial_sync_ended; |
| 160 syncer::ModelTypePayloadMap download_progress_markers; | 160 ModelTypePayloadMap download_progress_markers; |
| 161 for (int i = syncer::FIRST_REAL_MODEL_TYPE; | 161 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { |
| 162 i < syncer::MODEL_TYPE_COUNT; ++i) { | 162 ModelType type(ModelTypeFromInt(i)); |
| 163 syncer::ModelType type(syncer::ModelTypeFromInt(i)); | |
| 164 if (routing_info_.count(type) != 0) { | 163 if (routing_info_.count(type) != 0) { |
| 165 if (dir->initial_sync_ended_for_type(type)) | 164 if (dir->initial_sync_ended_for_type(type)) |
| 166 initial_sync_ended.Put(type); | 165 initial_sync_ended.Put(type); |
| 167 else | 166 else |
| 168 is_share_useable = false; | 167 is_share_useable = false; |
| 169 } | 168 } |
| 170 dir->GetDownloadProgressAsString(type, &download_progress_markers[type]); | 169 dir->GetDownloadProgressAsString(type, &download_progress_markers[type]); |
| 171 } | 170 } |
| 172 | 171 |
| 173 return SyncSessionSnapshot( | 172 return SyncSessionSnapshot( |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // with the server. Therefore, we verify no errors and at least one SYNCER_OK. | 268 // with the server. Therefore, we verify no errors and at least one SYNCER_OK. |
| 270 return reached_server && !HadErrors(state); | 269 return reached_server && !HadErrors(state); |
| 271 } | 270 } |
| 272 | 271 |
| 273 void SyncSession::SetFinished() { | 272 void SyncSession::SetFinished() { |
| 274 finished_ = true; | 273 finished_ = true; |
| 275 } | 274 } |
| 276 | 275 |
| 277 } // namespace sessions | 276 } // namespace sessions |
| 278 } // namespace syncer | 277 } // namespace syncer |
| OLD | NEW |