#include "components/metrics/content/content_stability_metrics_provider.h"
#include "base/check.h"
#include "base/notreached.h"
#include "build/build_config.h"
#include "components/metrics/content/extensions_helper.h"
#include "content/public/browser/browser_child_process_observer.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/child_process_termination_info.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/page_visibility_state.h"
#include "content/public/common/process_type.h"
#include "ppapi/buildflags/buildflags.h"
#if BUILDFLAG(IS_ANDROID)
#include "components/crash/content/browser/crash_metrics_reporter_android.h"
#endif
namespace metrics {
namespace {
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
RendererHostedContentType DetermineHostedContentType(
content::RenderProcessHost* host,
ExtensionsHelper* extensions_helper) { … }
#endif
}
ContentStabilityMetricsProvider::ContentStabilityMetricsProvider(
PrefService* local_state,
std::unique_ptr<ExtensionsHelper> extensions_helper)
: … { … }
ContentStabilityMetricsProvider::~ContentStabilityMetricsProvider() { … }
void ContentStabilityMetricsProvider::OnRecordingEnabled() { … }
void ContentStabilityMetricsProvider::OnRecordingDisabled() { … }
#if BUILDFLAG(IS_ANDROID)
void ContentStabilityMetricsProvider::ProvideStabilityMetrics(
SystemProfileProto* system_profile_proto) {
helper_.ProvideStabilityMetrics(system_profile_proto);
}
void ContentStabilityMetricsProvider::ClearSavedStabilityMetrics() {
helper_.ClearSavedStabilityMetrics();
}
#endif
void ContentStabilityMetricsProvider::OnRenderProcessHostCreated(
content::RenderProcessHost* host) { … }
void ContentStabilityMetricsProvider::OnRenderProcessHostCreationFailed(
content::RenderProcessHost* host,
const content::ChildProcessTerminationInfo& info) { … }
void ContentStabilityMetricsProvider::RenderProcessExited(
content::RenderProcessHost* host,
const content::ChildProcessTerminationInfo& info) { … }
void ContentStabilityMetricsProvider::RenderProcessHostDestroyed(
content::RenderProcessHost* host) { … }
void ContentStabilityMetricsProvider::BrowserChildProcessCrashed(
const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) { … }
void ContentStabilityMetricsProvider::BrowserChildProcessLaunchedAndConnected(
const content::ChildProcessData& data) { … }
void ContentStabilityMetricsProvider::BrowserChildProcessLaunchFailed(
const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) { … }
#if BUILDFLAG(IS_ANDROID)
void ContentStabilityMetricsProvider::OnCrashDumpProcessed(
int rph_id,
const crash_reporter::CrashMetricsReporter::ReportedCrashTypeSet&
reported_counts) {
if (reported_counts.count(crash_reporter::CrashMetricsReporter::
ProcessedCrashCounts::kRendererCrashAll)) {
helper_.IncreaseRendererCrashCount();
}
if (reported_counts.count(crash_reporter::CrashMetricsReporter::
ProcessedCrashCounts::kGpuCrashAll)) {
helper_.IncreaseGpuCrashCount();
}
}
#endif
void ContentStabilityMetricsProvider::OnPageLoadStarted() { … }
}