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
3 // found in the LICENSE file.
5 #ifndef IOS_CHROME_BROWSER_METRICS_IOS_STABILITY_METRICS_PROVIDER_H_
6 #define IOS_CHROME_BROWSER_METRICS_IOS_STABILITY_METRICS_PROVIDER_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "components/metrics/metrics_provider.h"
16 // Exposed for testing purposes only.
17 // Values of the UMA Stability.MobileSessionShutdownType histogram.
18 enum MobileSessionShutdownType
{
19 SHUTDOWN_IN_BACKGROUND
= 0,
20 SHUTDOWN_IN_FOREGROUND_NO_CRASH_LOG_NO_MEMORY_WARNING
,
21 SHUTDOWN_IN_FOREGROUND_WITH_CRASH_LOG_NO_MEMORY_WARNING
,
22 SHUTDOWN_IN_FOREGROUND_NO_CRASH_LOG_WITH_MEMORY_WARNING
,
23 SHUTDOWN_IN_FOREGROUND_WITH_CRASH_LOG_WITH_MEMORY_WARNING
,
24 FIRST_LAUNCH_AFTER_UPGRADE
,
25 MOBILE_SESSION_SHUTDOWN_TYPE_COUNT
,
28 class IOSStabilityMetricsProvider
: public metrics::MetricsProvider
{
30 explicit IOSStabilityMetricsProvider(
31 metrics::MetricsService
* metrics_service
);
32 ~IOSStabilityMetricsProvider() override
;
34 // metrics::MetricsProvider
35 bool HasInitialStabilityMetrics() override
;
36 void ProvideInitialStabilityMetrics(
37 metrics::SystemProfileProto
* system_profile_proto
) override
;
40 // Provides information on the last session environment, used to decide what
41 // stability metrics to provide in ProvideInitialStabilityMetrics.
42 // These methods are virtual to be overridden in the tests.
43 // The default implementations return the real values.
45 // Whether this is the first time the app is launched after an upgrade.
46 virtual bool IsFirstLaunchAfterUpgrade();
48 // Whether there are crash reports to upload.
49 virtual bool HasCrashLogs();
51 // Whether there were crash reports that have been uploaded in background
52 // since the last full start.
53 virtual bool HasUploadedCrashReportsInBackground();
55 // Whether there was a memory warning shortly before last shutdown.
56 virtual bool ReceivedMemoryWarningBeforeLastShutdown();
59 metrics::MetricsService
* metrics_service_
;
60 DISALLOW_COPY_AND_ASSIGN(IOSStabilityMetricsProvider
);
63 #endif // IOS_CHROME_BROWSER_METRICS_IOS_STABILITY_METRICS_PROVIDER_H_