| 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" |
| 11 #include "sync/internal_api/public/base/model_type.h" | 11 #include "sync/internal_api/public/base/model_type.h" |
| 12 #include "sync/internal_api/public/engine/model_safe_worker.h" | 12 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 13 #include "sync/syncable/directory.h" | 13 #include "sync/syncable/directory.h" |
| 14 | 14 |
| 15 namespace syncer { | 15 namespace syncer { |
| 16 namespace sessions { | 16 namespace sessions { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 std::set<ModelSafeGroup> ComputeEnabledGroups( | 20 std::set<ModelSafeGroup> ComputeEnabledGroups( |
| 21 const ModelSafeRoutingInfo& routing_info, | 21 const ModelSafeRoutingInfo& routing_info, |
| 22 const std::vector<ModelSafeWorker*>& workers) { | 22 const std::vector<ModelSafeWorker*>& workers) { |
| 23 std::set<ModelSafeGroup> enabled_groups; | 23 std::set<ModelSafeGroup> enabled_groups; |
| 24 // Project the list of enabled types (i.e., types in the routing | 24 // Project the list of enabled types (i.e., types in the routing |
| 25 // info) to a list of enabled groups. | 25 // info) to a list of enabled groups. |
| 26 for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin(); | 26 for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin(); |
| 27 it != routing_info.end(); ++it) { | 27 it != routing_info.end(); ++it) { |
| 28 enabled_groups.insert(it->second); | 28 enabled_groups.insert(it->second); |
| 29 } | 29 } |
| 30 // GROUP_PASSIVE is always enabled, since that's the group that | 30 // GROUP_PASSIVE is always enabled, since that's the group that top-level |
| 31 // top-level folders map to. | 31 // folders map to. |
| 32 // GROUP_CONTROL manages some meta-data types that are always enabled. |
| 32 enabled_groups.insert(GROUP_PASSIVE); | 33 enabled_groups.insert(GROUP_PASSIVE); |
| 34 enabled_groups.insert(GROUP_CONTROL); |
| 33 if (DCHECK_IS_ON()) { | 35 if (DCHECK_IS_ON()) { |
| 34 // We sometimes create dummy SyncSession objects (see | 36 // We sometimes create dummy SyncSession objects (see |
| 35 // SyncScheduler::InitialSnapshot) so don't check in that case. | 37 // SyncScheduler::InitialSnapshot) so don't check in that case. |
| 36 if (!routing_info.empty() || !workers.empty()) { | 38 if (!routing_info.empty() || !workers.empty()) { |
| 37 std::set<ModelSafeGroup> groups_with_workers; | 39 std::set<ModelSafeGroup> groups_with_workers; |
| 38 for (std::vector<ModelSafeWorker*>::const_iterator it = workers.begin(); | 40 for (std::vector<ModelSafeWorker*>::const_iterator it = workers.begin(); |
| 39 it != workers.end(); ++it) { | 41 it != workers.end(); ++it) { |
| 40 groups_with_workers.insert((*it)->GetModelSafeGroup()); | 42 groups_with_workers.insert((*it)->GetModelSafeGroup()); |
| 41 } | 43 } |
| 42 // All enabled groups should have a corresponding worker. | 44 // All enabled groups should have a corresponding worker. |
| (...skipping 226 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. | 271 // with the server. Therefore, we verify no errors and at least one SYNCER_OK. |
| 270 return reached_server && !HadErrors(state); | 272 return reached_server && !HadErrors(state); |
| 271 } | 273 } |
| 272 | 274 |
| 273 void SyncSession::SetFinished() { | 275 void SyncSession::SetFinished() { |
| 274 finished_ = true; | 276 finished_ = true; |
| 275 } | 277 } |
| 276 | 278 |
| 277 } // namespace sessions | 279 } // namespace sessions |
| 278 } // namespace syncer | 280 } // namespace syncer |
| OLD | NEW |