// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ios/chrome/browser/browser_state_metrics/browser_state_metrics.h" #include #include "components/profile_metrics/counts.h" #include "ios/chrome/browser/browser_state/browser_state_info_cache.h" #include "ios/chrome/browser/browser_state/chrome_browser_state_manager.h" bool CountBrowserStateInformation(ios::ChromeBrowserStateManager* manager, profile_metrics::Counts* counts) { BrowserStateInfoCache* info_cache = manager->GetBrowserStateInfoCache(); size_t number_of_browser_states = info_cache->GetNumberOfBrowserStates(); counts->total = number_of_browser_states; // Ignore other metrics if we have no browser states. if (!number_of_browser_states) return false; for (size_t i = 0; i < number_of_browser_states; ++i) { if (info_cache->BrowserStateIsAuthenticatedAtIndex(i)) { counts->signedin++; if (info_cache->BrowserStateIsAuthErrorAtIndex(i)) counts->auth_errors++; } } return true; } void LogNumberOfBrowserStates(ios::ChromeBrowserStateManager* manager) { profile_metrics::Counts counts; CountBrowserStateInformation(manager, &counts); profile_metrics::LogProfileMetricsCounts(counts); }