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

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

Issue 6319001: Support window.opener after a process swap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comments. Created 9 years, 8 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 "content/browser/tab_contents/tab_contents.h" 5 #include "content/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/command_line.h" 10 #include "base/command_line.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // pending cross-site request, and then installs a CrossSiteEventHandler. 118 // pending cross-site request, and then installs a CrossSiteEventHandler.
119 // - When RDH receives a response, the BufferedEventHandler determines whether 119 // - When RDH receives a response, the BufferedEventHandler determines whether
120 // it is a download. If so, it sends a message to the new renderer causing 120 // it is a download. If so, it sends a message to the new renderer causing
121 // it to cancel the request, and the download proceeds in the download 121 // it to cancel the request, and the download proceeds in the download
122 // thread. For now, we stay in a PENDING state (with a pending RVH) until 122 // thread. For now, we stay in a PENDING state (with a pending RVH) until
123 // the next DidNavigate event for this TabContents. This isn't ideal, but it 123 // the next DidNavigate event for this TabContents. This isn't ideal, but it
124 // doesn't affect any functionality. 124 // doesn't affect any functionality.
125 // - After RDH receives a response and determines that it is safe and not a 125 // - After RDH receives a response and determines that it is safe and not a
126 // download, it pauses the response to first run the old page's onunload 126 // download, it pauses the response to first run the old page's onunload
127 // handler. It does this by asynchronously calling the OnCrossSiteResponse 127 // handler. It does this by asynchronously calling the OnCrossSiteResponse
128 // method of TabContents on the UI thread, which sends a ClosePage message 128 // method of TabContents on the UI thread, which sends a SwapOut message
129 // to the current RVH. 129 // to the current RVH.
130 // - Once the onunload handler is finished, a ClosePage_ACK message is sent to 130 // - Once the onunload handler is finished, a SwapOut_ACK message is sent to
131 // the ResourceDispatcherHost, who unpauses the response. Data is then sent 131 // the ResourceDispatcherHost, who unpauses the response. Data is then sent
132 // to the pending RVH. 132 // to the pending RVH.
133 // - The pending renderer sends a FrameNavigate message that invokes the 133 // - The pending renderer sends a FrameNavigate message that invokes the
134 // DidNavigate method. This replaces the current RVH with the 134 // DidNavigate method. This replaces the current RVH with the
135 // pending RVH and goes back to the NORMAL RendererState. 135 // pending RVH and goes back to the NORMAL RendererState.
136 // - The previous renderer is kept swapped out in RenderViewHostManager in case
137 // the user goes back. The process only stays live if another tab is using
138 // it, but if so, the existing frame relationships will be maintained.
136 139
137 namespace { 140 namespace {
138 141
139 // Amount of time we wait between when a key event is received and the renderer 142 // Amount of time we wait between when a key event is received and the renderer
140 // is queried for its state and pushed to the NavigationEntry. 143 // is queried for its state and pushed to the NavigationEntry.
141 const int kQueryStateDelay = 5000; 144 const int kQueryStateDelay = 5000;
142 145
143 const int kSyncWaitDelay = 40; 146 const int kSyncWaitDelay = 40;
144 147
145 // The list of prefs we want to observe. 148 // The list of prefs we want to observe.
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 2014
2012 // Run post-commit tasks. 2015 // Run post-commit tasks.
2013 if (details.is_main_frame) 2016 if (details.is_main_frame)
2014 DidNavigateMainFramePostCommit(details, params); 2017 DidNavigateMainFramePostCommit(details, params);
2015 DidNavigateAnyFramePostCommit(rvh, details, params); 2018 DidNavigateAnyFramePostCommit(rvh, details, params);
2016 } 2019 }
2017 2020
2018 void TabContents::UpdateState(RenderViewHost* rvh, 2021 void TabContents::UpdateState(RenderViewHost* rvh,
2019 int32 page_id, 2022 int32 page_id,
2020 const std::string& state) { 2023 const std::string& state) {
2021 DCHECK(rvh == render_view_host()); 2024 // Ensure that this state update comes from either the active RVH or one of
2025 // the swapped out RVHs. We don't expect to hear from any other RVHs.
2026 DCHECK(rvh == render_view_host() || render_manager_.IsSwappedOut(rvh));
2022 2027
2023 // We must be prepared to handle state updates for any page, these occur 2028 // We must be prepared to handle state updates for any page, these occur
2024 // when the user is scrolling and entering form data, as well as when we're 2029 // when the user is scrolling and entering form data, as well as when we're
2025 // leaving a page, in which case our state may have already been moved to 2030 // leaving a page, in which case our state may have already been moved to
2026 // the next page. The navigation controller will look up the appropriate 2031 // the next page. The navigation controller will look up the appropriate
2027 // NavigationEntry and update it when it is notified via the delegate. 2032 // NavigationEntry and update it when it is notified via the delegate.
2028 2033
2029 int entry_index = controller_.GetEntryIndexWithPageID( 2034 int entry_index = controller_.GetEntryIndexWithPageID(
2030 GetSiteInstance(), page_id); 2035 rvh->site_instance(), page_id);
2031 if (entry_index < 0) 2036 if (entry_index < 0)
2032 return; 2037 return;
2033 NavigationEntry* entry = controller_.GetEntryAtIndex(entry_index); 2038 NavigationEntry* entry = controller_.GetEntryAtIndex(entry_index);
2034 2039
2035 if (state == entry->content_state()) 2040 if (state == entry->content_state())
2036 return; // Nothing to update. 2041 return; // Nothing to update.
2037 entry->set_content_state(state); 2042 entry->set_content_state(state);
2038 controller_.NotifyEntryChanged(entry, entry_index); 2043 controller_.NotifyEntryChanged(entry, entry_index);
2039 } 2044 }
2040 2045
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
2576 2581
2577 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { 2582 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
2578 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); 2583 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh);
2579 rwh_view->SetSize(view()->GetContainerSize()); 2584 rwh_view->SetSize(view()->GetContainerSize());
2580 } 2585 }
2581 2586
2582 void TabContents::OnOnlineStateChanged(bool online) { 2587 void TabContents::OnOnlineStateChanged(bool online) {
2583 render_view_host()->Send(new ViewMsg_NetworkStateChanged( 2588 render_view_host()->Send(new ViewMsg_NetworkStateChanged(
2584 render_view_host()->routing_id(), online)); 2589 render_view_host()->routing_id(), online));
2585 } 2590 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698