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

Side by Side Diff: ios/chrome/browser/browser_state_metrics/browser_state_metrics.cc

Issue 1664193002: Upstream ChromeBrowserStateManagerImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@upstream-chrome-browser-state-impl
Patch Set: Address comments Created 4 years, 10 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 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 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h ('k') | ios/chrome/browser/ios_chrome_main_parts.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698