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

Side by Side Diff: chrome/browser/android/tab_android.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 unified diff | Download patch
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/android/tab_android.h" 5 #include "chrome/browser/android/tab_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "cc/layers/layer.h" 12 #include "cc/layers/layer.h"
13 #include "chrome/browser/android/chrome_web_contents_delegate_android.h" 13 #include "chrome/browser/android/chrome_web_contents_delegate_android.h"
14 #include "chrome/browser/android/compositor/tab_content_manager.h" 14 #include "chrome/browser/android/compositor/tab_content_manager.h"
15 #include "chrome/browser/android/hung_renderer_infobar_delegate.h"
15 #include "chrome/browser/android/metrics/uma_utils.h" 16 #include "chrome/browser/android/metrics/uma_utils.h"
16 #include "chrome/browser/android/offline_pages/offline_page_bridge.h" 17 #include "chrome/browser/android/offline_pages/offline_page_bridge.h"
17 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 18 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
19 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" 20 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
20 #include "chrome/browser/browser_about_handler.h" 21 #include "chrome/browser/browser_about_handler.h"
21 #include "chrome/browser/chrome_notification_types.h" 22 #include "chrome/browser/chrome_notification_types.h"
22 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 23 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
23 #include "chrome/browser/infobars/infobar_service.h" 24 #include "chrome/browser/infobars/infobar_service.h"
24 #include "chrome/browser/prerender/prerender_contents.h" 25 #include "chrome/browser/prerender/prerender_contents.h"
(...skipping 23 matching lines...) Expand all
48 #include "chrome/browser/ui/tab_helpers.h" 49 #include "chrome/browser/ui/tab_helpers.h"
49 #include "chrome/common/instant_types.h" 50 #include "chrome/common/instant_types.h"
50 #include "chrome/common/render_messages.h" 51 #include "chrome/common/render_messages.h"
51 #include "chrome/common/url_constants.h" 52 #include "chrome/common/url_constants.h"
52 #include "components/bookmarks/browser/bookmark_model.h" 53 #include "components/bookmarks/browser/bookmark_model.h"
53 #include "components/bookmarks/browser/bookmark_node.h" 54 #include "components/bookmarks/browser/bookmark_node.h"
54 #include "components/bookmarks/browser/bookmark_utils.h" 55 #include "components/bookmarks/browser/bookmark_utils.h"
55 #include "components/bookmarks/managed/managed_bookmark_service.h" 56 #include "components/bookmarks/managed/managed_bookmark_service.h"
56 #include "components/dom_distiller/core/url_utils.h" 57 #include "components/dom_distiller/core/url_utils.h"
57 #include "components/favicon/content/content_favicon_driver.h" 58 #include "components/favicon/content/content_favicon_driver.h"
59 #include "components/infobars/core/infobar.h"
58 #include "components/infobars/core/infobar_container.h" 60 #include "components/infobars/core/infobar_container.h"
59 #include "components/navigation_interception/intercept_navigation_delegate.h" 61 #include "components/navigation_interception/intercept_navigation_delegate.h"
60 #include "components/navigation_interception/navigation_params.h" 62 #include "components/navigation_interception/navigation_params.h"
61 #include "components/offline_pages/offline_page_feature.h" 63 #include "components/offline_pages/offline_page_feature.h"
62 #include "components/offline_pages/offline_page_item.h" 64 #include "components/offline_pages/offline_page_item.h"
63 #include "components/offline_pages/offline_page_model.h" 65 #include "components/offline_pages/offline_page_model.h"
64 #include "components/url_formatter/url_fixer.h" 66 #include "components/url_formatter/url_fixer.h"
65 #include "content/public/browser/android/compositor.h" 67 #include "content/public/browser/android/compositor.h"
66 #include "content/public/browser/android/content_view_core.h" 68 #include "content/public/browser/android/content_view_core.h"
67 #include "content/public/browser/browser_thread.h" 69 #include "content/public/browser/browser_thread.h"
(...skipping 26 matching lines...) Expand all
94 using content::WebContents; 96 using content::WebContents;
95 using navigation_interception::InterceptNavigationDelegate; 97 using navigation_interception::InterceptNavigationDelegate;
96 using navigation_interception::NavigationParams; 98 using navigation_interception::NavigationParams;
97 99
98 namespace { 100 namespace {
99 101
100 const int kImageSearchThumbnailMinSize = 300 * 300; 102 const int kImageSearchThumbnailMinSize = 300 * 300;
101 const int kImageSearchThumbnailMaxWidth = 600; 103 const int kImageSearchThumbnailMaxWidth = 600;
102 const int kImageSearchThumbnailMaxHeight = 600; 104 const int kImageSearchThumbnailMaxHeight = 600;
103 105
106 infobars::InfoBar* FindHungRendererInfoBar(InfoBarService* infobar_service) {
107 DCHECK(infobar_service);
108 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
109 infobars::InfoBar* infobar = infobar_service->infobar_at(i);
110 if (infobar->delegate()->AsHungRendererInfoBarDelegate())
111 return infobar;
112 }
113 return nullptr;
114 }
115
104 } // namespace 116 } // namespace
105 117
106 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { 118 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) {
107 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); 119 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents);
108 if (!core_tab_helper) 120 if (!core_tab_helper)
109 return NULL; 121 return NULL;
110 122
111 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); 123 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate();
112 if (!core_delegate) 124 if (!core_delegate)
113 return NULL; 125 return NULL;
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 offline_pages::OfflinePageModelFactory::GetForBrowserContext( 847 offline_pages::OfflinePageModelFactory::GetForBrowserContext(
836 GetProfile()); 848 GetProfile());
837 return offline_page_model->GetPageByOfflineURL(url); 849 return offline_page_model->GetPageByOfflineURL(url);
838 } 850 }
839 851
840 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, jobject obj, jstring url) { 852 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, jobject obj, jstring url) {
841 GURL gurl(base::android::ConvertJavaStringToUTF8(env, url)); 853 GURL gurl(base::android::ConvertJavaStringToUTF8(env, url));
842 return HasPrerenderedUrl(gurl); 854 return HasPrerenderedUrl(gurl);
843 } 855 }
844 856
857 void TabAndroid::OnRendererUnresponsive(JNIEnv* env, jobject obj) {
858 InfoBarService* infobar_service =
859 InfoBarService::FromWebContents(web_contents());
860 DCHECK(!FindHungRendererInfoBar(infobar_service));
861 HungRendererInfoBarDelegate::Create(infobar_service,
862 web_contents()->GetRenderProcessHost());
863 }
864
865 void TabAndroid::OnRendererResponsive(JNIEnv* env, jobject obj) {
866 InfoBarService* infobar_service =
867 InfoBarService::FromWebContents(web_contents());
868 infobars::InfoBar* hung_renderer_infobar =
869 FindHungRendererInfoBar(infobar_service);
870 if (!hung_renderer_infobar)
871 return;
872
873 hung_renderer_infobar->delegate()
874 ->AsHungRendererInfoBarDelegate()
875 ->OnRendererResponsive();
876 infobar_service->RemoveInfoBar(hung_renderer_infobar);
877 }
878
845 namespace { 879 namespace {
846 880
847 class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate { 881 class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate {
848 public: 882 public:
849 ChromeInterceptNavigationDelegate(JNIEnv* env, jobject jdelegate) 883 ChromeInterceptNavigationDelegate(JNIEnv* env, jobject jdelegate)
850 : InterceptNavigationDelegate(env, jdelegate) {} 884 : InterceptNavigationDelegate(env, jdelegate) {}
851 885
852 bool ShouldIgnoreNavigation( 886 bool ShouldIgnoreNavigation(
853 const NavigationParams& navigation_params) override { 887 const NavigationParams& navigation_params) override {
854 NavigationParams chrome_navigation_params(navigation_params); 888 NavigationParams chrome_navigation_params(navigation_params);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 // s^{n+1} / s^{n} = 2100 / 2000 962 // s^{n+1} / s^{n} = 2100 / 2000
929 // s = 1.05 963 // s = 1.05
930 // s^b = 60000 964 // s^b = 60000
931 // b = ln(60000) / ln(1.05) ~= 225 965 // b = ln(60000) / ln(1.05) ~= 225
932 UMA_HISTOGRAM_CUSTOM_TIMES("Startup.FirstCommitNavigationTime", 966 UMA_HISTOGRAM_CUSTOM_TIMES("Startup.FirstCommitNavigationTime",
933 base::Time::Now() - chrome::android::GetMainEntryPointTime(), 967 base::Time::Now() - chrome::android::GetMainEntryPointTime(),
934 base::TimeDelta::FromMilliseconds(1), 968 base::TimeDelta::FromMilliseconds(1),
935 base::TimeDelta::FromMinutes(1), 969 base::TimeDelta::FromMinutes(1),
936 225); 970 225);
937 } 971 }
OLDNEW
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698