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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 180993003: Revert "Revert 249676 "Have the unload event execute in background on cr..."" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed an error in the swap out logic Created 6 years, 9 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
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 "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) 320 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++)
321 g_created_callbacks.Get().at(i).Run(this); 321 g_created_callbacks.Get().at(i).Run(this);
322 frame_tree_.SetFrameRemoveListener( 322 frame_tree_.SetFrameRemoveListener(
323 base::Bind(&WebContentsImpl::OnFrameRemoved, 323 base::Bind(&WebContentsImpl::OnFrameRemoved,
324 base::Unretained(this))); 324 base::Unretained(this)));
325 } 325 }
326 326
327 WebContentsImpl::~WebContentsImpl() { 327 WebContentsImpl::~WebContentsImpl() {
328 is_being_destroyed_ = true; 328 is_being_destroyed_ = true;
329 329
330 // Delete all RFH pending shutdown, which will lead the corresponding RVH to
331 // shutdown and be deleted as well.
332 GetRenderManager()->ClearAllPendingShutdownRFH();
Charlie Reis 2014/02/26 17:54:30 If this deletes the RVHs, does it eliminate the ne
jam 2014/02/26 22:48:47 I had assumed, perhaps incorrectly, that the list
Charlie Reis 2014/02/26 23:30:31 Ah, of course. ClearAllPendingShutdownRFH() doesn
clamy 2014/02/27 17:38:06 Yes this only covers the case of RFH pending shutd
Charlie Reis 2014/02/27 20:09:27 Ah, thanks for taking care of that here.
jam 2014/02/27 21:33:10 I think for swapped out RFH, we should call Render
333
330 ClearAllPowerSaveBlockers(); 334 ClearAllPowerSaveBlockers();
331 335
332 for (std::set<RenderWidgetHostImpl*>::iterator iter = 336 for (std::set<RenderWidgetHostImpl*>::iterator iter =
333 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { 337 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) {
334 (*iter)->DetachDelegate(); 338 (*iter)->DetachDelegate();
335 } 339 }
336 created_widgets_.clear(); 340 created_widgets_.clear();
337 341
338 // Clear out any JavaScript state. 342 // Clear out any JavaScript state.
339 if (dialog_manager_) 343 if (dialog_manager_)
(...skipping 2432 matching lines...) Expand 10 before | Expand all | Expand 10 after
2772 2776
2773 void WebContentsImpl::RemoveBrowserPluginEmbedder() { 2777 void WebContentsImpl::RemoveBrowserPluginEmbedder() {
2774 if (browser_plugin_embedder_) 2778 if (browser_plugin_embedder_)
2775 browser_plugin_embedder_.reset(); 2779 browser_plugin_embedder_.reset();
2776 } 2780 }
2777 2781
2778 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { 2782 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) {
2779 // Don't send notifications if we are just creating a swapped-out RVH for 2783 // Don't send notifications if we are just creating a swapped-out RVH for
2780 // the opener chain. These won't be used for view-source or WebUI, so it's 2784 // the opener chain. These won't be used for view-source or WebUI, so it's
2781 // ok to return early. 2785 // ok to return early.
2782 if (static_cast<RenderViewHostImpl*>(render_view_host)->is_swapped_out()) 2786 if (static_cast<RenderViewHostImpl*>(render_view_host)->IsSwappedOut())
2783 return; 2787 return;
2784 2788
2785 if (delegate_) 2789 if (delegate_)
2786 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); 2790 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent());
2787 2791
2788 NotificationService::current()->Notify( 2792 NotificationService::current()->Notify(
2789 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, 2793 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED,
2790 Source<WebContents>(this), 2794 Source<WebContents>(this),
2791 Details<RenderViewHost>(render_view_host)); 2795 Details<RenderViewHost>(render_view_host));
2792 2796
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
3054 3058
3055 void WebContentsImpl::RequestOpenURL(RenderViewHost* rvh, 3059 void WebContentsImpl::RequestOpenURL(RenderViewHost* rvh,
3056 const GURL& url, 3060 const GURL& url,
3057 const Referrer& referrer, 3061 const Referrer& referrer,
3058 WindowOpenDisposition disposition, 3062 WindowOpenDisposition disposition,
3059 int64 source_frame_id, 3063 int64 source_frame_id,
3060 bool should_replace_current_entry, 3064 bool should_replace_current_entry,
3061 bool user_gesture) { 3065 bool user_gesture) {
3062 // If this came from a swapped out RenderViewHost, we only allow the request 3066 // If this came from a swapped out RenderViewHost, we only allow the request
3063 // if we are still in the same BrowsingInstance. 3067 // if we are still in the same BrowsingInstance.
3064 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() && 3068 if (static_cast<RenderViewHostImpl*>(rvh)->IsSwappedOut() &&
3065 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { 3069 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) {
3066 return; 3070 return;
3067 } 3071 }
3068 3072
3069 // Delegate to RequestTransferURL because this is just the generic 3073 // Delegate to RequestTransferURL because this is just the generic
3070 // case where |old_request_id| is empty. 3074 // case where |old_request_id| is empty.
3071 // TODO(creis): Pass the redirect_chain into this method to support client 3075 // TODO(creis): Pass the redirect_chain into this method to support client
3072 // redirects. http://crbug.com/311721. 3076 // redirects. http://crbug.com/311721.
3073 std::vector<GURL> redirect_chain; 3077 std::vector<GURL> redirect_chain;
3074 RequestTransferURL(url, redirect_chain, referrer, PAGE_TRANSITION_LINK, 3078 RequestTransferURL(url, redirect_chain, referrer, PAGE_TRANSITION_LINK,
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
3225 const base::string16& message, 3229 const base::string16& message,
3226 const base::string16& default_prompt, 3230 const base::string16& default_prompt,
3227 const GURL& frame_url, 3231 const GURL& frame_url,
3228 JavaScriptMessageType javascript_message_type, 3232 JavaScriptMessageType javascript_message_type,
3229 IPC::Message* reply_msg, 3233 IPC::Message* reply_msg,
3230 bool* did_suppress_message) { 3234 bool* did_suppress_message) {
3231 // Suppress JavaScript dialogs when requested. Also suppress messages when 3235 // Suppress JavaScript dialogs when requested. Also suppress messages when
3232 // showing an interstitial as it's shown over the previous page and we don't 3236 // showing an interstitial as it's shown over the previous page and we don't
3233 // want the hidden page's dialogs to interfere with the interstitial. 3237 // want the hidden page's dialogs to interfere with the interstitial.
3234 bool suppress_this_message = 3238 bool suppress_this_message =
3235 static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() || 3239 static_cast<RenderViewHostImpl*>(rvh)->IsSwappedOut() ||
3236 ShowingInterstitialPage() || 3240 ShowingInterstitialPage() ||
3237 !delegate_ || 3241 !delegate_ ||
3238 delegate_->ShouldSuppressDialogs() || 3242 delegate_->ShouldSuppressDialogs() ||
3239 !delegate_->GetJavaScriptDialogManager(); 3243 !delegate_->GetJavaScriptDialogManager();
3240 3244
3241 if (!suppress_this_message) { 3245 if (!suppress_this_message) {
3242 std::string accept_lang = GetContentClient()->browser()-> 3246 std::string accept_lang = GetContentClient()->browser()->
3243 GetAcceptLangs(GetBrowserContext()); 3247 GetAcceptLangs(GetBrowserContext());
3244 dialog_manager_ = delegate_->GetJavaScriptDialogManager(); 3248 dialog_manager_ = delegate_->GetJavaScriptDialogManager();
3245 dialog_manager_->RunJavaScriptDialog( 3249 dialog_manager_->RunJavaScriptDialog(
(...skipping 24 matching lines...) Expand all
3270 3274
3271 void WebContentsImpl::RunBeforeUnloadConfirm(RenderViewHost* rvh, 3275 void WebContentsImpl::RunBeforeUnloadConfirm(RenderViewHost* rvh,
3272 const base::string16& message, 3276 const base::string16& message,
3273 bool is_reload, 3277 bool is_reload,
3274 IPC::Message* reply_msg) { 3278 IPC::Message* reply_msg) {
3275 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); 3279 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh);
3276 if (delegate_) 3280 if (delegate_)
3277 delegate_->WillRunBeforeUnloadConfirm(); 3281 delegate_->WillRunBeforeUnloadConfirm();
3278 3282
3279 bool suppress_this_message = 3283 bool suppress_this_message =
3280 rvhi->is_swapped_out() || 3284 rvhi->rvh_state() != RenderViewHostImpl::STATE_DEFAULT ||
3281 !delegate_ || 3285 !delegate_ ||
3282 delegate_->ShouldSuppressDialogs() || 3286 delegate_->ShouldSuppressDialogs() ||
3283 !delegate_->GetJavaScriptDialogManager(); 3287 !delegate_->GetJavaScriptDialogManager();
3284 if (suppress_this_message) { 3288 if (suppress_this_message) {
3285 // The reply must be sent to the RVH that sent the request. 3289 // The reply must be sent to the RVH that sent the request.
3286 rvhi->JavaScriptDialogClosed(reply_msg, true, base::string16()); 3290 rvhi->JavaScriptDialogClosed(reply_msg, true, base::string16());
3287 return; 3291 return;
3288 } 3292 }
3289 3293
3290 is_showing_before_unload_dialog_ = true; 3294 is_showing_before_unload_dialog_ = true;
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
3662 3666
3663 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { 3667 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) {
3664 if (!delegate_) 3668 if (!delegate_)
3665 return; 3669 return;
3666 const gfx::Size new_size = GetPreferredSize(); 3670 const gfx::Size new_size = GetPreferredSize();
3667 if (new_size != old_size) 3671 if (new_size != old_size)
3668 delegate_->UpdatePreferredSize(this, new_size); 3672 delegate_->UpdatePreferredSize(this, new_size);
3669 } 3673 }
3670 3674
3671 } // namespace content 3675 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.cc ('k') | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698