| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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. | |
| 4 | |
| 5 #include "blimp/engine/app/blimp_stability_metrics_provider.h" | |
| 6 | |
| 7 #include <vector> | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 #include "base/metrics/histogram.h" | |
| 11 #include "base/metrics/sparse_histogram.h" | |
| 12 #include "build/build_config.h" | |
| 13 #include "content/public/browser/child_process_data.h" | |
| 14 #include "content/public/browser/notification_service.h" | |
| 15 #include "content/public/browser/notification_types.h" | |
| 16 #include "content/public/browser/render_process_host.h" | |
| 17 | |
| 18 BlimpStabilityMetricsProvider::BlimpStabilityMetricsProvider( | |
| 19 PrefService* local_state) | |
| 20 : helper_(local_state) { | |
| 21 BrowserChildProcessObserver::Add(this); | |
| 22 } | |
| 23 | |
| 24 BlimpStabilityMetricsProvider::~BlimpStabilityMetricsProvider() { | |
| 25 BrowserChildProcessObserver::Remove(this); | |
| 26 } | |
| 27 | |
| 28 void BlimpStabilityMetricsProvider::OnRecordingEnabled() { | |
| 29 registrar_.Add(this, | |
| 30 content::NOTIFICATION_LOAD_START, | |
| 31 content::NotificationService::AllSources()); | |
| 32 registrar_.Add(this, | |
| 33 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | |
| 34 content::NotificationService::AllSources()); | |
| 35 registrar_.Add(this, | |
| 36 content::NOTIFICATION_RENDER_WIDGET_HOST_HANG, | |
| 37 content::NotificationService::AllSources()); | |
| 38 } | |
| 39 | |
| 40 void BlimpStabilityMetricsProvider::OnRecordingDisabled() { | |
| 41 registrar_.RemoveAll(); | |
| 42 } | |
| 43 | |
| 44 void BlimpStabilityMetricsProvider::ProvideStabilityMetrics( | |
| 45 metrics::SystemProfileProto* system_profile_proto) { | |
| 46 helper_.ProvideStabilityMetrics(system_profile_proto); | |
| 47 } | |
| 48 | |
| 49 void BlimpStabilityMetricsProvider::ClearSavedStabilityMetrics() { | |
| 50 helper_.ClearSavedStabilityMetrics(); | |
| 51 } | |
| 52 | |
| 53 void BlimpStabilityMetricsProvider::Observe( | |
| 54 int type, | |
| 55 const content::NotificationSource& source, | |
| 56 const content::NotificationDetails& details) { | |
| 57 switch (type) { | |
| 58 case content::NOTIFICATION_LOAD_START: { | |
| 59 helper_.LogLoadStarted(); | |
| 60 break; | |
| 61 } | |
| 62 | |
| 63 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { | |
| 64 content::RenderProcessHost::RendererClosedDetails* process_details = | |
| 65 content::Details<content::RenderProcessHost::RendererClosedDetails>( | |
| 66 details).ptr(); | |
| 67 bool was_extension_process = false; | |
| 68 helper_.LogRendererCrash(was_extension_process, process_details->status, | |
| 69 process_details->exit_code); | |
| 70 break; | |
| 71 } | |
| 72 | |
| 73 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: | |
| 74 helper_.LogRendererHang(); | |
| 75 break; | |
| 76 | |
| 77 default: | |
| 78 NOTREACHED(); | |
| 79 break; | |
| 80 } | |
| 81 } | |
| 82 | |
| 83 void BlimpStabilityMetricsProvider::BrowserChildProcessCrashed( | |
| 84 const content::ChildProcessData& data, | |
| 85 int exit_code) { | |
| 86 helper_.BrowserChildProcessCrashed(); | |
| 87 } | |
| OLD | NEW |