diff options
-rw-r--r-- | content/browser/renderer_host/render_view_host.cc | 40 | ||||
-rw-r--r-- | content/browser/renderer_host/render_view_host.h | 11 | ||||
-rw-r--r-- | content/browser/renderer_host/test_render_view_host.cc | 2 | ||||
-rw-r--r-- | content/browser/tab_contents/render_view_host_manager.cc | 12 | ||||
-rw-r--r-- | content/browser/tab_contents/render_view_host_manager.h | 6 | ||||
-rw-r--r-- | content/browser/tab_contents/render_view_host_manager_unittest.cc | 4 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents_unittest.cc | 24 | ||||
-rw-r--r-- | content/common/view_messages.h | 9 | ||||
-rw-r--r-- | content/public/browser/render_view_host_delegate.h | 10 | ||||
-rw-r--r-- | content/renderer/render_view_impl.cc | 27 | ||||
-rw-r--r-- | content/renderer/render_view_impl.h | 2 |
11 files changed, 27 insertions, 120 deletions
diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index 2ea99ae..3fe9e9e 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -29,7 +29,6 @@ #include "content/common/accessibility_messages.h" #include "content/common/desktop_notification_messages.h" #include "content/common/drag_messages.h" -#include "content/common/inter_process_time_ticks_converter.h" #include "content/common/speech_input_messages.h" #include "content/common/swapped_out_messages.h" #include "content/common/view_messages.h" @@ -69,8 +68,6 @@ using content::BrowserThread; using content::DomOperationNotificationDetails; using content::DOMStorageContext; using content::HostZoomMap; -using content::LocalTimeTicks; -using content::RemoteTimeTicks; using content::RenderViewHostDelegate; using content::SessionStorageNamespace; using content::SiteInstance; @@ -352,18 +349,13 @@ void RenderViewHostImpl::CancelSuspendedNavigations() { navigations_suspended_ = false; } -void RenderViewHostImpl::SetNavigationStartTime( - const base::TimeTicks& navigation_start) { - Send(new ViewMsg_SetNavigationStartTime(GetRoutingID(), navigation_start)); -} - void RenderViewHostImpl::FirePageBeforeUnload(bool for_cross_site_transition) { if (!IsRenderViewLive()) { // This RenderViewHostImpl doesn't have a live renderer, so just // skip running the onbeforeunload handler. is_waiting_for_beforeunload_ack_ = true; // Checked by OnMsgShouldCloseACK. unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; - OnMsgShouldCloseACK(true, base::TimeTicks::Now(), base::TimeTicks::Now()); + OnMsgShouldCloseACK(true); return; } @@ -385,7 +377,6 @@ void RenderViewHostImpl::FirePageBeforeUnload(bool for_cross_site_transition) { is_waiting_for_beforeunload_ack_ = true; unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); - send_should_close_start_time_ = base::TimeTicks::Now(); Send(new ViewMsg_ShouldClose(GetRoutingID())); } } @@ -991,8 +982,7 @@ void RenderViewHostImpl::OnMsgNavigate(const IPC::Message& msg) { if (is_waiting_for_beforeunload_ack_ && unload_ack_is_for_cross_site_transition_ && content::PageTransitionIsMainFrame(validated_params.transition)) { - OnMsgShouldCloseACK(true, send_should_close_start_time_, - base::TimeTicks::Now()); + OnMsgShouldCloseACK(true); return; } @@ -1285,10 +1275,7 @@ void RenderViewHostImpl::OnUserGesture() { delegate_->OnUserGesture(); } -void RenderViewHostImpl::OnMsgShouldCloseACK( - bool proceed, - const base::TimeTicks& renderer_before_unload_start_time, - const base::TimeTicks& renderer_before_unload_end_time) { +void RenderViewHostImpl::OnMsgShouldCloseACK(bool proceed) { StopHangMonitorTimeout(); // If this renderer navigated while the beforeunload request was in flight, we // may have cleared this state in OnMsgNavigate, in which case we can ignore @@ -1301,27 +1288,8 @@ void RenderViewHostImpl::OnMsgShouldCloseACK( RenderViewHostDelegate::RendererManagement* management_delegate = delegate_->GetRendererManagementDelegate(); if (management_delegate) { - base::TimeTicks before_unload_end_time; - if (!send_should_close_start_time_.is_null() && - !renderer_before_unload_start_time.is_null() && - !renderer_before_unload_end_time.is_null()) { - // When passing TimeTicks across process boundaries, we need to compensate - // for any skew between the processes. Here we are converting the - // renderer's notion of before_unload_end_time to TimeTicks in the browser - // process. See comments in inter_process_time_ticks_converter.h for more. - content::InterProcessTimeTicksConverter converter( - LocalTimeTicks::FromTimeTicks(send_should_close_start_time_), - LocalTimeTicks::FromTimeTicks(base::TimeTicks::Now()), - RemoteTimeTicks::FromTimeTicks(renderer_before_unload_start_time), - RemoteTimeTicks::FromTimeTicks(renderer_before_unload_end_time)); - LocalTimeTicks browser_before_unload_end_time = - converter.ToLocalTimeTicks( - RemoteTimeTicks::FromTimeTicks(renderer_before_unload_end_time)); - before_unload_end_time = browser_before_unload_end_time.ToTimeTicks(); - } management_delegate->ShouldClosePage( - unload_ack_is_for_cross_site_transition_, proceed, - before_unload_end_time); + unload_ack_is_for_cross_site_transition_, proceed); } // If canceled, notify the delegate to cancel its pending navigation entry. diff --git a/content/browser/renderer_host/render_view_host.h b/content/browser/renderer_host/render_view_host.h index 72b747b..e488b39 100644 --- a/content/browser/renderer_host/render_view_host.h +++ b/content/browser/renderer_host/render_view_host.h @@ -492,9 +492,6 @@ class CONTENT_EXPORT RenderViewHostImpl // RenderViewHost. void CancelSuspendedNavigations(); - // Informs the renderer of when the current navigation was allowed to proceed. - void SetNavigationStartTime(const base::TimeTicks& navigation_start); - // Whether this RenderViewHost has been swapped out to be displayed by a // different process. bool is_swapped_out() const { return is_swapped_out_; } @@ -711,10 +708,7 @@ class CONTENT_EXPORT RenderViewHostImpl const string16& source_id); void OnUpdateInspectorSetting(const std::string& key, const std::string& value); - void OnMsgShouldCloseACK( - bool proceed, - const base::TimeTicks& renderer_before_unload_start_time, - const base::TimeTicks& renderer_before_unload_end_time); + void OnMsgShouldCloseACK(bool proceed); void OnMsgClosePageACK(); void OnAccessibilityNotifications( const std::vector<AccessibilityHostMsg_NotificationParams>& params); @@ -837,9 +831,6 @@ class CONTENT_EXPORT RenderViewHostImpl // A list of observers that filter messages. Weak references. ObserverList<content::RenderViewHostObserver> observers_; - // When the last ShouldClose message was sent. - base::TimeTicks send_should_close_start_time_; - DISALLOW_COPY_AND_ASSIGN(RenderViewHostImpl); }; diff --git a/content/browser/renderer_host/test_render_view_host.cc b/content/browser/renderer_host/test_render_view_host.cc index bcc15b4..69bbc17 100644 --- a/content/browser/renderer_host/test_render_view_host.cc +++ b/content/browser/renderer_host/test_render_view_host.cc @@ -137,7 +137,7 @@ void TestRenderViewHost::SendNavigateWithTransition( } void TestRenderViewHost::SendShouldCloseACK(bool proceed) { - OnMsgShouldCloseACK(proceed, base::TimeTicks(), base::TimeTicks()); + OnMsgShouldCloseACK(proceed); } void TestRenderViewHost::TestOnMsgStartDragging(const WebDropData& drop_data) { diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc index 79039e2..29faba0a 100644 --- a/content/browser/tab_contents/render_view_host_manager.cc +++ b/content/browser/tab_contents/render_view_host_manager.cc @@ -270,10 +270,8 @@ void RenderViewHostManager::RendererProcessClosing( } } -void RenderViewHostManager::ShouldClosePage( - bool for_cross_site_transition, - bool proceed, - const base::TimeTicks& proceed_time) { +void RenderViewHostManager::ShouldClosePage(bool for_cross_site_transition, + bool proceed) { if (for_cross_site_transition) { // Ignore if we're not in a cross-site navigation. if (!cross_navigation_pending_) @@ -286,12 +284,8 @@ void RenderViewHostManager::ShouldClosePage( // already made by ShouldCloseTabOnUnresponsiveRenderer. In that case, it // is ok to do nothing here. if (pending_render_view_host_ && - pending_render_view_host_->are_navigations_suspended()) { + pending_render_view_host_->are_navigations_suspended()) pending_render_view_host_->SetNavigationsSuspended(false); - if (!proceed_time.is_null()) { - pending_render_view_host_->SetNavigationStartTime(proceed_time); - } - } } else { // Current page says to cancel. CancelPending(); diff --git a/content/browser/tab_contents/render_view_host_manager.h b/content/browser/tab_contents/render_view_host_manager.h index 2772dca..179a400 100644 --- a/content/browser/tab_contents/render_view_host_manager.h +++ b/content/browser/tab_contents/render_view_host_manager.h @@ -178,10 +178,8 @@ class CONTENT_EXPORT RenderViewHostManager } // RenderViewHostDelegate::RendererManagement implementation. - virtual void ShouldClosePage( - bool for_cross_site_transition, - bool proceed, - const base::TimeTicks& proceed_time) OVERRIDE; + virtual void ShouldClosePage(bool for_cross_site_transition, + bool proceed) OVERRIDE; virtual void OnCrossSiteResponse(int new_render_process_host_id, int new_request_id) OVERRIDE; diff --git a/content/browser/tab_contents/render_view_host_manager_unittest.cc b/content/browser/tab_contents/render_view_host_manager_unittest.cc index 593a8ee..7d29909 100644 --- a/content/browser/tab_contents/render_view_host_manager_unittest.cc +++ b/content/browser/tab_contents/render_view_host_manager_unittest.cc @@ -335,8 +335,8 @@ TEST_F(RenderViewHostManagerTest, AlwaysSendEnableViewSourceMode) { controller().LoadURL( kUrl, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); // Simulate response from RenderView for FirePageBeforeUnload. - rvh()->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK( - rvh()->GetRoutingID(), true, base::TimeTicks(), base::TimeTicks())); + rvh()->TestOnMessageReceived( + ViewHostMsg_ShouldClose_ACK(rvh()->GetRoutingID(), true)); ASSERT_TRUE(pending_rvh()); // New pending RenderViewHost will be created. RenderViewHost* last_rvh = pending_rvh(); int32 new_id = contents()->GetMaxPageIDForSiteInstance( diff --git a/content/browser/tab_contents/tab_contents_unittest.cc b/content/browser/tab_contents/tab_contents_unittest.cc index 97b720b..dce378f 100644 --- a/content/browser/tab_contents/tab_contents_unittest.cc +++ b/content/browser/tab_contents/tab_contents_unittest.cc @@ -636,8 +636,7 @@ TEST_F(TabContentsTest, CrossSiteUnloadHandlers) { controller().LoadURL( url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack()); - orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK( - 0, false, base::TimeTicks(), base::TimeTicks())); + orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, false)); EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack()); EXPECT_FALSE(contents()->cross_navigation_pending()); EXPECT_EQ(orig_rvh, contents()->GetRenderViewHost()); @@ -646,8 +645,7 @@ TEST_F(TabContentsTest, CrossSiteUnloadHandlers) { controller().LoadURL( url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack()); - orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK( - 0, true, base::TimeTicks(), base::TimeTicks())); + orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true)); EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack()); EXPECT_TRUE(contents()->cross_navigation_pending()); TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>( @@ -688,8 +686,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationPreempted) { controller().LoadURL( url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack()); - orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK( - 0, true, base::TimeTicks(), base::TimeTicks())); + orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true)); EXPECT_TRUE(contents()->cross_navigation_pending()); // Suppose the original renderer navigates before the new one is ready. @@ -732,8 +729,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationBackPreempted) { // Simulate beforeunload approval. EXPECT_TRUE(ntp_rvh->is_waiting_for_beforeunload_ack()); - ntp_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK( - 0, true, base::TimeTicks(), base::TimeTicks())); + ntp_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true)); // DidNavigate from the pending page. contents()->TestDidNavigate( @@ -782,8 +778,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationBackPreempted) { // Simulate beforeunload approval. EXPECT_TRUE(google_rvh->is_waiting_for_beforeunload_ack()); - google_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK( - 0, true, base::TimeTicks(), base::TimeTicks())); + google_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true)); // DidNavigate from the first back. This aborts the second back's pending RVH. contents()->TestDidNavigate( @@ -832,8 +827,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationNotPreemptedByFrame) { // Now simulate the onbeforeunload approval and verify the navigation is // not canceled. - orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK( - 0, true, base::TimeTicks(), base::TimeTicks())); + orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true)); EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack()); EXPECT_TRUE(contents()->cross_navigation_pending()); } @@ -896,8 +890,7 @@ TEST_F(TabContentsTest, CrossSiteCantPreemptAfterUnload) { const GURL url2("http://www.yahoo.com"); controller().LoadURL( url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); - orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK( - 0, true, base::TimeTicks(), base::TimeTicks())); + orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true)); EXPECT_TRUE(contents()->cross_navigation_pending()); TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>( contents()->pending_rvh()); @@ -949,8 +942,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationCanceled) { controller().LoadURL( url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack()); - orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK( - 0, true, base::TimeTicks(), base::TimeTicks())); + orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true)); EXPECT_TRUE(contents()->cross_navigation_pending()); // Simulate swap out message when the response arrives. diff --git a/content/common/view_messages.h b/content/common/view_messages.h index 7ca8eaa..9ce789f 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -1083,9 +1083,6 @@ IPC_MESSAGE_ROUTED1(ViewMsg_DisableScrollbarsForSmallWindows, IPC_MESSAGE_ROUTED1(ViewMsg_SetActive, bool /* active */) -IPC_MESSAGE_ROUTED1(ViewMsg_SetNavigationStartTime, - base::TimeTicks /* browser_navigation_start */) - #if defined(OS_MACOSX) // Let the RenderView know its window has changed visibility. IPC_MESSAGE_ROUTED1(ViewMsg_SetWindowVisibility, @@ -1288,10 +1285,8 @@ IPC_MESSAGE_ROUTED5(ViewHostMsg_Find_Reply, // return value of the the frame's shouldClose method (which includes the // onbeforeunload handler): true if the user decided to proceed with leaving // the page. -IPC_MESSAGE_ROUTED3(ViewHostMsg_ShouldClose_ACK, - bool /* proceed */, - base::TimeTicks /* before_unload_start_time */, - base::TimeTicks /* before_unload_end_time */) +IPC_MESSAGE_ROUTED1(ViewHostMsg_ShouldClose_ACK, + bool /* proceed */) // Indicates that the current renderer has swapped out, after a SwapOut // message. The parameters are just echoed from the SwapOut request. diff --git a/content/public/browser/render_view_host_delegate.h b/content/public/browser/render_view_host_delegate.h index 3dbae8b..3a41689 100644 --- a/content/public/browser/render_view_host_delegate.h +++ b/content/public/browser/render_view_host_delegate.h @@ -36,7 +36,6 @@ struct WebPreferences; namespace base { class ListValue; -class TimeTicks; } namespace gfx { @@ -167,12 +166,9 @@ class CONTENT_EXPORT RenderViewHostDelegate : public IPC::Channel::Listener { // AttemptToClosePage. This is called before a cross-site request or before // a tab/window is closed (as indicated by the first parameter) to allow the // appropriate renderer to approve or deny the request. |proceed| indicates - // whether the user chose to proceed. |proceed_time| is the time when the - // request was allowed to proceed. - virtual void ShouldClosePage( - bool for_cross_site_transition, - bool proceed, - const base::TimeTicks& proceed_time) = 0; + // whether the user chose to proceed. + virtual void ShouldClosePage(bool for_cross_site_transition, + bool proceed) = 0; // Called by ResourceDispatcherHost when a response for a pending cross-site // request is received. The ResourceDispatcherHost will pause the response diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 8e729f3..59a0c46 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -787,8 +787,6 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) - IPC_MESSAGE_HANDLER(ViewMsg_SetNavigationStartTime, - OnSetNavigationStartTime) #if defined(OS_MACOSX) IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) @@ -4303,12 +4301,8 @@ void RenderViewImpl::OnGetSerializedHtmlDataForCurrentPageWithLocalLinks( } void RenderViewImpl::OnShouldClose() { - base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); bool should_close = webview()->dispatchBeforeUnloadEvent(); - base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); - Send(new ViewHostMsg_ShouldClose_ACK(routing_id_, should_close, - before_unload_start_time, - before_unload_end_time)); + Send(new ViewHostMsg_ShouldClose_ACK(routing_id_, should_close)); } void RenderViewImpl::OnSwapOut(const ViewMsg_SwapOut_Params& params) { @@ -4554,25 +4548,6 @@ void RenderViewImpl::OnSetActive(bool active) { #endif } -void RenderViewImpl::OnSetNavigationStartTime( - const base::TimeTicks& browser_navigation_start) { - if (!webview()) - return; - - // Only the initial navigation can be a cross-renderer navigation. If we've - // already navigated away from that page, we can ignore this message. - if (page_id_ != -1) - return; - - // browser_navigation_start is likely before this process existed, so we can't - // use InterProcessTimeTicksConverter. Instead, the best we can do is just - // ensure we don't report a bogus value in the future. - base::TimeTicks navigation_start = std::min(base::TimeTicks::Now(), - browser_navigation_start); - webview()->mainFrame()->provisionalDataSource()->setNavigationStartTime( - (navigation_start - base::TimeTicks()).InSecondsF()); -} - #if defined(OS_MACOSX) void RenderViewImpl::OnSetWindowVisibility(bool visible) { // Inform plugins that their container has changed visibility. diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index d4888a7..8117125 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -864,8 +864,6 @@ class RenderViewImpl : public RenderWidget, void OnSetActive(bool active); void OnSetAltErrorPageURL(const GURL& gurl); void OnSetBackground(const SkBitmap& background); - void OnSetNavigationStartTime( - const base::TimeTicks& browser_navigation_start); void OnSetWebUIProperty(const std::string& name, const std::string& value); void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands); CONTENT_EXPORT void OnSetHistoryLengthAndPrune(int history_length, |