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 "chrome/grit/generated_resources.h" | |
| 10 #include "components/infobars/core/infobar.h" | |
| 11 #include "content/public/browser/render_process_host.h" | |
| 12 #include "content/public/browser/web_contents.h" | |
| 13 #include "content/public/common/result_codes.h" | |
| 14 #include "grit/theme_resources.h" | |
| 15 #include "ui/base/l10n/l10n_util.h" | |
| 16 | |
| 17 HungRendererInfoBarDelegate::HungRendererInfoBarDelegate( | |
| 18 content::WebContents* web_contents) | |
| 19 : web_contents_(web_contents), action_logged_for_uma_(false) { | |
| 20 DCHECK(web_contents); | |
| 21 } | |
| 22 | |
| 23 HungRendererInfoBarDelegate::~HungRendererInfoBarDelegate() { | |
| 24 LogAction(REMOVE); | |
|
Peter Kasting
2015/09/01 22:24:05
This is just browser shutdown, right? Is logging
jdduke (slow)
2015/09/02 00:04:01
You tell me =/. Is there anything else that could
Peter Kasting
2015/09/02 21:52:45
I wasn't thinking clearly. This is tab closure, n
| |
| 25 } | |
| 26 | |
| 27 void HungRendererInfoBarDelegate::InfoBarDismissed() { | |
| 28 LogAction(DISMISS); | |
| 29 } | |
| 30 | |
| 31 HungRendererInfoBarDelegate* | |
| 32 HungRendererInfoBarDelegate::AsHungRendererInfoBarDelegate() { | |
| 33 return this; | |
| 34 } | |
| 35 | |
| 36 int HungRendererInfoBarDelegate::GetIconID() const { | |
| 37 return IDR_INFOBAR_FROZEN_TAB; | |
| 38 } | |
| 39 | |
| 40 base::string16 HungRendererInfoBarDelegate::GetMessageText() const { | |
| 41 return l10n_util::GetPluralStringFUTF16(IDS_BROWSER_HANGMONITOR_RENDERER, 1); | |
| 42 } | |
| 43 | |
| 44 base::string16 HungRendererInfoBarDelegate::GetButtonLabel( | |
| 45 InfoBarButton button) const { | |
| 46 return l10n_util::GetStringUTF16((button == BUTTON_OK) | |
| 47 ? IDS_BROWSER_HANGMONITOR_RENDERER_END | |
| 48 : IDS_BROWSER_HANGMONITOR_RENDERER_WAIT); | |
| 49 } | |
| 50 | |
| 51 bool HungRendererInfoBarDelegate::Accept() { | |
| 52 LogAction(KILL); | |
| 53 content::RenderProcessHost* process = web_contents_->GetRenderProcessHost(); | |
| 54 process->Shutdown(content::RESULT_CODE_HUNG, false); | |
| 55 return true; | |
| 56 } | |
| 57 | |
| 58 bool HungRendererInfoBarDelegate::Cancel() { | |
| 59 LogAction(WAIT); | |
| 60 return true; | |
| 61 } | |
| 62 | |
| 63 void HungRendererInfoBarDelegate::OnRendererResponsive() { | |
| 64 LogAction(RESPONSIVE); | |
| 65 } | |
| 66 | |
| 67 void HungRendererInfoBarDelegate::LogAction(Action action) { | |
| 68 if (action_logged_for_uma_) | |
|
Peter Kasting
2015/09/01 22:24:05
The only reason we should get multiple actions log
jdduke (slow)
2015/09/02 00:04:01
Done.
| |
| 69 return; | |
| 70 | |
| 71 action_logged_for_uma_ = true; | |
| 72 UMA_HISTOGRAM_ENUMERATION("HungRenderer.MobileInfoBar.Action", action, | |
| 73 ACTION_COUNT); | |
| 74 } | |
| OLD | NEW |