Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: components/sync/driver/model_type_controller.cc

Issue 2886933003: Use stricter type checking in UMA_HISTOGRAM_ENUMERATION (Closed)
Patch Set: simplify type checking Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/model_type_controller.h" 5 #include "components/sync/driver/model_type_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 21 matching lines...) Expand all
32 const ModelErrorHandler& error_handler, 32 const ModelErrorHandler& error_handler,
33 const ModelTypeChangeProcessor::StartCallback& callback, 33 const ModelTypeChangeProcessor::StartCallback& callback,
34 ModelTypeSyncBridge* bridge) { 34 ModelTypeSyncBridge* bridge) {
35 bridge->OnSyncStarting(std::move(error_handler), std::move(callback)); 35 bridge->OnSyncStarting(std::move(error_handler), std::move(callback));
36 } 36 }
37 37
38 void ReportError(ModelType model_type, 38 void ReportError(ModelType model_type,
39 scoped_refptr<base::SingleThreadTaskRunner> ui_thread, 39 scoped_refptr<base::SingleThreadTaskRunner> ui_thread,
40 const ModelErrorHandler& error_handler, 40 const ModelErrorHandler& error_handler,
41 const ModelError& error) { 41 const ModelError& error) {
42 // TODO(wychen): enum uma should be strongly typed. crbug.com/661401
42 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeRunFailures", 43 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeRunFailures",
43 ModelTypeToHistogramInt(model_type), 44 ModelTypeToHistogramInt(model_type),
44 MODEL_TYPE_COUNT); 45 static_cast<int>(MODEL_TYPE_COUNT));
45 ui_thread->PostTask(error.location(), base::Bind(error_handler, error)); 46 ui_thread->PostTask(error.location(), base::Bind(error_handler, error));
46 } 47 }
47 48
48 // This function allows us to return a Callback using Bind that returns the 49 // This function allows us to return a Callback using Bind that returns the
49 // given |arg|. This function itself does nothing. 50 // given |arg|. This function itself does nothing.
50 base::WeakPtr<ModelTypeSyncBridge> ReturnCapturedBridge( 51 base::WeakPtr<ModelTypeSyncBridge> ReturnCapturedBridge(
51 base::WeakPtr<ModelTypeSyncBridge> arg) { 52 base::WeakPtr<ModelTypeSyncBridge> arg) {
52 return arg; 53 return arg;
53 } 54 }
54 55
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 244
244 void ModelTypeController::ReportModelError(const ModelError& error) { 245 void ModelTypeController::ReportModelError(const ModelError& error) {
245 DCHECK(CalledOnValidThread()); 246 DCHECK(CalledOnValidThread());
246 LoadModelsDone(UNRECOVERABLE_ERROR, 247 LoadModelsDone(UNRECOVERABLE_ERROR,
247 SyncError(error.location(), SyncError::DATATYPE_ERROR, 248 SyncError(error.location(), SyncError::DATATYPE_ERROR,
248 error.message(), type())); 249 error.message(), type()));
249 } 250 }
250 251
251 void ModelTypeController::RecordStartFailure(ConfigureResult result) const { 252 void ModelTypeController::RecordStartFailure(ConfigureResult result) const {
252 DCHECK(CalledOnValidThread()); 253 DCHECK(CalledOnValidThread());
254 // TODO(wychen): enum uma should be strongly typed. crbug.com/661401
253 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeStartFailures", 255 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeStartFailures",
254 ModelTypeToHistogramInt(type()), MODEL_TYPE_COUNT); 256 ModelTypeToHistogramInt(type()),
257 static_cast<int>(MODEL_TYPE_COUNT));
255 #define PER_DATA_TYPE_MACRO(type_str) \ 258 #define PER_DATA_TYPE_MACRO(type_str) \
256 UMA_HISTOGRAM_ENUMERATION("Sync." type_str "ConfigureFailure", result, \ 259 UMA_HISTOGRAM_ENUMERATION("Sync." type_str "ConfigureFailure", result, \
257 MAX_CONFIGURE_RESULT); 260 MAX_CONFIGURE_RESULT);
258 SYNC_DATA_TYPE_HISTOGRAM(type()); 261 SYNC_DATA_TYPE_HISTOGRAM(type());
259 #undef PER_DATA_TYPE_MACRO 262 #undef PER_DATA_TYPE_MACRO
260 } 263 }
261 264
262 BridgeProvider ModelTypeController::GetBridgeProvider() { 265 BridgeProvider ModelTypeController::GetBridgeProvider() {
263 // Get the bridge eagerly, and capture the weak pointer. 266 // Get the bridge eagerly, and capture the weak pointer.
264 base::WeakPtr<ModelTypeSyncBridge> bridge = 267 base::WeakPtr<ModelTypeSyncBridge> bridge =
265 sync_client_->GetSyncBridgeForModelType(type()); 268 sync_client_->GetSyncBridgeForModelType(type());
266 return base::Bind(&ReturnCapturedBridge, bridge); 269 return base::Bind(&ReturnCapturedBridge, bridge);
267 } 270 }
268 271
269 void ModelTypeController::PostBridgeTask( 272 void ModelTypeController::PostBridgeTask(
270 const tracked_objects::Location& location, 273 const tracked_objects::Location& location,
271 const BridgeTask& task) { 274 const BridgeTask& task) {
272 model_thread_->PostTask( 275 model_thread_->PostTask(
273 location, base::Bind(&RunBridgeTask, GetBridgeProvider(), task)); 276 location, base::Bind(&RunBridgeTask, GetBridgeProvider(), task));
274 } 277 }
275 } // namespace syncer 278 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/model_association_manager.cc ('k') | components/sync/driver/startup_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698