Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2606)

Unified Diff: chrome/browser/android/hung_renderer_infobar_delegate.cc

Issue 1299513002: [Android] Add support for a hung renderer dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/hung_renderer_infobar_delegate.h ('k') | chrome/browser/android/resource_id.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/hung_renderer_infobar_delegate.cc
diff --git a/chrome/browser/android/hung_renderer_infobar_delegate.cc b/chrome/browser/android/hung_renderer_infobar_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f469c675c6d8992518dc66f925302a0b178ea060
--- /dev/null
+++ b/chrome/browser/android/hung_renderer_infobar_delegate.cc
@@ -0,0 +1,81 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/hung_renderer_infobar_delegate.h"
+
+#include "base/callback.h"
+#include "base/metrics/histogram.h"
+#include "chrome/browser/infobars/infobar_service.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/infobars/core/infobar.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/common/result_codes.h"
+#include "grit/theme_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+
+// static
+void HungRendererInfoBarDelegate::Create(
+ InfoBarService* infobar_service,
+ content::RenderProcessHost* render_process_host) {
+ DCHECK(render_process_host);
+ infobar_service->AddInfoBar(
+ infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>(
+ new HungRendererInfoBarDelegate(render_process_host))));
+}
+
+void HungRendererInfoBarDelegate::OnRendererResponsive() {
+ LogEvent(RENDERER_BECAME_RESPONSIVE);
+}
+
+HungRendererInfoBarDelegate::HungRendererInfoBarDelegate(
+ content::RenderProcessHost* render_process_host)
+ : render_process_host_(render_process_host),
+ terminal_event_logged_for_uma_(false) {}
+
+HungRendererInfoBarDelegate::~HungRendererInfoBarDelegate() {
+ if (!terminal_event_logged_for_uma_)
+ LogEvent(TAB_CLOSED);
+}
+
+void HungRendererInfoBarDelegate::InfoBarDismissed() {
+ LogEvent(CLOSE_CLICKED);
+}
+
+HungRendererInfoBarDelegate*
+HungRendererInfoBarDelegate::AsHungRendererInfoBarDelegate() {
+ return this;
+}
+
+int HungRendererInfoBarDelegate::GetIconId() const {
+ return IDR_INFOBAR_FROZEN_TAB;
+}
+
+base::string16 HungRendererInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetPluralStringFUTF16(IDS_BROWSER_HANGMONITOR_RENDERER, 1);
+}
+
+base::string16 HungRendererInfoBarDelegate::GetButtonLabel(
+ InfoBarButton button) const {
+ return l10n_util::GetStringUTF16((button == BUTTON_OK)
+ ? IDS_BROWSER_HANGMONITOR_RENDERER_END
+ : IDS_BROWSER_HANGMONITOR_RENDERER_WAIT);
+}
+
+bool HungRendererInfoBarDelegate::Accept() {
+ LogEvent(KILL_CLICKED);
+ render_process_host_->Shutdown(content::RESULT_CODE_HUNG, false);
+ return true;
+}
+
+bool HungRendererInfoBarDelegate::Cancel() {
+ LogEvent(WAIT_CLICKED);
+ return true;
+}
+
+void HungRendererInfoBarDelegate::LogEvent(Event event) {
+ DCHECK(!terminal_event_logged_for_uma_);
+ terminal_event_logged_for_uma_ = true;
+ UMA_HISTOGRAM_ENUMERATION("Renderer.Hung.MobileInfoBar.UserEvent", event,
+ EVENT_COUNT);
+}
« no previous file with comments | « chrome/browser/android/hung_renderer_infobar_delegate.h ('k') | chrome/browser/android/resource_id.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698