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

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

Issue 2886933003: Use stricter type checking in UMA_HISTOGRAM_ENUMERATION (Closed)
Patch Set: nocompile test Created 3 years, 6 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 239
239 void ModelTypeController::ReportModelError(const ModelError& error) { 240 void ModelTypeController::ReportModelError(const ModelError& error) {
240 DCHECK(CalledOnValidThread()); 241 DCHECK(CalledOnValidThread());
241 LoadModelsDone(UNRECOVERABLE_ERROR, 242 LoadModelsDone(UNRECOVERABLE_ERROR,
242 SyncError(error.location(), SyncError::DATATYPE_ERROR, 243 SyncError(error.location(), SyncError::DATATYPE_ERROR,
243 error.message(), type())); 244 error.message(), type()));
244 } 245 }
245 246
246 void ModelTypeController::RecordStartFailure(ConfigureResult result) const { 247 void ModelTypeController::RecordStartFailure(ConfigureResult result) const {
247 DCHECK(CalledOnValidThread()); 248 DCHECK(CalledOnValidThread());
249 // TODO(wychen): enum uma should be strongly typed. crbug.com/661401
248 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeStartFailures", 250 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeStartFailures",
249 ModelTypeToHistogramInt(type()), MODEL_TYPE_COUNT); 251 ModelTypeToHistogramInt(type()),
252 static_cast<int>(MODEL_TYPE_COUNT));
250 #define PER_DATA_TYPE_MACRO(type_str) \ 253 #define PER_DATA_TYPE_MACRO(type_str) \
251 UMA_HISTOGRAM_ENUMERATION("Sync." type_str "ConfigureFailure", result, \ 254 UMA_HISTOGRAM_ENUMERATION("Sync." type_str "ConfigureFailure", result, \
252 MAX_CONFIGURE_RESULT); 255 MAX_CONFIGURE_RESULT);
253 SYNC_DATA_TYPE_HISTOGRAM(type()); 256 SYNC_DATA_TYPE_HISTOGRAM(type());
254 #undef PER_DATA_TYPE_MACRO 257 #undef PER_DATA_TYPE_MACRO
255 } 258 }
256 259
257 BridgeProvider ModelTypeController::GetBridgeProvider() { 260 BridgeProvider ModelTypeController::GetBridgeProvider() {
258 // Get the bridge eagerly, and capture the weak pointer. 261 // Get the bridge eagerly, and capture the weak pointer.
259 base::WeakPtr<ModelTypeSyncBridge> bridge = 262 base::WeakPtr<ModelTypeSyncBridge> bridge =
260 sync_client_->GetSyncBridgeForModelType(type()); 263 sync_client_->GetSyncBridgeForModelType(type());
261 return base::Bind(&ReturnCapturedBridge, bridge); 264 return base::Bind(&ReturnCapturedBridge, bridge);
262 } 265 }
263 266
264 void ModelTypeController::PostBridgeTask( 267 void ModelTypeController::PostBridgeTask(
265 const tracked_objects::Location& location, 268 const tracked_objects::Location& location,
266 const BridgeTask& task) { 269 const BridgeTask& task) {
267 model_thread_->PostTask( 270 model_thread_->PostTask(
268 location, base::Bind(&RunBridgeTask, GetBridgeProvider(), task)); 271 location, base::Bind(&RunBridgeTask, GetBridgeProvider(), task));
269 } 272 }
270 } // namespace syncer 273 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698