OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "components/signin/core/browser/signin_status_metrics_provider.h" | 5 #include "components/signin/core/browser/signin_status_metrics_provider.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/memory/ptr_util.h" |
11 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
13 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
14 #include "components/signin/core/browser/signin_manager.h" | 15 #include "components/signin/core/browser/signin_manager.h" |
15 | 16 |
16 SigninStatusMetricsProvider::SigninStatusMetricsProvider( | 17 SigninStatusMetricsProvider::SigninStatusMetricsProvider( |
17 std::unique_ptr<SigninStatusMetricsProviderDelegate> delegate, | 18 std::unique_ptr<SigninStatusMetricsProviderDelegate> delegate, |
18 bool is_test) | 19 bool is_test) |
19 : delegate_(std::move(delegate)), | 20 : delegate_(std::move(delegate)), |
20 scoped_observer_(this), | 21 scoped_observer_(this), |
(...skipping 17 matching lines...) Expand all Loading... |
38 metrics::ChromeUserMetricsExtension* uma_proto) { | 39 metrics::ChromeUserMetricsExtension* uma_proto) { |
39 RecordSigninStatusHistogram(signin_status()); | 40 RecordSigninStatusHistogram(signin_status()); |
40 // After a histogram value is recorded, a new UMA session will be started, so | 41 // After a histogram value is recorded, a new UMA session will be started, so |
41 // we need to re-check the current sign-in status regardless of the previous | 42 // we need to re-check the current sign-in status regardless of the previous |
42 // recorded |signin_status_| value. | 43 // recorded |signin_status_| value. |
43 ResetSigninStatus(); | 44 ResetSigninStatus(); |
44 ComputeCurrentSigninStatus(); | 45 ComputeCurrentSigninStatus(); |
45 } | 46 } |
46 | 47 |
47 // static | 48 // static |
48 SigninStatusMetricsProvider* SigninStatusMetricsProvider::CreateInstance( | 49 std::unique_ptr<SigninStatusMetricsProvider> |
| 50 SigninStatusMetricsProvider::CreateInstance( |
49 std::unique_ptr<SigninStatusMetricsProviderDelegate> delegate) { | 51 std::unique_ptr<SigninStatusMetricsProviderDelegate> delegate) { |
50 return new SigninStatusMetricsProvider(std::move(delegate), false); | 52 return base::WrapUnique( |
| 53 new SigninStatusMetricsProvider(std::move(delegate), false)); |
51 } | 54 } |
52 | 55 |
53 void SigninStatusMetricsProvider::OnSigninManagerCreated( | 56 void SigninStatusMetricsProvider::OnSigninManagerCreated( |
54 SigninManagerBase* manager) { | 57 SigninManagerBase* manager) { |
55 // Whenever a new profile is created, a new SigninManagerBase will be created | 58 // Whenever a new profile is created, a new SigninManagerBase will be created |
56 // for it. This ensures that all sign-in or sign-out actions of all opened | 59 // for it. This ensures that all sign-in or sign-out actions of all opened |
57 // profiles are being monitored. | 60 // profiles are being monitored. |
58 scoped_observer_.Add(manager); | 61 scoped_observer_.Add(manager); |
59 | 62 |
60 // If the status is unknown, it means this is the first created | 63 // If the status is unknown, it means this is the first created |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 void SigninStatusMetricsProvider::UpdateInitialSigninStatusForTesting( | 150 void SigninStatusMetricsProvider::UpdateInitialSigninStatusForTesting( |
148 size_t total_count, | 151 size_t total_count, |
149 size_t signed_in_profiles_count) { | 152 size_t signed_in_profiles_count) { |
150 UpdateInitialSigninStatus(total_count, signed_in_profiles_count); | 153 UpdateInitialSigninStatus(total_count, signed_in_profiles_count); |
151 } | 154 } |
152 | 155 |
153 SigninStatusMetricsProvider::SigninStatus | 156 SigninStatusMetricsProvider::SigninStatus |
154 SigninStatusMetricsProvider::GetSigninStatusForTesting() { | 157 SigninStatusMetricsProvider::GetSigninStatusForTesting() { |
155 return signin_status(); | 158 return signin_status(); |
156 } | 159 } |
OLD | NEW |