Chromium Code Reviews| 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 "chromecast/browser/metrics/cast_stability_metrics_provider.h" | 5 #include "chromecast/browser/metrics/cast_stability_metrics_provider.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/metrics/sparse_histogram.h" | 11 #include "base/metrics/sparse_histogram.h" |
| 12 #include "base/prefs/pref_registry_simple.h" | 12 #include "base/prefs/pref_registry_simple.h" |
| 13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "chromecast/browser/metrics/cast_metrics_service_client.h" | 14 #include "chromecast/browser/metrics/cast_metrics_service_client.h" |
| 15 #include "chromecast/common/chromecast_config.h" | 15 #include "chromecast/common/chromecast_config.h" |
| 16 #include "chromecast/common/pref_names.h" | 16 #include "chromecast/common/pref_names.h" |
| 17 #include "components/metrics/metrics_service.h" | |
| 17 #include "components/metrics/proto/system_profile.pb.h" | 18 #include "components/metrics/proto/system_profile.pb.h" |
| 18 #include "content/public/browser/child_process_data.h" | 19 #include "content/public/browser/child_process_data.h" |
| 19 #include "content/public/browser/navigation_controller.h" | 20 #include "content/public/browser/navigation_controller.h" |
| 20 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| 21 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
| 22 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
| 23 #include "content/public/browser/user_metrics.h" | 24 #include "content/public/browser/user_metrics.h" |
| 24 | 25 |
| 25 namespace chromecast { | 26 namespace chromecast { |
| 26 namespace metrics { | 27 namespace metrics { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 42 | 43 |
| 43 } // namespace | 44 } // namespace |
| 44 | 45 |
| 45 // static | 46 // static |
| 46 void CastStabilityMetricsProvider::RegisterPrefs(PrefRegistrySimple* registry) { | 47 void CastStabilityMetricsProvider::RegisterPrefs(PrefRegistrySimple* registry) { |
| 47 registry->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); | 48 registry->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); |
| 48 registry->RegisterIntegerPref(prefs::kStabilityRendererHangCount, 0); | 49 registry->RegisterIntegerPref(prefs::kStabilityRendererHangCount, 0); |
| 49 registry->RegisterIntegerPref(prefs::kStabilityChildProcessCrashCount, 0); | 50 registry->RegisterIntegerPref(prefs::kStabilityChildProcessCrashCount, 0); |
| 50 } | 51 } |
| 51 | 52 |
| 52 CastStabilityMetricsProvider::CastStabilityMetricsProvider() { | 53 CastStabilityMetricsProvider::CastStabilityMetricsProvider( |
| 54 ::metrics::MetricsService* metrics_service) | |
| 55 : metrics_service_(metrics_service) { | |
| 53 BrowserChildProcessObserver::Add(this); | 56 BrowserChildProcessObserver::Add(this); |
| 54 } | 57 } |
| 55 | 58 |
| 56 CastStabilityMetricsProvider::~CastStabilityMetricsProvider() { | 59 CastStabilityMetricsProvider::~CastStabilityMetricsProvider() { |
| 57 BrowserChildProcessObserver::Remove(this); | 60 BrowserChildProcessObserver::Remove(this); |
| 58 } | 61 } |
| 59 | 62 |
| 60 void CastStabilityMetricsProvider::OnRecordingEnabled() { | 63 void CastStabilityMetricsProvider::OnRecordingEnabled() { |
| 61 registrar_.Add(this, | 64 registrar_.Add(this, |
| 62 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 65 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 88 pref->SetInteger(prefs::kStabilityRendererCrashCount, 0); | 91 pref->SetInteger(prefs::kStabilityRendererCrashCount, 0); |
| 89 } | 92 } |
| 90 | 93 |
| 91 count = pref->GetInteger(prefs::kStabilityRendererHangCount); | 94 count = pref->GetInteger(prefs::kStabilityRendererHangCount); |
| 92 if (count) { | 95 if (count) { |
| 93 stability_proto->set_renderer_hang_count(count); | 96 stability_proto->set_renderer_hang_count(count); |
| 94 pref->SetInteger(prefs::kStabilityRendererHangCount, 0); | 97 pref->SetInteger(prefs::kStabilityRendererHangCount, 0); |
| 95 } | 98 } |
| 96 } | 99 } |
| 97 | 100 |
| 101 void CastStabilityMetricsProvider::LogExternalCrash( | |
| 102 const std::string& crash_type) { | |
| 103 if (crash_type == "user") | |
| 104 IncrementPrefValue(prefs::kStabilityOtherUserCrashCount); | |
|
Will Harris
2016/07/07 20:26:49
I don't think these prefs are being registered any
| |
| 105 else if (crash_type == "kernel") | |
| 106 IncrementPrefValue(prefs::kStabilityKernelCrashCount); | |
| 107 else if (crash_type == "uncleanshutdown") | |
| 108 IncrementPrefValue(prefs::kStabilitySystemUncleanShutdownCount); | |
| 109 else | |
| 110 NOTREACHED() << "Unexpected crash type " << crash_type; | |
| 111 | |
| 112 // Wake up metrics logs sending if necessary now that new | |
| 113 // log data is available. | |
| 114 metrics_service_->OnApplicationNotIdle(); | |
| 115 } | |
| 116 | |
| 98 void CastStabilityMetricsProvider::Observe( | 117 void CastStabilityMetricsProvider::Observe( |
| 99 int type, | 118 int type, |
| 100 const content::NotificationSource& source, | 119 const content::NotificationSource& source, |
| 101 const content::NotificationDetails& details) { | 120 const content::NotificationDetails& details) { |
| 102 switch (type) { | 121 switch (type) { |
| 103 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { | 122 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { |
| 104 content::RenderProcessHost::RendererClosedDetails* process_details = | 123 content::RenderProcessHost::RendererClosedDetails* process_details = |
| 105 content::Details<content::RenderProcessHost::RendererClosedDetails>( | 124 content::Details<content::RenderProcessHost::RendererClosedDetails>( |
| 106 details).ptr(); | 125 details).ptr(); |
| 107 content::RenderProcessHost* host = | 126 content::RenderProcessHost* host = |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.DisconnectedAlive", 1); | 162 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.DisconnectedAlive", 1); |
| 144 } | 163 } |
| 145 } | 164 } |
| 146 | 165 |
| 147 void CastStabilityMetricsProvider::LogRendererHang() { | 166 void CastStabilityMetricsProvider::LogRendererHang() { |
| 148 IncrementPrefValue(prefs::kStabilityRendererHangCount); | 167 IncrementPrefValue(prefs::kStabilityRendererHangCount); |
| 149 } | 168 } |
| 150 | 169 |
| 151 } // namespace metrics | 170 } // namespace metrics |
| 152 } // namespace chromecast | 171 } // namespace chromecast |
| OLD | NEW |