| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #import "ios/chrome/browser/ui/sync/sync_util.h" | 5 #import "ios/chrome/browser/ui/sync/sync_util.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "components/infobars/core/infobar_manager.h" | 8 #include "components/infobars/core/infobar_manager.h" |
| 9 #include "components/strings/grit/components_strings.h" | 9 #include "components/strings/grit/components_strings.h" |
| 10 #import "ios/chrome/browser/browser_state/chrome_browser_state.h" | 10 #import "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 #if !defined(__has_feature) || !__has_feature(objc_arc) | 22 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 23 #error "This file requires ARC support." | 23 #error "This file requires ARC support." |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 // Enumerated constants for logging when a sign-in error infobar was shown | 27 // Enumerated constants for logging when a sign-in error infobar was shown |
| 28 // to the user. This was added for crbug/265352 to quantify how often this | 28 // to the user. This was added for crbug/265352 to quantify how often this |
| 29 // bug shows up in the wild. The logged histogram count should be interpreted | 29 // bug shows up in the wild. The logged histogram count should be interpreted |
| 30 // as a ratio of the number of active sync users. | 30 // as a ratio of the number of active sync users. |
| 31 enum { | 31 enum ErrorState { |
| 32 SYNC_SIGN_IN_NEEDS_UPDATE = 1, | 32 SYNC_SIGN_IN_NEEDS_UPDATE = 1, |
| 33 SYNC_SERVICE_UNAVAILABLE, | 33 SYNC_SERVICE_UNAVAILABLE, |
| 34 SYNC_NEEDS_PASSPHRASE, | 34 SYNC_NEEDS_PASSPHRASE, |
| 35 SYNC_UNRECOVERABLE_ERROR, | 35 SYNC_UNRECOVERABLE_ERROR, |
| 36 SYNC_ERROR_COUNT | 36 SYNC_ERROR_COUNT |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 namespace ios_internal { | 41 namespace ios_internal { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 SyncSetupService* syncSetupService = | 135 SyncSetupService* syncSetupService = |
| 136 SyncSetupServiceFactory::GetForBrowserState(browser_state); | 136 SyncSetupServiceFactory::GetForBrowserState(browser_state); |
| 137 if (!syncSetupService) | 137 if (!syncSetupService) |
| 138 return false; | 138 return false; |
| 139 SyncSetupService::SyncServiceState errorState = | 139 SyncSetupService::SyncServiceState errorState = |
| 140 syncSetupService->GetSyncServiceState(); | 140 syncSetupService->GetSyncServiceState(); |
| 141 if (IsTransientSyncError(errorState)) | 141 if (IsTransientSyncError(errorState)) |
| 142 return false; | 142 return false; |
| 143 | 143 |
| 144 // Logs when an infobar is shown to user. See crbug/265352. | 144 // Logs when an infobar is shown to user. See crbug/265352. |
| 145 int loggedErrorState = 0; | 145 ErrorState loggedErrorState = SYNC_ERROR_COUNT; |
| 146 switch (errorState) { | 146 switch (errorState) { |
| 147 case SyncSetupService::kNoSyncServiceError: | 147 case SyncSetupService::kNoSyncServiceError: |
| 148 case SyncSetupService::kSyncServiceCouldNotConnect: | 148 case SyncSetupService::kSyncServiceCouldNotConnect: |
| 149 case SyncSetupService::kSyncServiceServiceUnavailable: | 149 case SyncSetupService::kSyncServiceServiceUnavailable: |
| 150 NOTREACHED(); | 150 NOTREACHED(); |
| 151 break; | 151 break; |
| 152 case SyncSetupService::kSyncServiceSignInNeedsUpdate: | 152 case SyncSetupService::kSyncServiceSignInNeedsUpdate: |
| 153 loggedErrorState = SYNC_SIGN_IN_NEEDS_UPDATE; | 153 loggedErrorState = SYNC_SIGN_IN_NEEDS_UPDATE; |
| 154 break; | 154 break; |
| 155 case SyncSetupService::kSyncServiceNeedsPassphrase: | 155 case SyncSetupService::kSyncServiceNeedsPassphrase: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 175 return true; | 175 return true; |
| 176 case SyncSetupService::kSyncServiceSignInNeedsUpdate: | 176 case SyncSetupService::kSyncServiceSignInNeedsUpdate: |
| 177 case SyncSetupService::kSyncServiceNeedsPassphrase: | 177 case SyncSetupService::kSyncServiceNeedsPassphrase: |
| 178 case SyncSetupService::kSyncServiceUnrecoverableError: | 178 case SyncSetupService::kSyncServiceUnrecoverableError: |
| 179 return false; | 179 return false; |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace sync | 183 } // namespace sync |
| 184 } // namespace ios_internal | 184 } // namespace ios_internal |
| OLD | NEW |