OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/sync/engine_impl/model_type_registry.h" | 5 #include "components/sync/engine_impl/model_type_registry.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 // Initialize Processor -> Worker communication channel. | 116 // Initialize Processor -> Worker communication channel. |
117 type_processor->ConnectSync(base::MakeUnique<CommitQueueProxy>( | 117 type_processor->ConnectSync(base::MakeUnique<CommitQueueProxy>( |
118 worker_ptr->AsWeakPtr(), base::ThreadTaskRunnerHandle::Get())); | 118 worker_ptr->AsWeakPtr(), base::ThreadTaskRunnerHandle::Get())); |
119 | 119 |
120 // Attempt migration if necessary. | 120 // Attempt migration if necessary. |
121 if (do_migration) { | 121 if (do_migration) { |
122 // TODO(crbug.com/658002): Store a pref before attempting migration | 122 // TODO(crbug.com/658002): Store a pref before attempting migration |
123 // indicating that it was attempted so we can avoid failure loops. | 123 // indicating that it was attempted so we can avoid failure loops. |
124 if (uss_migrator_.Run(type, user_share_, worker_ptr)) { | 124 if (uss_migrator_.Run(type, user_share_, worker_ptr)) { |
| 125 // TODO(wychen): enum uma should be strongly typed. crbug.com/661401 |
125 UMA_HISTOGRAM_ENUMERATION("Sync.USSMigrationSuccess", | 126 UMA_HISTOGRAM_ENUMERATION("Sync.USSMigrationSuccess", |
126 ModelTypeToHistogramInt(type), | 127 ModelTypeToHistogramInt(type), |
127 MODEL_TYPE_COUNT); | 128 static_cast<int>(MODEL_TYPE_COUNT)); |
128 // If we succesfully migrated, purge the directory of data for the type. | 129 // If we succesfully migrated, purge the directory of data for the type. |
129 // Purging removes the directory's local copy of the data only. | 130 // Purging removes the directory's local copy of the data only. |
130 directory()->PurgeEntriesWithTypeIn(ModelTypeSet(type), ModelTypeSet(), | 131 directory()->PurgeEntriesWithTypeIn(ModelTypeSet(type), ModelTypeSet(), |
131 ModelTypeSet()); | 132 ModelTypeSet()); |
132 } else { | 133 } else { |
| 134 // TODO(wychen): enum uma should be strongly typed. crbug.com/661401 |
133 UMA_HISTOGRAM_ENUMERATION("Sync.USSMigrationFailure", | 135 UMA_HISTOGRAM_ENUMERATION("Sync.USSMigrationFailure", |
134 ModelTypeToHistogramInt(type), | 136 ModelTypeToHistogramInt(type), |
135 MODEL_TYPE_COUNT); | 137 static_cast<int>(MODEL_TYPE_COUNT)); |
136 } | 138 } |
137 } | 139 } |
138 | 140 |
139 // We want to check that we haven't accidentally enabled both the non-blocking | 141 // We want to check that we haven't accidentally enabled both the non-blocking |
140 // and directory implementations for a given model type. This is true even if | 142 // and directory implementations for a given model type. This is true even if |
141 // migration fails; our fallback in this case is to do an initial GetUpdates, | 143 // migration fails; our fallback in this case is to do an initial GetUpdates, |
142 // not to use the directory implementation. | 144 // not to use the directory implementation. |
143 DCHECK(Intersection(GetEnabledDirectoryTypes(), GetEnabledNonBlockingTypes()) | 145 DCHECK(Intersection(GetEnabledDirectoryTypes(), GetEnabledNonBlockingTypes()) |
144 .Empty()); | 146 .Empty()); |
145 } | 147 } |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 | 355 |
354 ModelTypeSet ModelTypeRegistry::GetEnabledNonBlockingTypes() const { | 356 ModelTypeSet ModelTypeRegistry::GetEnabledNonBlockingTypes() const { |
355 ModelTypeSet enabled_non_blocking_types; | 357 ModelTypeSet enabled_non_blocking_types; |
356 for (const auto& worker : model_type_workers_) { | 358 for (const auto& worker : model_type_workers_) { |
357 enabled_non_blocking_types.Put(worker->GetModelType()); | 359 enabled_non_blocking_types.Put(worker->GetModelType()); |
358 } | 360 } |
359 return enabled_non_blocking_types; | 361 return enabled_non_blocking_types; |
360 } | 362 } |
361 | 363 |
362 } // namespace syncer | 364 } // namespace syncer |
OLD | NEW |