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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 15742019: Avoid DidStopLoading messages from the old renderer process during a transfer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clarify comment. Created 7 years, 6 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
« no previous file with comments | « content/browser/web_contents/render_view_host_manager.cc ('k') | no next file » | 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 "content/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 5443 matching lines...) Expand 10 before | Expand all | Expand 10 after
5454 void RenderViewImpl::OnShouldClose() { 5454 void RenderViewImpl::OnShouldClose() {
5455 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); 5455 base::TimeTicks before_unload_start_time = base::TimeTicks::Now();
5456 bool should_close = webview()->dispatchBeforeUnloadEvent(); 5456 bool should_close = webview()->dispatchBeforeUnloadEvent();
5457 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); 5457 base::TimeTicks before_unload_end_time = base::TimeTicks::Now();
5458 Send(new ViewHostMsg_ShouldClose_ACK(routing_id_, should_close, 5458 Send(new ViewHostMsg_ShouldClose_ACK(routing_id_, should_close,
5459 before_unload_start_time, 5459 before_unload_start_time,
5460 before_unload_end_time)); 5460 before_unload_end_time));
5461 } 5461 }
5462 5462
5463 void RenderViewImpl::OnSwapOut(const ViewMsg_SwapOut_Params& params) { 5463 void RenderViewImpl::OnSwapOut(const ViewMsg_SwapOut_Params& params) {
5464 // Ensure that no other in-progress navigation continues.
5465 OnStop();
5466
5467 // Only run unload if we're not swapped out yet, but send the ack either way. 5464 // Only run unload if we're not swapped out yet, but send the ack either way.
5468 if (!is_swapped_out_) { 5465 if (!is_swapped_out_) {
5469 // Swap this RenderView out so the tab can navigate to a page rendered by a 5466 // Swap this RenderView out so the tab can navigate to a page rendered by a
5470 // different process. This involves running the unload handler and clearing 5467 // different process. This involves running the unload handler and clearing
5471 // the page. Once WasSwappedOut is called, we also allow this process to 5468 // the page. Once WasSwappedOut is called, we also allow this process to
5472 // exit if there are no other active RenderViews in it. 5469 // exit if there are no other active RenderViews in it.
5473 5470
5474 // Send an UpdateState message before we get swapped out. 5471 // Send an UpdateState message before we get swapped out.
5475 SyncNavigationState(); 5472 SyncNavigationState();
5476 5473
5477 // Synchronously run the unload handler before sending the ACK. 5474 // Synchronously run the unload handler before sending the ACK.
5478 webview()->dispatchUnloadEvent(); 5475 webview()->dispatchUnloadEvent();
5479 5476
5480 // Swap out and stop sending any IPC messages that are not ACKs. 5477 // Swap out and stop sending any IPC messages that are not ACKs.
5481 SetSwappedOut(true); 5478 SetSwappedOut(true);
5482 5479
5480 // Now that we're swapped out and filtering IPC messages, stop loading to
5481 // ensure that no other in-progress navigation continues. We do this here
5482 // to avoid sending a DidStopLoading message to the browser process.
5483 OnStop();
5484
5483 // Replace the page with a blank dummy URL. The unload handler will not be 5485 // Replace the page with a blank dummy URL. The unload handler will not be
5484 // run a second time, thanks to a check in FrameLoader::stopLoading. 5486 // run a second time, thanks to a check in FrameLoader::stopLoading.
5485 // TODO(creis): Need to add a better way to do this that avoids running the 5487 // TODO(creis): Need to add a better way to do this that avoids running the
5486 // beforeunload handler. For now, we just run it a second time silently. 5488 // beforeunload handler. For now, we just run it a second time silently.
5487 NavigateToSwappedOutURL(webview()->mainFrame()); 5489 NavigateToSwappedOutURL(webview()->mainFrame());
5488 5490
5489 // Let WebKit know that this view is hidden so it can drop resources and 5491 // Let WebKit know that this view is hidden so it can drop resources and
5490 // stop compositing. 5492 // stop compositing.
5491 webview()->setVisibilityState(WebKit::WebPageVisibilityStateHidden, false); 5493 webview()->setVisibilityState(WebKit::WebPageVisibilityStateHidden, false);
5492 } 5494 }
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
6562 WebURL url = icon_urls[i].iconURL(); 6564 WebURL url = icon_urls[i].iconURL();
6563 if (!url.isEmpty()) 6565 if (!url.isEmpty())
6564 urls.push_back(FaviconURL(url, 6566 urls.push_back(FaviconURL(url,
6565 ToFaviconType(icon_urls[i].iconType()))); 6567 ToFaviconType(icon_urls[i].iconType())));
6566 } 6568 }
6567 SendUpdateFaviconURL(urls); 6569 SendUpdateFaviconURL(urls);
6568 } 6570 }
6569 6571
6570 6572
6571 } // namespace content 6573 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/render_view_host_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698