OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/chrome/browser/browser_state_metrics/browser_state_metrics.h" | 5 #include "ios/chrome/browser/browser_state_metrics/browser_state_metrics.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "components/profile_metrics/counts.h" | 9 #include "components/profile_metrics/counts.h" |
10 #include "ios/chrome/browser/browser_state/browser_state_info_cache.h" | 10 #include "ios/chrome/browser/browser_state/browser_state_info_cache.h" |
11 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state_
manager.h" | 11 #include "ios/chrome/browser/browser_state/chrome_browser_state_manager.h" |
12 | 12 |
13 bool CountBrowserStateInformation(ios::ChromeBrowserStateManager* manager, | 13 bool CountBrowserStateInformation(ios::ChromeBrowserStateManager* manager, |
14 profile_metrics::Counts* counts) { | 14 profile_metrics::Counts* counts) { |
15 BrowserStateInfoCache* info_cache = manager->GetBrowserStateInfoCache(); | 15 BrowserStateInfoCache* info_cache = manager->GetBrowserStateInfoCache(); |
16 size_t number_of_browser_states = info_cache->GetNumberOfBrowserStates(); | 16 size_t number_of_browser_states = info_cache->GetNumberOfBrowserStates(); |
17 counts->total = number_of_browser_states; | 17 counts->total = number_of_browser_states; |
18 | 18 |
19 // Ignore other metrics if we have no browser states. | 19 // Ignore other metrics if we have no browser states. |
20 if (!number_of_browser_states) | 20 if (!number_of_browser_states) |
21 return false; | 21 return false; |
22 | 22 |
23 for (size_t i = 0; i < number_of_browser_states; ++i) { | 23 for (size_t i = 0; i < number_of_browser_states; ++i) { |
24 if (info_cache->BrowserStateIsAuthenticatedAtIndex(i)) { | 24 if (info_cache->BrowserStateIsAuthenticatedAtIndex(i)) { |
25 counts->signedin++; | 25 counts->signedin++; |
26 if (info_cache->BrowserStateIsAuthErrorAtIndex(i)) | 26 if (info_cache->BrowserStateIsAuthErrorAtIndex(i)) |
27 counts->auth_errors++; | 27 counts->auth_errors++; |
28 } | 28 } |
29 } | 29 } |
30 return true; | 30 return true; |
31 } | 31 } |
32 | 32 |
33 void LogNumberOfBrowserStates(ios::ChromeBrowserStateManager* manager) { | 33 void LogNumberOfBrowserStates(ios::ChromeBrowserStateManager* manager) { |
34 profile_metrics::Counts counts; | 34 profile_metrics::Counts counts; |
35 CountBrowserStateInformation(manager, &counts); | 35 CountBrowserStateInformation(manager, &counts); |
36 profile_metrics::LogProfileMetricsCounts(counts); | 36 profile_metrics::LogProfileMetricsCounts(counts); |
37 } | 37 } |
OLD | NEW |