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

Side by Side Diff: chrome/browser/tab_contents/tab_contents.cc

Issue 6006006: Show OOM notification bar in all tabs sharing same render process (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Send reply to the sync message on the IO thread Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tab_contents/tab_contents.h" 5 #include "chrome/browser/tab_contents/tab_contents.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 is_showing_before_unload_dialog_(false), 316 is_showing_before_unload_dialog_(false),
317 renderer_preferences_(), 317 renderer_preferences_(),
318 opener_web_ui_type_(WebUIFactory::kNoWebUI), 318 opener_web_ui_type_(WebUIFactory::kNoWebUI),
319 language_state_(&controller_), 319 language_state_(&controller_),
320 closed_by_user_gesture_(false), 320 closed_by_user_gesture_(false),
321 minimum_zoom_percent_( 321 minimum_zoom_percent_(
322 static_cast<int>(WebKit::WebView::minTextSizeMultiplier * 100)), 322 static_cast<int>(WebKit::WebView::minTextSizeMultiplier * 100)),
323 maximum_zoom_percent_( 323 maximum_zoom_percent_(
324 static_cast<int>(WebKit::WebView::maxTextSizeMultiplier * 100)), 324 static_cast<int>(WebKit::WebView::maxTextSizeMultiplier * 100)),
325 temporary_zoom_settings_(false), 325 temporary_zoom_settings_(false),
326 content_restrictions_(0) { 326 content_restrictions_(0),
327 render_process_ran_out_of_memory_(false) {
327 renderer_preferences_util::UpdateFromSystemSettings( 328 renderer_preferences_util::UpdateFromSystemSettings(
328 &renderer_preferences_, profile); 329 &renderer_preferences_, profile);
329 330
330 content_settings_delegate_.reset( 331 content_settings_delegate_.reset(
331 new TabSpecificContentSettings(this, profile)); 332 new TabSpecificContentSettings(this, profile));
332 333
333 render_manager_.Init(profile, site_instance, routing_id); 334 render_manager_.Init(profile, site_instance, routing_id);
334 335
335 // We have the initial size of the view be based on the size of the passed in 336 // We have the initial size of the view be based on the size of the passed in
336 // tab contents (normally a tab from the same window). 337 // tab contents (normally a tab from the same window).
(...skipping 2085 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 } 2423 }
2423 2424
2424 SetIsLoading(false, NULL); 2425 SetIsLoading(false, NULL);
2425 NotifyDisconnected(); 2426 NotifyDisconnected();
2426 SetIsCrashed(status, error_code); 2427 SetIsCrashed(status, error_code);
2427 2428
2428 // Remove all infobars. 2429 // Remove all infobars.
2429 for (int i = infobar_delegate_count() - 1; i >=0 ; --i) 2430 for (int i = infobar_delegate_count() - 1; i >=0 ; --i)
2430 RemoveInfoBar(GetInfoBarDelegateAt(i)); 2431 RemoveInfoBar(GetInfoBarDelegateAt(i));
2431 2432
2433 // Restore OOM infobar.
2434 if (render_process_ran_out_of_memory_)
2435 OnJSOutOfMemory();
2436
2432 // Tell the view that we've crashed so it can prepare the sad tab page. 2437 // Tell the view that we've crashed so it can prepare the sad tab page.
2433 // Only do this if we're not in browser shutdown, so that TabContents 2438 // Only do this if we're not in browser shutdown, so that TabContents
2434 // objects that are not in a browser (e.g., HTML dialogs) and thus are 2439 // objects that are not in a browser (e.g., HTML dialogs) and thus are
2435 // visible do not flash a sad tab page. 2440 // visible do not flash a sad tab page.
2436 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) 2441 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID)
2437 view_->OnTabCrashed(status, error_code); 2442 view_->OnTabCrashed(status, error_code);
2438 2443
2439 // Hide any visible hung renderer warning for this web contents' process. 2444 // Hide any visible hung renderer warning for this web contents' process.
2440 hung_renderer_dialog::HideForTabContents(this); 2445 hung_renderer_dialog::HideForTabContents(this);
2441 } 2446 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2930 } 2935 }
2931 2936
2932 void TabContents::OnIgnoredUIEvent() { 2937 void TabContents::OnIgnoredUIEvent() {
2933 if (constrained_window_count()) { 2938 if (constrained_window_count()) {
2934 ConstrainedWindow* window = *constrained_window_begin(); 2939 ConstrainedWindow* window = *constrained_window_begin();
2935 window->FocusConstrainedWindow(); 2940 window->FocusConstrainedWindow();
2936 } 2941 }
2937 } 2942 }
2938 2943
2939 void TabContents::OnJSOutOfMemory() { 2944 void TabContents::OnJSOutOfMemory() {
2945 render_process_ran_out_of_memory_ = true;
2940 AddInfoBar(new SimpleAlertInfoBarDelegate(this, NULL, 2946 AddInfoBar(new SimpleAlertInfoBarDelegate(this, NULL,
2941 l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), true)); 2947 l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), true));
2942 } 2948 }
2943 2949
2944 void TabContents::OnCrossSiteResponse(int new_render_process_host_id, 2950 void TabContents::OnCrossSiteResponse(int new_render_process_host_id,
2945 int new_request_id) { 2951 int new_request_id) {
2946 // Allows the TabContents to react when a cross-site response is ready to be 2952 // Allows the TabContents to react when a cross-site response is ready to be
2947 // delivered to a pending RenderViewHost. We must first run the onunload 2953 // delivered to a pending RenderViewHost. We must first run the onunload
2948 // handler of the old RenderViewHost before we can allow it to proceed. 2954 // handler of the old RenderViewHost before we can allow it to proceed.
2949 render_manager_.OnCrossSiteResponse(new_render_process_host_id, 2955 render_manager_.OnCrossSiteResponse(new_render_process_host_id,
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
3120 case NotificationType::RENDER_WIDGET_HOST_DESTROYED: 3126 case NotificationType::RENDER_WIDGET_HOST_DESTROYED:
3121 view_->RenderWidgetHostDestroyed(Source<RenderWidgetHost>(source).ptr()); 3127 view_->RenderWidgetHostDestroyed(Source<RenderWidgetHost>(source).ptr());
3122 break; 3128 break;
3123 3129
3124 case NotificationType::NAV_ENTRY_COMMITTED: { 3130 case NotificationType::NAV_ENTRY_COMMITTED: {
3125 DCHECK(&controller_ == Source<NavigationController>(source).ptr()); 3131 DCHECK(&controller_ == Source<NavigationController>(source).ptr());
3126 3132
3127 NavigationController::LoadCommittedDetails& committed_details = 3133 NavigationController::LoadCommittedDetails& committed_details =
3128 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); 3134 *(Details<NavigationController::LoadCommittedDetails>(details).ptr());
3129 ExpireInfoBars(committed_details); 3135 ExpireInfoBars(committed_details);
3136
3137 render_process_ran_out_of_memory_ = false;
3130 break; 3138 break;
3131 } 3139 }
3132 3140
3133 #if defined(OS_LINUX) 3141 #if defined(OS_LINUX)
3134 case NotificationType::BROWSER_THEME_CHANGED: { 3142 case NotificationType::BROWSER_THEME_CHANGED: {
3135 renderer_preferences_util::UpdateFromSystemSettings( 3143 renderer_preferences_util::UpdateFromSystemSettings(
3136 &renderer_preferences_, profile()); 3144 &renderer_preferences_, profile());
3137 render_view_host()->SyncRendererPrefs(); 3145 render_view_host()->SyncRendererPrefs();
3138 break; 3146 break;
3139 } 3147 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
3258 } 3266 }
3259 3267
3260 bool TabContents::MaybeUsePreloadedPage(const GURL& url) { 3268 bool TabContents::MaybeUsePreloadedPage(const GURL& url) {
3261 PrerenderManager* pm = profile()->GetPrerenderManager(); 3269 PrerenderManager* pm = profile()->GetPrerenderManager();
3262 if (pm != NULL) { 3270 if (pm != NULL) {
3263 if (pm->MaybeUsePreloadedPage(this, url)) 3271 if (pm->MaybeUsePreloadedPage(this, url))
3264 return true; 3272 return true;
3265 } 3273 }
3266 return false; 3274 return false;
3267 } 3275 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698