Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // Ensure that no other in-progress navigation continues, once we've started | |
| 5481 // filtering the IPCs. We don't want to send a DidStopLoading for this. | |
|
Matt Perry
2013/05/28 22:08:06
Not sure I understand the comment. What does "this
Charlie Reis
2013/05/28 22:17:02
The SetSwappedOut line above it starts filtering o
| |
| 5482 OnStop(); | |
| 5483 | |
| 5483 // Replace the page with a blank dummy URL. The unload handler will not be | 5484 // 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. | 5485 // 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 | 5486 // 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. | 5487 // beforeunload handler. For now, we just run it a second time silently. |
| 5487 NavigateToSwappedOutURL(webview()->mainFrame()); | 5488 NavigateToSwappedOutURL(webview()->mainFrame()); |
| 5488 | 5489 |
| 5489 // Let WebKit know that this view is hidden so it can drop resources and | 5490 // Let WebKit know that this view is hidden so it can drop resources and |
| 5490 // stop compositing. | 5491 // stop compositing. |
| 5491 webview()->setVisibilityState(WebKit::WebPageVisibilityStateHidden, false); | 5492 webview()->setVisibilityState(WebKit::WebPageVisibilityStateHidden, false); |
| 5492 } | 5493 } |
| (...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6562 WebURL url = icon_urls[i].iconURL(); | 6563 WebURL url = icon_urls[i].iconURL(); |
| 6563 if (!url.isEmpty()) | 6564 if (!url.isEmpty()) |
| 6564 urls.push_back(FaviconURL(url, | 6565 urls.push_back(FaviconURL(url, |
| 6565 ToFaviconType(icon_urls[i].iconType()))); | 6566 ToFaviconType(icon_urls[i].iconType()))); |
| 6566 } | 6567 } |
| 6567 SendUpdateFaviconURL(urls); | 6568 SendUpdateFaviconURL(urls); |
| 6568 } | 6569 } |
| 6569 | 6570 |
| 6570 | 6571 |
| 6571 } // namespace content | 6572 } // namespace content |
| OLD | NEW |