forked from kiwibrowser/src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcast_stability_metrics_provider.h
84 lines (65 loc) · 2.83 KB
/
cast_stability_metrics_provider.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright 2014 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.
#ifndef CHROMECAST_BROWSER_METRICS_CAST_STABILITY_METRICS_PROVIDER_H_
#define CHROMECAST_BROWSER_METRICS_CAST_STABILITY_METRICS_PROVIDER_H_
#include "base/macros.h"
#include "base/process/kill.h"
#include "components/metrics/metrics_provider.h"
#include "content/public/browser/browser_child_process_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
class PrefRegistrySimple;
namespace content {
class RenderProcessHost;
}
namespace metrics {
class MetricsService;
}
namespace chromecast {
namespace metrics {
// CastStabilityMetricsProvider gathers and logs stability-related metrics.
// Loosely based on ChromeStabilityMetricsProvider from chrome/browser/metrics.
class CastStabilityMetricsProvider
: public ::metrics::MetricsProvider,
public content::BrowserChildProcessObserver,
public content::NotificationObserver {
public:
// Registers local state prefs used by this class.
static void RegisterPrefs(PrefRegistrySimple* registry);
explicit CastStabilityMetricsProvider(
::metrics::MetricsService* metrics_service);
~CastStabilityMetricsProvider() override;
// metrics::MetricsDataProvider implementation:
void OnRecordingEnabled() override;
void OnRecordingDisabled() override;
void ProvideStabilityMetrics(
::metrics::SystemProfileProto* system_profile_proto) override;
// Logs an external crash, presumably from the ExternalMetrics service.
void LogExternalCrash(const std::string& crash_type);
private:
// content::NotificationObserver implementation:
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
// content::BrowserChildProcessObserver implementation:
void BrowserChildProcessCrashed(
const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) override;
// Records a renderer process crash.
void LogRendererCrash(content::RenderProcessHost* host,
base::TerminationStatus status,
int exit_code);
// Records a renderer process hang.
void LogRendererHang();
// Registrar for receiving stability-related notifications.
content::NotificationRegistrar registrar_;
// Reference to the current MetricsService. Raw pointer is safe, since
// MetricsService is responsible for the lifetime of
// CastStabilityMetricsProvider.
::metrics::MetricsService* metrics_service_;
DISALLOW_COPY_AND_ASSIGN(CastStabilityMetricsProvider);
};
} // namespace metrics
} // namespace chromecast
#endif // CHROMECAST_BROWSER_METRICS_CAST_STABILITY_METRICS_PROVIDER_H_