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/driver/ui_data_type_controller.h" | 5 #include "components/sync/driver/ui_data_type_controller.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/profiler/scoped_tracker.h" | 12 #include "base/profiler/scoped_tracker.h" |
13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
14 #include "components/sync/api/data_type_error_handler_impl.h" | 14 #include "components/sync/api/data_type_error_handler_impl.h" |
15 #include "components/sync/api/sync_error.h" | 15 #include "components/sync/api/sync_error.h" |
16 #include "components/sync/api/sync_merge_result.h" | 16 #include "components/sync/api/sync_merge_result.h" |
17 #include "components/sync/api/syncable_service.h" | 17 #include "components/sync/api/syncable_service.h" |
18 #include "components/sync/base/data_type_histogram.h" | 18 #include "components/sync/base/data_type_histogram.h" |
19 #include "components/sync/base/model_type.h" | 19 #include "components/sync/base/model_type.h" |
20 #include "components/sync/driver/generic_change_processor_factory.h" | 20 #include "components/sync/driver/generic_change_processor_factory.h" |
21 #include "components/sync/driver/shared_change_processor_ref.h" | 21 #include "components/sync/driver/shared_change_processor_ref.h" |
22 #include "components/sync/driver/sync_client.h" | 22 #include "components/sync/driver/sync_client.h" |
23 #include "components/sync/driver/sync_service.h" | 23 #include "components/sync/driver/sync_service.h" |
24 | 24 |
25 namespace sync_driver { | 25 namespace syncer { |
26 | 26 |
27 UIDataTypeController::UIDataTypeController() | 27 UIDataTypeController::UIDataTypeController() |
28 : DirectoryDataTypeController(syncer::UNSPECIFIED, | 28 : DirectoryDataTypeController(UNSPECIFIED, base::Closure(), nullptr), |
29 base::Closure(), | |
30 nullptr), | |
31 state_(NOT_RUNNING) {} | 29 state_(NOT_RUNNING) {} |
32 | 30 |
33 UIDataTypeController::UIDataTypeController(syncer::ModelType type, | 31 UIDataTypeController::UIDataTypeController(ModelType type, |
34 const base::Closure& dump_stack, | 32 const base::Closure& dump_stack, |
35 SyncClient* sync_client) | 33 SyncClient* sync_client) |
36 : DirectoryDataTypeController(type, dump_stack, sync_client), | 34 : DirectoryDataTypeController(type, dump_stack, sync_client), |
37 state_(NOT_RUNNING), | 35 state_(NOT_RUNNING), |
38 processor_factory_(new GenericChangeProcessorFactory()) { | 36 processor_factory_(new GenericChangeProcessorFactory()) { |
39 DCHECK(syncer::IsRealDataType(type)); | 37 DCHECK(IsRealDataType(type)); |
40 } | 38 } |
41 | 39 |
42 void UIDataTypeController::SetGenericChangeProcessorFactoryForTest( | 40 void UIDataTypeController::SetGenericChangeProcessorFactoryForTest( |
43 std::unique_ptr<GenericChangeProcessorFactory> factory) { | 41 std::unique_ptr<GenericChangeProcessorFactory> factory) { |
44 DCHECK_EQ(state_, NOT_RUNNING); | 42 DCHECK_EQ(state_, NOT_RUNNING); |
45 processor_factory_ = std::move(factory); | 43 processor_factory_ = std::move(factory); |
46 } | 44 } |
47 | 45 |
48 UIDataTypeController::~UIDataTypeController() {} | 46 UIDataTypeController::~UIDataTypeController() {} |
49 | 47 |
50 void UIDataTypeController::LoadModels( | 48 void UIDataTypeController::LoadModels( |
51 const ModelLoadCallback& model_load_callback) { | 49 const ModelLoadCallback& model_load_callback) { |
52 DCHECK(CalledOnValidThread()); | 50 DCHECK(CalledOnValidThread()); |
53 DCHECK(syncer::IsRealDataType(type())); | 51 DCHECK(IsRealDataType(type())); |
54 model_load_callback_ = model_load_callback; | 52 model_load_callback_ = model_load_callback; |
55 if (state_ != NOT_RUNNING) { | 53 if (state_ != NOT_RUNNING) { |
56 model_load_callback.Run( | 54 model_load_callback.Run(type(), |
57 type(), syncer::SyncError(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, | 55 SyncError(FROM_HERE, SyncError::DATATYPE_ERROR, |
58 "Model already loaded", type())); | 56 "Model already loaded", type())); |
59 return; | 57 return; |
60 } | 58 } |
61 // Since we can't be called multiple times before Stop() is called, | 59 // Since we can't be called multiple times before Stop() is called, |
62 // |shared_change_processor_| must be NULL here. | 60 // |shared_change_processor_| must be NULL here. |
63 DCHECK(!shared_change_processor_.get()); | 61 DCHECK(!shared_change_processor_.get()); |
64 shared_change_processor_ = new SharedChangeProcessor(type()); | 62 shared_change_processor_ = new SharedChangeProcessor(type()); |
65 | 63 |
66 state_ = MODEL_STARTING; | 64 state_ = MODEL_STARTING; |
67 if (!StartModels()) { | 65 if (!StartModels()) { |
68 // If we are waiting for some external service to load before associating | 66 // If we are waiting for some external service to load before associating |
69 // or we failed to start the models, we exit early. state_ will control | 67 // or we failed to start the models, we exit early. state_ will control |
70 // what we perform next. | 68 // what we perform next. |
71 DCHECK(state_ == NOT_RUNNING || state_ == MODEL_STARTING); | 69 DCHECK(state_ == NOT_RUNNING || state_ == MODEL_STARTING); |
72 return; | 70 return; |
73 } | 71 } |
74 | 72 |
75 state_ = MODEL_LOADED; | 73 state_ = MODEL_LOADED; |
76 model_load_callback_.Run(type(), syncer::SyncError()); | 74 model_load_callback_.Run(type(), SyncError()); |
77 } | 75 } |
78 | 76 |
79 void UIDataTypeController::OnModelLoaded() { | 77 void UIDataTypeController::OnModelLoaded() { |
80 DCHECK(CalledOnValidThread()); | 78 DCHECK(CalledOnValidThread()); |
81 DCHECK_EQ(state_, MODEL_STARTING); | 79 DCHECK_EQ(state_, MODEL_STARTING); |
82 | 80 |
83 state_ = MODEL_LOADED; | 81 state_ = MODEL_LOADED; |
84 model_load_callback_.Run(type(), syncer::SyncError()); | 82 model_load_callback_.Run(type(), SyncError()); |
85 } | 83 } |
86 | 84 |
87 void UIDataTypeController::StartAssociating( | 85 void UIDataTypeController::StartAssociating( |
88 const StartCallback& start_callback) { | 86 const StartCallback& start_callback) { |
89 DCHECK(CalledOnValidThread()); | 87 DCHECK(CalledOnValidThread()); |
90 DCHECK(!start_callback.is_null()); | 88 DCHECK(!start_callback.is_null()); |
91 DCHECK_EQ(state_, MODEL_LOADED); | 89 DCHECK_EQ(state_, MODEL_LOADED); |
92 | 90 |
93 start_callback_ = start_callback; | 91 start_callback_ = start_callback; |
94 state_ = ASSOCIATING; | 92 state_ = ASSOCIATING; |
(...skipping 10 matching lines...) Expand all Loading... |
105 } | 103 } |
106 | 104 |
107 void UIDataTypeController::Associate() { | 105 void UIDataTypeController::Associate() { |
108 DCHECK(CalledOnValidThread()); | 106 DCHECK(CalledOnValidThread()); |
109 if (state_ != ASSOCIATING) { | 107 if (state_ != ASSOCIATING) { |
110 // Stop() must have been called while Associate() task have been waiting. | 108 // Stop() must have been called while Associate() task have been waiting. |
111 DCHECK_EQ(state_, NOT_RUNNING); | 109 DCHECK_EQ(state_, NOT_RUNNING); |
112 return; | 110 return; |
113 } | 111 } |
114 | 112 |
115 syncer::SyncMergeResult local_merge_result(type()); | 113 SyncMergeResult local_merge_result(type()); |
116 syncer::SyncMergeResult syncer_merge_result(type()); | 114 SyncMergeResult syncer_merge_result(type()); |
117 base::WeakPtrFactory<syncer::SyncMergeResult> weak_ptr_factory( | 115 base::WeakPtrFactory<SyncMergeResult> weak_ptr_factory(&syncer_merge_result); |
118 &syncer_merge_result); | |
119 | 116 |
120 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is | 117 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is |
121 // fixed. | 118 // fixed. |
122 tracked_objects::ScopedTracker tracking_profile1( | 119 tracked_objects::ScopedTracker tracking_profile1( |
123 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 120 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
124 "471403 UIDataTypeController::Associate1")); | 121 "471403 UIDataTypeController::Associate1")); |
125 | 122 |
126 // Connect |shared_change_processor_| to the syncer and get the | 123 // Connect |shared_change_processor_| to the syncer and get the |
127 // syncer::SyncableService associated with type(). | 124 // SyncableService associated with type(). |
128 DCHECK(sync_client_->GetSyncService()); | 125 DCHECK(sync_client_->GetSyncService()); |
129 local_service_ = shared_change_processor_->Connect( | 126 local_service_ = shared_change_processor_->Connect( |
130 sync_client_, processor_factory_.get(), | 127 sync_client_, processor_factory_.get(), |
131 sync_client_->GetSyncService()->GetUserShare(), CreateErrorHandler(), | 128 sync_client_->GetSyncService()->GetUserShare(), CreateErrorHandler(), |
132 weak_ptr_factory.GetWeakPtr()); | 129 weak_ptr_factory.GetWeakPtr()); |
133 if (!local_service_.get()) { | 130 if (!local_service_.get()) { |
134 syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, | 131 SyncError error(FROM_HERE, SyncError::DATATYPE_ERROR, |
135 "Failed to connect to syncer.", type()); | 132 "Failed to connect to syncer.", type()); |
136 local_merge_result.set_error(error); | 133 local_merge_result.set_error(error); |
137 StartDone(ASSOCIATION_FAILED, local_merge_result, syncer_merge_result); | 134 StartDone(ASSOCIATION_FAILED, local_merge_result, syncer_merge_result); |
138 return; | 135 return; |
139 } | 136 } |
140 | 137 |
141 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is | 138 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is |
142 // fixed. | 139 // fixed. |
143 tracked_objects::ScopedTracker tracking_profile2( | 140 tracked_objects::ScopedTracker tracking_profile2( |
144 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 141 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
145 "471403 UIDataTypeController::Associate2")); | 142 "471403 UIDataTypeController::Associate2")); |
146 if (!shared_change_processor_->CryptoReadyIfNecessary()) { | 143 if (!shared_change_processor_->CryptoReadyIfNecessary()) { |
147 syncer::SyncError error(FROM_HERE, syncer::SyncError::CRYPTO_ERROR, "", | 144 SyncError error(FROM_HERE, SyncError::CRYPTO_ERROR, "", type()); |
148 type()); | |
149 local_merge_result.set_error(error); | 145 local_merge_result.set_error(error); |
150 StartDone(NEEDS_CRYPTO, local_merge_result, syncer_merge_result); | 146 StartDone(NEEDS_CRYPTO, local_merge_result, syncer_merge_result); |
151 return; | 147 return; |
152 } | 148 } |
153 | 149 |
154 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is | 150 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is |
155 // fixed. | 151 // fixed. |
156 tracked_objects::ScopedTracker tracking_profile3( | 152 tracked_objects::ScopedTracker tracking_profile3( |
157 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 153 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
158 "471403 UIDataTypeController::Associate3")); | 154 "471403 UIDataTypeController::Associate3")); |
159 bool sync_has_nodes = false; | 155 bool sync_has_nodes = false; |
160 if (!shared_change_processor_->SyncModelHasUserCreatedNodes( | 156 if (!shared_change_processor_->SyncModelHasUserCreatedNodes( |
161 &sync_has_nodes)) { | 157 &sync_has_nodes)) { |
162 syncer::SyncError error(FROM_HERE, syncer::SyncError::UNRECOVERABLE_ERROR, | 158 SyncError error(FROM_HERE, SyncError::UNRECOVERABLE_ERROR, |
163 "Failed to load sync nodes", type()); | 159 "Failed to load sync nodes", type()); |
164 local_merge_result.set_error(error); | 160 local_merge_result.set_error(error); |
165 StartDone(UNRECOVERABLE_ERROR, local_merge_result, syncer_merge_result); | 161 StartDone(UNRECOVERABLE_ERROR, local_merge_result, syncer_merge_result); |
166 return; | 162 return; |
167 } | 163 } |
168 | 164 |
169 // Scope for |initial_sync_data| which might be expensive, so we don't want | 165 // Scope for |initial_sync_data| which might be expensive, so we don't want |
170 // to keep it in memory longer than necessary. | 166 // to keep it in memory longer than necessary. |
171 { | 167 { |
172 syncer::SyncDataList initial_sync_data; | 168 SyncDataList initial_sync_data; |
173 | 169 |
174 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 | 170 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 |
175 // is fixed. | 171 // is fixed. |
176 tracked_objects::ScopedTracker tracking_profile4( | 172 tracked_objects::ScopedTracker tracking_profile4( |
177 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 173 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
178 "471403 UIDataTypeController::Associate4")); | 174 "471403 UIDataTypeController::Associate4")); |
179 base::TimeTicks start_time = base::TimeTicks::Now(); | 175 base::TimeTicks start_time = base::TimeTicks::Now(); |
180 syncer::SyncError error = | 176 SyncError error = shared_change_processor_->GetAllSyncDataReturnError( |
181 shared_change_processor_->GetAllSyncDataReturnError(type(), | 177 type(), &initial_sync_data); |
182 &initial_sync_data); | |
183 if (error.IsSet()) { | 178 if (error.IsSet()) { |
184 local_merge_result.set_error(error); | 179 local_merge_result.set_error(error); |
185 StartDone(ASSOCIATION_FAILED, local_merge_result, syncer_merge_result); | 180 StartDone(ASSOCIATION_FAILED, local_merge_result, syncer_merge_result); |
186 return; | 181 return; |
187 } | 182 } |
188 | 183 |
189 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 | 184 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 |
190 // is fixed. | 185 // is fixed. |
191 tracked_objects::ScopedTracker tracking_profile5( | 186 tracked_objects::ScopedTracker tracking_profile5( |
192 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 187 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
193 "471403 UIDataTypeController::Associate5")); | 188 "471403 UIDataTypeController::Associate5")); |
194 std::string datatype_context; | 189 std::string datatype_context; |
195 if (shared_change_processor_->GetDataTypeContext(&datatype_context)) { | 190 if (shared_change_processor_->GetDataTypeContext(&datatype_context)) { |
196 local_service_->UpdateDataTypeContext( | 191 local_service_->UpdateDataTypeContext( |
197 type(), syncer::SyncChangeProcessor::NO_REFRESH, datatype_context); | 192 type(), SyncChangeProcessor::NO_REFRESH, datatype_context); |
198 } | 193 } |
199 | 194 |
200 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 | 195 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 |
201 // is fixed. | 196 // is fixed. |
202 tracked_objects::ScopedTracker tracking_profile6( | 197 tracked_objects::ScopedTracker tracking_profile6( |
203 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 198 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
204 "471403 UIDataTypeController::Associate6")); | 199 "471403 UIDataTypeController::Associate6")); |
205 syncer_merge_result.set_num_items_before_association( | 200 syncer_merge_result.set_num_items_before_association( |
206 initial_sync_data.size()); | 201 initial_sync_data.size()); |
207 // Passes a reference to |shared_change_processor_|. | 202 // Passes a reference to |shared_change_processor_|. |
208 local_merge_result = local_service_->MergeDataAndStartSyncing( | 203 local_merge_result = local_service_->MergeDataAndStartSyncing( |
209 type(), initial_sync_data, | 204 type(), initial_sync_data, |
210 std::unique_ptr<syncer::SyncChangeProcessor>( | 205 std::unique_ptr<SyncChangeProcessor>( |
211 new SharedChangeProcessorRef(shared_change_processor_)), | 206 new SharedChangeProcessorRef(shared_change_processor_)), |
212 std::unique_ptr<syncer::SyncErrorFactory>( | 207 std::unique_ptr<SyncErrorFactory>( |
213 new SharedChangeProcessorRef(shared_change_processor_))); | 208 new SharedChangeProcessorRef(shared_change_processor_))); |
214 RecordAssociationTime(base::TimeTicks::Now() - start_time); | 209 RecordAssociationTime(base::TimeTicks::Now() - start_time); |
215 if (local_merge_result.error().IsSet()) { | 210 if (local_merge_result.error().IsSet()) { |
216 StartDone(ASSOCIATION_FAILED, local_merge_result, syncer_merge_result); | 211 StartDone(ASSOCIATION_FAILED, local_merge_result, syncer_merge_result); |
217 return; | 212 return; |
218 } | 213 } |
219 } | 214 } |
220 | 215 |
221 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is | 216 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is |
222 // fixed. | 217 // fixed. |
(...skipping 21 matching lines...) Expand all Loading... |
244 shared_change_processor_ = NULL; | 239 shared_change_processor_ = NULL; |
245 } | 240 } |
246 | 241 |
247 // We don't want to continue loading models (e.g OnModelLoaded should never be | 242 // We don't want to continue loading models (e.g OnModelLoaded should never be |
248 // called after we've decided to abort). | 243 // called after we've decided to abort). |
249 StopModels(); | 244 StopModels(); |
250 } | 245 } |
251 | 246 |
252 void UIDataTypeController::StartDone( | 247 void UIDataTypeController::StartDone( |
253 ConfigureResult start_result, | 248 ConfigureResult start_result, |
254 const syncer::SyncMergeResult& local_merge_result, | 249 const SyncMergeResult& local_merge_result, |
255 const syncer::SyncMergeResult& syncer_merge_result) { | 250 const SyncMergeResult& syncer_merge_result) { |
256 DCHECK(CalledOnValidThread()); | 251 DCHECK(CalledOnValidThread()); |
257 | 252 |
258 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is | 253 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is |
259 // fixed. | 254 // fixed. |
260 tracked_objects::ScopedTracker tracking_profile( | 255 tracked_objects::ScopedTracker tracking_profile( |
261 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 256 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
262 "471403 UIDataTypeController::StartDone")); | 257 "471403 UIDataTypeController::StartDone")); |
263 | 258 |
264 if (!IsSuccessfulResult(start_result)) { | 259 if (!IsSuccessfulResult(start_result)) { |
265 StopModels(); | 260 StopModels(); |
266 if (start_result == ASSOCIATION_FAILED) { | 261 if (start_result == ASSOCIATION_FAILED) { |
267 state_ = DISABLED; | 262 state_ = DISABLED; |
268 } else { | 263 } else { |
269 state_ = NOT_RUNNING; | 264 state_ = NOT_RUNNING; |
270 } | 265 } |
271 RecordStartFailure(start_result); | 266 RecordStartFailure(start_result); |
272 | 267 |
273 if (shared_change_processor_.get()) { | 268 if (shared_change_processor_.get()) { |
274 shared_change_processor_->Disconnect(); | 269 shared_change_processor_->Disconnect(); |
275 shared_change_processor_ = NULL; | 270 shared_change_processor_ = NULL; |
276 } | 271 } |
277 } | 272 } |
278 | 273 |
279 start_callback_.Run(start_result, local_merge_result, syncer_merge_result); | 274 start_callback_.Run(start_result, local_merge_result, syncer_merge_result); |
280 } | 275 } |
281 | 276 |
282 void UIDataTypeController::Stop() { | 277 void UIDataTypeController::Stop() { |
283 DCHECK(CalledOnValidThread()); | 278 DCHECK(CalledOnValidThread()); |
284 DCHECK(syncer::IsRealDataType(type())); | 279 DCHECK(IsRealDataType(type())); |
285 | 280 |
286 if (state_ == NOT_RUNNING) | 281 if (state_ == NOT_RUNNING) |
287 return; | 282 return; |
288 | 283 |
289 State prev_state = state_; | 284 State prev_state = state_; |
290 state_ = STOPPING; | 285 state_ = STOPPING; |
291 | 286 |
292 if (shared_change_processor_.get()) { | 287 if (shared_change_processor_.get()) { |
293 shared_change_processor_->Disconnect(); | 288 shared_change_processor_->Disconnect(); |
294 shared_change_processor_ = NULL; | 289 shared_change_processor_ = NULL; |
(...skipping 14 matching lines...) Expand all Loading... |
309 local_service_->StopSyncing(type()); | 304 local_service_->StopSyncing(type()); |
310 } | 305 } |
311 | 306 |
312 state_ = NOT_RUNNING; | 307 state_ = NOT_RUNNING; |
313 } | 308 } |
314 | 309 |
315 void UIDataTypeController::StopModels() { | 310 void UIDataTypeController::StopModels() { |
316 // Do nothing by default. | 311 // Do nothing by default. |
317 } | 312 } |
318 | 313 |
319 syncer::ModelSafeGroup UIDataTypeController::model_safe_group() const { | 314 ModelSafeGroup UIDataTypeController::model_safe_group() const { |
320 DCHECK(syncer::IsRealDataType(type())); | 315 DCHECK(IsRealDataType(type())); |
321 return syncer::GROUP_UI; | 316 return GROUP_UI; |
322 } | 317 } |
323 | 318 |
324 std::string UIDataTypeController::name() const { | 319 std::string UIDataTypeController::name() const { |
325 // For logging only. | 320 // For logging only. |
326 return syncer::ModelTypeToString(type()); | 321 return ModelTypeToString(type()); |
327 } | 322 } |
328 | 323 |
329 DataTypeController::State UIDataTypeController::state() const { | 324 DataTypeController::State UIDataTypeController::state() const { |
330 return state_; | 325 return state_; |
331 } | 326 } |
332 | 327 |
333 std::unique_ptr<syncer::DataTypeErrorHandler> | 328 std::unique_ptr<DataTypeErrorHandler> |
334 UIDataTypeController::CreateErrorHandler() { | 329 UIDataTypeController::CreateErrorHandler() { |
335 DCHECK(CalledOnValidThread()); | 330 DCHECK(CalledOnValidThread()); |
336 return base::MakeUnique<syncer::DataTypeErrorHandlerImpl>( | 331 return base::MakeUnique<DataTypeErrorHandlerImpl>( |
337 base::ThreadTaskRunnerHandle::Get(), dump_stack_, | 332 base::ThreadTaskRunnerHandle::Get(), dump_stack_, |
338 base::Bind(&UIDataTypeController::OnUnrecoverableError, | 333 base::Bind(&UIDataTypeController::OnUnrecoverableError, |
339 base::AsWeakPtr(this))); | 334 base::AsWeakPtr(this))); |
340 } | 335 } |
341 | 336 |
342 void UIDataTypeController::OnUnrecoverableError( | 337 void UIDataTypeController::OnUnrecoverableError(const SyncError& error) { |
343 const syncer::SyncError& error) { | |
344 DCHECK(CalledOnValidThread()); | 338 DCHECK(CalledOnValidThread()); |
345 DCHECK_EQ(type(), error.model_type()); | 339 DCHECK_EQ(type(), error.model_type()); |
346 if (!model_load_callback_.is_null()) { | 340 if (!model_load_callback_.is_null()) { |
347 model_load_callback_.Run(type(), error); | 341 model_load_callback_.Run(type(), error); |
348 } | 342 } |
349 } | 343 } |
350 | 344 |
351 void UIDataTypeController::RecordAssociationTime(base::TimeDelta time) { | 345 void UIDataTypeController::RecordAssociationTime(base::TimeDelta time) { |
352 DCHECK(CalledOnValidThread()); | 346 DCHECK(CalledOnValidThread()); |
353 #define PER_DATA_TYPE_MACRO(type_str) \ | 347 #define PER_DATA_TYPE_MACRO(type_str) \ |
354 UMA_HISTOGRAM_TIMES("Sync." type_str "AssociationTime", time); | 348 UMA_HISTOGRAM_TIMES("Sync." type_str "AssociationTime", time); |
355 SYNC_DATA_TYPE_HISTOGRAM(type()); | 349 SYNC_DATA_TYPE_HISTOGRAM(type()); |
356 #undef PER_DATA_TYPE_MACRO | 350 #undef PER_DATA_TYPE_MACRO |
357 } | 351 } |
358 | 352 |
359 void UIDataTypeController::RecordStartFailure(ConfigureResult result) { | 353 void UIDataTypeController::RecordStartFailure(ConfigureResult result) { |
360 DCHECK(CalledOnValidThread()); | 354 DCHECK(CalledOnValidThread()); |
361 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeStartFailures", | 355 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeStartFailures", |
362 ModelTypeToHistogramInt(type()), | 356 ModelTypeToHistogramInt(type()), MODEL_TYPE_COUNT); |
363 syncer::MODEL_TYPE_COUNT); | |
364 #define PER_DATA_TYPE_MACRO(type_str) \ | 357 #define PER_DATA_TYPE_MACRO(type_str) \ |
365 UMA_HISTOGRAM_ENUMERATION("Sync." type_str "ConfigureFailure", result, \ | 358 UMA_HISTOGRAM_ENUMERATION("Sync." type_str "ConfigureFailure", result, \ |
366 MAX_CONFIGURE_RESULT); | 359 MAX_CONFIGURE_RESULT); |
367 SYNC_DATA_TYPE_HISTOGRAM(type()); | 360 SYNC_DATA_TYPE_HISTOGRAM(type()); |
368 #undef PER_DATA_TYPE_MACRO | 361 #undef PER_DATA_TYPE_MACRO |
369 } | 362 } |
370 | 363 |
371 } // namespace sync_driver | 364 } // namespace syncer |
OLD | NEW |