Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #include "chrome/browser/android/hung_renderer_infobar_delegate.h" | |
| 6 | |
| 7 #include "base/callback.h" | |
| 8 #include "base/metrics/histogram.h" | |
| 9 #include "base/metrics/user_metrics.h" | |
| 10 #include "chrome/grit/generated_resources.h" | |
| 11 #include "components/infobars/core/infobar.h" | |
| 12 #include "content/public/browser/render_process_host.h" | |
| 13 #include "content/public/browser/web_contents.h" | |
| 14 #include "content/public/common/result_codes.h" | |
| 15 #include "grit/theme_resources.h" | |
| 16 #include "ui/base/l10n/l10n_util.h" | |
| 17 | |
| 18 HungRendererInfoBarDelegate::HungRendererInfoBarDelegate( | |
| 19 content::WebContents* web_contents) | |
| 20 : web_contents_(web_contents), action_logged_for_uma_(false) { | |
| 21 DCHECK(web_contents); | |
| 22 } | |
| 23 | |
| 24 HungRendererInfoBarDelegate::~HungRendererInfoBarDelegate() { | |
| 25 LogAction(REMOVE); | |
| 26 } | |
| 27 | |
| 28 void HungRendererInfoBarDelegate::InfoBarDismissed() { | |
| 29 LogAction(DISMISS); | |
| 30 } | |
| 31 | |
| 32 HungRendererInfoBarDelegate* | |
| 33 HungRendererInfoBarDelegate::AsHungRendererInfoBarDelegate() { | |
| 34 return this; | |
| 35 } | |
| 36 | |
| 37 int HungRendererInfoBarDelegate::GetIconID() const { | |
| 38 return IDR_INFOBAR_FROZEN_TAB; | |
| 39 } | |
| 40 | |
| 41 base::string16 HungRendererInfoBarDelegate::GetMessageText() const { | |
| 42 return l10n_util::GetPluralStringFUTF16(IDS_BROWSER_HANGMONITOR_RENDERER, 1); | |
| 43 } | |
| 44 | |
| 45 base::string16 HungRendererInfoBarDelegate::GetButtonLabel( | |
| 46 InfoBarButton button) const { | |
| 47 return l10n_util::GetStringUTF16((button == BUTTON_OK) | |
| 48 ? IDS_BROWSER_HANGMONITOR_RENDERER_END | |
| 49 : IDS_BROWSER_HANGMONITOR_RENDERER_WAIT); | |
| 50 } | |
| 51 | |
| 52 bool HungRendererInfoBarDelegate::Accept() { | |
| 53 LogAction(KILL); | |
| 54 content::RenderProcessHost* process = web_contents_->GetRenderProcessHost(); | |
| 55 process->Shutdown(content::RESULT_CODE_HUNG, false); | |
| 56 return true; | |
| 57 } | |
| 58 | |
| 59 bool HungRendererInfoBarDelegate::Cancel() { | |
| 60 LogAction(WAIT); | |
| 61 return true; | |
| 62 } | |
| 63 | |
| 64 void HungRendererInfoBarDelegate::OnRendererResponsive() { | |
| 65 LogAction(RESPONSIVE); | |
| 66 } | |
| 67 | |
| 68 void HungRendererInfoBarDelegate::LogAction(Action action) { | |
| 69 if (action_logged_for_uma_) | |
| 70 return; | |
| 71 | |
| 72 action_logged_for_uma_ = true; | |
| 73 | |
| 74 UMA_HISTOGRAM_ENUMERATION("HungRenderer.MobileInfoBar.Action", action, | |
| 75 ACTION_COUNT); | |
| 76 | |
| 77 if (action == KILL) { | |
| 78 base::RecordAction( | |
| 79 base::UserMetricsAction("MobileHungRendererInfoBarKill")); | |
|
gone
2015/09/01 18:49:34
Any reason you're doubling up on the count and his
jdduke (slow)
2015/09/01 21:49:20
Yeah, I thought it might be nice to have this incl
| |
| 80 } | |
| 81 } | |
| OLD | NEW |