Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/login/report_restarting_flags.h" | |
| 6 | |
| 7 #include <algorithm> | |
| 8 #include <set> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "ash/ash_switches.h" | |
| 12 #include "base/logging.h" | |
| 13 #include "base/metrics/sparse_histogram.h" | |
| 14 #include "cc/base/switches.h" | |
| 15 #include "chrome/common/chrome_switches.h" | |
| 16 #include "chromeos/chromeos_switches.h" | |
| 17 #include "components/autofill/core/common/autofill_switches.h" | |
| 18 #include "components/cloud_devices/common/cloud_devices_switches.h" | |
| 19 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h " | |
| 20 #include "components/nacl/common/nacl_switches.h" | |
| 21 #include "components/password_manager/core/common/password_manager_switches.h" | |
| 22 #include "content/public/common/content_switches.h" | |
| 23 #include "extensions/common/switches.h" | |
| 24 #include "third_party/cros_system_api/switches/chrome_switches.h" | |
| 25 #include "ui/app_list/app_list_switches.h" | |
| 26 #include "ui/base/ui_base_switches.h" | |
| 27 #include "ui/display/display_switches.h" | |
| 28 #include "ui/events/event_switches.h" | |
| 29 #include "ui/gfx/switches.h" | |
| 30 #include "ui/keyboard/keyboard_switches.h" | |
| 31 #include "ui/native_theme/native_theme_switches.h" | |
| 32 #include "ui/views/views_switches.h" | |
| 33 | |
| 34 namespace { | |
| 35 | |
| 36 /* Reserved histogram values */ | |
| 37 enum { | |
| 38 UNKNOWN_FLAG = 0, | |
| 39 BAD_FLAG_FORMAT = 1, | |
| 40 }; | |
| 41 | |
| 42 /* This table shoud consist of all possible command-line switches from | |
| 43 chrome/browser/about_flags.cc | |
| 44 | |
| 45 This is a mapping between switch name and UMA id. Indexes in this table | |
| 46 must never be modified. Plase add new value to the end of the table only! | |
| 47 | |
| 48 If some entry should be deleted, replace it with empty string and a comment | |
| 49 describing what was deleted. | |
| 50 | |
| 51 This table must be in sync with LoginRestartingFlags in | |
| 52 tools/metrics/histogram.xml . | |
| 53 | |
| 54 NOTE: This table is intentionally unsorted to force anyone to read this | |
| 55 comment before modifying the table. | |
| 56 */ | |
| 57 | |
| 58 const char* const chrome_restart_histogram_switches[] = { | |
| 59 "" /* UNKNOWN_FLAG - reserved */, | |
| 60 "" /* BAD_FLAG_FORMAT - reserved */, | |
| 61 "" /* unused - reserved */, | |
| 62 "" /* unused - reserved */, | |
| 63 "" /* unused - reserved */, | |
| 64 switches::kOverscrollHistoryNavigation, | |
| 65 switches::kEnableServiceWorkerSync, | |
| 66 switches::kNoPings, | |
| 67 switches::kNoExperiments, | |
| 68 switches::kEnableOneCopy, | |
| 69 switches::kDisableGestureTapHighlight, | |
| 70 chromeos::switches::kFileManagerEnableNewGallery, | |
| 71 switches::kEnableQuicHttps, | |
| 72 chromeos::switches::kEnableNetworkPortalNotification, | |
| 73 switches::kEnableCompositingForFixedPosition, | |
| 74 keyboard::switches::kEnableVirtualKeyboardOverscroll, | |
| 75 switches::kAllowInsecureWebSocketFromHttpsOrigin, | |
| 76 switches::kEnableWebBasedSignin, | |
| 77 cc::switches::kShowFPSCounter, | |
| 78 switches::kEnableOfflineAutoReload, | |
| 79 chromeos::switches::kEnableFileManagerMTP, | |
| 80 switches::kEnablePanels, | |
| 81 extensions::switches::kEnableScriptsRequireAction, | |
| 82 switches::kEnableSmoothScrolling, | |
| 83 switches::kDisableDelegatedRenderer, | |
| 84 switches::kTouchEventsDisabled, | |
| 85 switches::kMalwareInterstitialVersionV2, | |
| 86 switches::kDisableTouchEditing, | |
| 87 switches::kPrefetchSearchResults, | |
| 88 switches::kDisablePasswordManagerReauthentication, | |
| 89 switches::kEnableSearchButtonInOmniboxAlways, | |
| 90 switches::kDisableWebAudio, | |
| 91 switches::kDefaultTileHeight, | |
| 92 switches::kEnableSessionCrashedBubble, | |
| 93 chromeos::switches::kDisableQuickofficeComponentApp, | |
| 94 switches::kDebugPackedApps, | |
| 95 switches::kEnableSuggestionsService, | |
| 96 switches::kTabCaptureDownscaleQuality, | |
| 97 switches::kManualEnhancedBookmarksOptout, | |
| 98 switches::kDisableAcceleratedFixedRootBackground, | |
| 99 ash::switches::kAshTouchHud, | |
| 100 switches::kDisableDeviceEnumeration, | |
| 101 cc::switches::kDisablePinchVirtualViewport, | |
| 102 switches::kEnableDeferredImageDecoding, | |
| 103 keyboard::switches::kDisableInputView, | |
| 104 switches::kDisableDeviceDiscoveryNotifications, | |
| 105 autofill::switches::kEnablePasswordGeneration, | |
| 106 switches::kManualEnhancedBookmarks, | |
| 107 extensions::switches::kExtensionContentVerification, | |
| 108 switches::kEnableEphemeralApps, | |
| 109 switches::kEnableQuic, | |
| 110 chromeos::switches::kEnableFirstRunUITransitions, | |
| 111 switches::kEnableSearchButtonInOmniboxForStr, | |
| 112 switches::kEnableDistanceFieldText, | |
| 113 switches::kDisableTextInputFocusManager, | |
| 114 switches::kTouchScrollingMode, | |
| 115 switches::kDisableOverlayScrollbar, | |
| 116 cc::switches::kMaxTilesForInterestArea, | |
| 117 switches::kForceGpuRasterization, | |
| 118 switches::kAllowNaClSocketAPI, | |
| 119 chromeos::switches::kEnableRequestTabletSite, | |
| 120 extensions::switches::kExtensionContentVerificationEnforceStrict, | |
| 121 switches::kDisableSoftwareRasterizer, | |
| 122 switches::kEnableAppsFileAssociations, | |
| 123 switches::kSSLInterstitialVersionV2Gray, | |
| 124 autofill::switches::kShowAutofillTypePredictions, | |
| 125 switches::kEnableViewportMeta, | |
| 126 switches::kSilentDebuggerExtensionAPI, | |
| 127 switches::kDisableGpuRasterization, | |
| 128 switches::kFlagSwitchesBegin, | |
| 129 switches::kDisableOfflineLoadStaleCache, | |
| 130 keyboard::switches::kEnableVirtualKeyboard, | |
| 131 switches::kDisableThreadedCompositing, | |
| 132 switches::kEnableGpuRasterization, | |
| 133 switches::kDisableSettingsWindow, | |
| 134 switches::kEnableDelegatedRenderer, | |
| 135 switches::kEnableScrollPrediction, | |
| 136 switches::kEnableAcceleratedOverflowScroll, | |
| 137 switches::kDisableCompositingForFixedPosition, | |
| 138 switches::kDisableWebRtcHWEncoding, | |
| 139 switches::kEnableSearchButtonInOmniboxForStrOrIip, | |
| 140 switches::kEnableBleedingEdgeRenderingFastPaths, | |
| 141 switches::kDisableSavePasswordBubble, | |
| 142 switches::kEnableSettingsWindow, | |
| 143 switches::kDisableDeviceDiscovery, | |
| 144 switches::kDisableZeroCopy, | |
| 145 switches::kEnableNaClDebug, | |
| 146 switches::kEnableSavePasswordBubble, | |
| 147 switches::kDisablePrefixedEncryptedMedia, | |
| 148 switches::kDefaultTileWidth, | |
| 149 switches::kDisableEmbeddedSharedWorker, | |
| 150 switches::kDisableSessionCrashedBubble, | |
| 151 switches::kEnableDeviceDiscoveryNotifications, | |
| 152 chromeos::switches::kEnableCarrierSwitching, | |
| 153 switches::kEnableOfflineLoadStaleCache, | |
| 154 switches::kEnableAnswersInSuggest, | |
| 155 switches::kEnableAppList, | |
| 156 cc::switches::kEnablePinchVirtualViewport, | |
| 157 switches::kDisableOfflineAutoReload, | |
| 158 switches::kEnableFastTextAutosizing, | |
| 159 switches::kEnablePrintPreviewRegisterPromos, | |
| 160 switches::kEnableThreadedCompositing, | |
| 161 switches::kEnablePermissionsBubbles, | |
| 162 switches::kEnableEasyUnlock, | |
| 163 chromeos::switches::kDisableSamlSignin, | |
| 164 autofill::switches::kDisableIgnoreAutocompleteOff, | |
| 165 views::switches::kDisableViewsRectBasedTargeting, | |
| 166 switches::kPerformanceMonitorGathering, | |
| 167 cc::switches::kShowCompositedLayerBorders, | |
| 168 keyboard::switches::kEnableInputView, | |
| 169 autofill::switches::kWalletServiceUseSandbox, | |
| 170 chromeos::switches::kPolicySwitchesBegin, | |
| 171 switches::kEnableOverlayScrollbar, | |
| 172 switches::kEnableAccountConsistency, | |
| 173 switches::kDisableMediaSource, | |
| 174 switches::kEnableServiceWorker, | |
| 175 switches::kEnableTouchEditing, | |
| 176 switches::kEnableTranslateNewUX, | |
| 177 switches::kForceDeviceScaleFactor, | |
| 178 ash::switches::kAshDebugShortcuts, | |
| 179 switches::kDisableAccelerated2dCanvas, | |
| 180 switches::kDisableSuggestionsService, | |
| 181 switches::kNumRasterThreads, | |
| 182 password_manager::switches::kEnableAutomaticPasswordSaving, | |
| 183 switches::kEnableAppWindowControls, | |
| 184 switches::kDisableQuic, | |
| 185 switches::kDisableOriginChip, | |
| 186 switches::kMalwareInterstitialVersionV3, | |
| 187 switches::kTouchEvents, | |
| 188 keyboard::switches::kEnableExperimentalInputViewFeatures, | |
| 189 keyboard::switches::kDisableVirtualKeyboardOverscroll, | |
| 190 switches::kEnableAsyncDns, | |
| 191 switches::kGoogleProfileInfo, | |
| 192 switches::kEnableExperimentalWebPlatformFeatures, | |
| 193 switches::kEnableSpellingAutoCorrect, | |
| 194 switches::kEnableWebMIDI, | |
| 195 switches::kEnableNaCl, | |
| 196 switches::kOutOfProcessPdf, | |
| 197 switches::kDisableTouchAdjustment, | |
| 198 switches::kEnableProminentURLAppFlow, | |
| 199 switches::kEnableHarfBuzzRenderText, | |
| 200 switches::kEnableOriginChipAlways, | |
| 201 switches::kDisableDistanceFieldText, | |
| 202 switches::kEnableTextInputFocusManager, | |
| 203 switches::kFastUserSwitching, | |
| 204 switches::kEnableEncryptedMedia, | |
| 205 switches::kDisableQuicHttps, | |
| 206 switches::kSSLInterstitialVersionV1, | |
| 207 switches::kEnableSpdy4, | |
| 208 switches::kDisablePermissionsBubbles, | |
| 209 switches::kNewAvatarMenu, | |
| 210 switches::kEnableHighDpiCompositingForFixedPosition, | |
| 211 switches::kEnableTouchDragDrop, | |
| 212 switches::kDisableLCDText, | |
| 213 switches::kEnableCompositingForTransition, | |
| 214 switches::kEnableImplSidePainting, | |
| 215 switches::kIgnoreGpuBlacklist, | |
| 216 switches::kTouchEventsEnabled, | |
| 217 switches::kEnableDownloadResumption, | |
| 218 switches::kJavaScriptFlags, | |
| 219 switches::kDisableCompositingForTransition, | |
| 220 switches::kTouchScrollingModeSyncTouchmove, | |
| 221 extensions::switches::kEnableExperimentalExtensionApis, | |
| 222 switches::kEnableGestureTapHighlight, | |
| 223 switches::kNaClDebugMask, | |
| 224 switches::kEnhancedBookmarksExperiment, | |
| 225 switches::kEnableFastUnload, | |
| 226 chromeos::switches::kDisableBootAnimation, | |
| 227 switches::kDisableNTPOtherSessionsMenu, | |
| 228 switches::kEnableOriginChipOnSrp, | |
| 229 switches::kDisableAccountConsistency, | |
| 230 switches::kScrollEndEffect, | |
| 231 switches::kTouchScrollingModeTouchcancel, | |
| 232 switches::kDisablePnacl, | |
| 233 switches::kSSLInterstitialVersionV2Colorful, | |
| 234 switches::kEnableNewProfileManagement, | |
| 235 switches::kEnableAppsShowOnFirstPaint, | |
| 236 switches::kEnablePinch, | |
| 237 switches::kResetAppListInstallState, | |
| 238 switches::kDisableImplSidePainting, | |
| 239 autofill::switches::kDisablePasswordGeneration, | |
| 240 switches::kEnableExperimentalCanvasFeatures, | |
| 241 switches::kEnableOfflineAutoReloadVisibleOnly, | |
| 242 switches::kEnableStreamlinedHostedApps, | |
| 243 switches::kTouchScrollingModeAsyncTouchmove, | |
| 244 switches::kDisableTouchDragDrop, | |
| 245 data_reduction_proxy::switches::kEnableDataReductionProxyDev, | |
| 246 switches::kEnableSpellingFeedbackFieldTrial, | |
| 247 switches::kTabCaptureUpscaleQuality, | |
| 248 switches::kEnableLCDText, | |
| 249 keyboard::switches::kEnableSwipeSelection, | |
| 250 switches::kEnableWebGLDraftExtensions, | |
| 251 switches::kEnableSyncSyncedNotifications, | |
| 252 switches::kEnableCloudDevices, | |
| 253 extensions::switches::kExtensionContentVerificationBootstrap, | |
| 254 switches::kFlagSwitchesEnd, | |
| 255 switches::kDisableSearchButtonInOmnibox, | |
| 256 switches::kDisableOfflineAutoReloadVisibleOnly, | |
| 257 chromeos::switches::kPolicySwitchesEnd, | |
| 258 switches::kDisableExperimentalWebGL, | |
| 259 extensions::switches::kExtensionContentVerificationEnforce, | |
| 260 switches::kDisableLayerSquashing, | |
| 261 extensions::switches::kExtensionsOnChromeURLs, | |
| 262 chromeos::switches::kDisableNetworkPortalNotification, | |
| 263 ash::switches::kAshEnableTouchViewTesting, | |
| 264 chromeos::switches::kEnableTouchpadThreeFingerClick, | |
| 265 chromeos::switches::kFileManagerEnableNewAudioPlayer, | |
| 266 switches::kDisableFastTextAutosizing, | |
| 267 switches::kDisableMinimizeOnSecondLauncherItemClick, | |
| 268 switches::kDisableWebRtcHWDecoding, | |
| 269 switches::kDisableAcceleratedVideoDecode, | |
| 270 switches::kSavePageAsMHTML, | |
| 271 switches::kDisableNewProfileManagement, | |
| 272 switches::kEnableZeroCopy, | |
| 273 switches::kEnableLinkableEphemeralApps, | |
| 274 switches::kUseSimpleCacheBackend, | |
| 275 switches::kEnableDevToolsExperiments, | |
| 276 switches::kDisableSyncSyncedNotifications, | |
| 277 cc::switches::kDisableCompositorTouchHitTesting, | |
| 278 switches::kEnableAcceleratedFixedRootBackground, | |
| 279 switches::kEnableTcpFastOpen, | |
| 280 switches::kDisableAsyncDns, | |
| 281 switches::kSyncfsEnableDirectoryOperation, | |
| 282 data_reduction_proxy::switches::kDisableDataReductionProxyDev, | |
| 283 ui::switches::kDisableDisplayColorCalibration, | |
| 284 switches::kDisableAcceleratedOverflowScroll, | |
| 285 | |
| 286 /* Insert new entries here. Never modify existing entries! */ | |
| 287 }; | |
| 288 | |
| 289 } // namespace | |
| 290 | |
| 291 namespace chromeos { | |
| 292 | |
| 293 void ReportRestartingFlags( | |
| 294 const std::set<std::string>& command_line_difference) { | |
| 295 for (size_t i = 0; i < arraysize(chrome_restart_histogram_switches); ++i) { | |
| 296 LOG(ERROR) << "ReportRestartingFlags(): i=" << i << " \"" | |
|
Nikita (slow)
2014/06/19 17:26:44
Debug output?
Alexander Alekseev
2014/06/19 18:17:47
Done.
| |
| 297 << chrome_restart_histogram_switches[i] << "\""; | |
| 298 } | |
| 299 | |
| 300 for (std::set<std::string>::const_iterator i = | |
| 301 command_line_difference.begin(); | |
| 302 i != command_line_difference.end(); | |
| 303 ++i) { | |
| 304 int uma_id = UNKNOWN_FLAG; | |
| 305 if (i->size() > 2) { | |
| 306 // skip '--' before switch name | |
| 307 const char* switch_name = &((*i)[2]); | |
| 308 const char* const* end = chrome_restart_histogram_switches + | |
| 309 arraysize(chrome_restart_histogram_switches); | |
| 310 const char* const* histflag = std::find_if( | |
| 311 chrome_restart_histogram_switches, | |
| 312 end, | |
| 313 std::not1(std::bind1st(std::ptr_fun(strcmp), switch_name))); | |
| 314 uma_id = histflag - chrome_restart_histogram_switches; | |
| 315 if (histflag == end) { | |
| 316 uma_id = UNKNOWN_FLAG; | |
| 317 LOG(ERROR) << "ReportRestartingFlags(): flag '" << *i << "' ('" | |
| 318 << switch_name << "') is unknown."; | |
| 319 } | |
| 320 } else { | |
| 321 uma_id = BAD_FLAG_FORMAT; | |
| 322 LOG(ERROR) << "ReportRestartingFlags(): flag '" << *i | |
| 323 << "' has incorrect format."; | |
| 324 } | |
| 325 DCHECK_LT(uma_id, | |
| 326 static_cast<int>(arraysize(chrome_restart_histogram_switches))); | |
| 327 VLOG(1) << "ReportRestartingFlags(): '" << *i << "', uma_id=" << uma_id | |
| 328 << " ('" << chrome_restart_histogram_switches[uma_id] << "')"; | |
| 329 UMA_HISTOGRAM_SPARSE_SLOWLY("Login.RestartingFlags", uma_id); | |
|
Nikita (slow)
2014/06/19 17:26:44
Maybe UMA_HISTOGRAM_ENUMERATION is better suited h
Alexander Alekseev
2014/06/24 21:51:52
As jar@ has suggested, we'd better use SPARSE here
| |
| 330 } | |
| 331 } | |
| 332 | |
| 333 const char* const* GetChromeRestartHistogramSwitchesForTesting( | |
| 334 size_t* out_size) { | |
| 335 *out_size = arraysize(chrome_restart_histogram_switches); | |
| 336 return chrome_restart_histogram_switches; | |
| 337 } | |
| 338 | |
| 339 } // namespace chromeos | |
| OLD | NEW |