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

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

Issue 117693002: Make RenderFrameHostManager swap RenderFrameHosts, not RenderViewHosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflicts Created 7 years 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) 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 bool CollectSites(BrowserContext* context, 275 bool CollectSites(BrowserContext* context,
276 std::set<GURL>* sites, 276 std::set<GURL>* sites,
277 FrameTreeNode* node) { 277 FrameTreeNode* node) {
278 sites->insert(SiteInstance::GetSiteForURL(context, node->current_url())); 278 sites->insert(SiteInstance::GetSiteForURL(context, node->current_url()));
279 return true; 279 return true;
280 } 280 }
281 281
282 bool ForEachFrameInternal( 282 bool ForEachFrameInternal(
283 const base::Callback<void(RenderFrameHost*)>& on_frame, 283 const base::Callback<void(RenderFrameHost*)>& on_frame,
284 FrameTreeNode* node) { 284 FrameTreeNode* node) {
285 on_frame.Run(node->render_frame_host()); 285 on_frame.Run(node->current_frame_host());
286 return true; 286 return true;
287 } 287 }
288 288
289 void SendToAllFramesInternal(IPC::Message* message, RenderFrameHost* rfh) { 289 void SendToAllFramesInternal(IPC::Message* message, RenderFrameHost* rfh) {
290 IPC::Message* message_copy = new IPC::Message(*message); 290 IPC::Message* message_copy = new IPC::Message(*message);
291 message_copy->set_routing_id(rfh->GetRoutingID()); 291 message_copy->set_routing_id(rfh->GetRoutingID());
292 rfh->Send(message_copy); 292 rfh->Send(message_copy);
293 } 293 }
294 294
295 } // namespace 295 } // namespace
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 view_->SetOverscrollControllerEnabled(delegate->CanOverscrollContent()); 644 view_->SetOverscrollControllerEnabled(delegate->CanOverscrollContent());
645 } 645 }
646 } 646 }
647 647
648 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { 648 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const {
649 RenderViewHostImpl* host = GetRenderManager()->current_host(); 649 RenderViewHostImpl* host = GetRenderManager()->current_host();
650 return host ? host->GetProcess() : NULL; 650 return host ? host->GetProcess() : NULL;
651 } 651 }
652 652
653 RenderFrameHost* WebContentsImpl::GetMainFrame() { 653 RenderFrameHost* WebContentsImpl::GetMainFrame() {
654 return frame_tree_.root()->render_frame_host(); 654 return frame_tree_.root()->current_frame_host();
655 } 655 }
656 656
657 void WebContentsImpl::ForEachFrame( 657 void WebContentsImpl::ForEachFrame(
658 const base::Callback<void(RenderFrameHost*)>& on_frame) { 658 const base::Callback<void(RenderFrameHost*)>& on_frame) {
659 frame_tree_.ForEach(base::Bind(&ForEachFrameInternal, on_frame)); 659 frame_tree_.ForEach(base::Bind(&ForEachFrameInternal, on_frame));
660 } 660 }
661 661
662 void WebContentsImpl::SendToAllFrames(IPC::Message* message) { 662 void WebContentsImpl::SendToAllFrames(IPC::Message* message) {
663 ForEachFrame(base::Bind(&SendToAllFramesInternal, message)); 663 ForEachFrame(base::Bind(&SendToAllFramesInternal, message));
664 delete message; 664 delete message;
(...skipping 2390 matching lines...) Expand 10 before | Expand all | Expand 10 after
3055 } 3055 }
3056 } 3056 }
3057 DidNavigateAnyFramePostCommit(rvh, details, params); 3057 DidNavigateAnyFramePostCommit(rvh, details, params);
3058 } 3058 }
3059 3059
3060 void WebContentsImpl::UpdateState(RenderViewHost* rvh, 3060 void WebContentsImpl::UpdateState(RenderViewHost* rvh,
3061 int32 page_id, 3061 int32 page_id,
3062 const PageState& page_state) { 3062 const PageState& page_state) {
3063 // Ensure that this state update comes from either the active RVH or one of 3063 // Ensure that this state update comes from either the active RVH or one of
3064 // the swapped out RVHs. We don't expect to hear from any other RVHs. 3064 // the swapped out RVHs. We don't expect to hear from any other RVHs.
3065 DCHECK(rvh == GetRenderViewHost() || 3065 // TODO(nasko): This should go through RenderFrameHost.
3066 GetRenderManager()->IsOnSwappedOutList(rvh)); 3066 // TODO(creis): We can't update state for cross-process subframes until we
3067 // have FrameNavigationEntries. Once we do, this should be a DCHECK.
3068 if (rvh != GetRenderViewHost() &&
3069 !GetRenderManager()->IsRVHOnSwappedOutList(
3070 static_cast<RenderViewHostImpl*>(rvh)))
3071 return;
3067 3072
3068 // We must be prepared to handle state updates for any page, these occur 3073 // We must be prepared to handle state updates for any page, these occur
3069 // when the user is scrolling and entering form data, as well as when we're 3074 // when the user is scrolling and entering form data, as well as when we're
3070 // leaving a page, in which case our state may have already been moved to 3075 // leaving a page, in which case our state may have already been moved to
3071 // the next page. The navigation controller will look up the appropriate 3076 // the next page. The navigation controller will look up the appropriate
3072 // NavigationEntry and update it when it is notified via the delegate. 3077 // NavigationEntry and update it when it is notified via the delegate.
3073 3078
3074 int entry_index = controller_.GetEntryIndexWithPageID( 3079 int entry_index = controller_.GetEntryIndexWithPageID(
3075 rvh->GetSiteInstance(), page_id); 3080 rvh->GetSiteInstance(), page_id);
3076 if (entry_index < 0) 3081 if (entry_index < 0)
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
3483 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here, 3488 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here,
3484 // as it is deprecated and can be out of sync with GetRenderViewHost(). 3489 // as it is deprecated and can be out of sync with GetRenderViewHost().
3485 GURL url = controller_.GetActiveEntry() 3490 GURL url = controller_.GetActiveEntry()
3486 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); 3491 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL();
3487 3492
3488 return GetRenderManager()->current_host()->GetWebkitPrefs(url); 3493 return GetRenderManager()->current_host()->GetWebkitPrefs(url);
3489 } 3494 }
3490 3495
3491 int WebContentsImpl::CreateSwappedOutRenderView( 3496 int WebContentsImpl::CreateSwappedOutRenderView(
3492 SiteInstance* instance) { 3497 SiteInstance* instance) {
3493 return GetRenderManager()->CreateRenderView(instance, MSG_ROUTING_NONE, 3498 return GetRenderManager()->CreateRenderFrame(instance, MSG_ROUTING_NONE,
3494 true, true); 3499 true, true);
3495 } 3500 }
3496 3501
3497 void WebContentsImpl::OnUserGesture() { 3502 void WebContentsImpl::OnUserGesture() {
3498 // Notify observers. 3503 // Notify observers.
3499 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); 3504 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture());
3500 3505
3501 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); 3506 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
3502 if (rdh) // NULL in unittests. 3507 if (rdh) // NULL in unittests.
3503 rdh->OnUserGesture(this); 3508 rdh->OnUserGesture(this);
3504 } 3509 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
3653 instance) 3658 instance)
3654 return GetRenderManager()->pending_render_view_host()->GetRoutingID(); 3659 return GetRenderManager()->pending_render_view_host()->GetRoutingID();
3655 3660
3656 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost( 3661 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost(
3657 instance); 3662 instance);
3658 if (rvh) 3663 if (rvh)
3659 return rvh->GetRoutingID(); 3664 return rvh->GetRoutingID();
3660 3665
3661 // Create a swapped out RenderView in the given SiteInstance if none exists, 3666 // Create a swapped out RenderView in the given SiteInstance if none exists,
3662 // setting its opener to the given route_id. Return the new view's route_id. 3667 // setting its opener to the given route_id. Return the new view's route_id.
3663 return GetRenderManager()->CreateRenderView(instance, opener_route_id, 3668 return GetRenderManager()->CreateRenderFrame(instance, opener_route_id,
3664 true, true); 3669 true, true);
3665 } 3670 }
3666 3671
3667 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { 3672 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() {
3668 return GetController(); 3673 return GetController();
3669 } 3674 }
3670 3675
3671 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { 3676 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) {
3672 return static_cast<WebUIImpl*>(CreateWebUI(url)); 3677 return static_cast<WebUIImpl*>(CreateWebUI(url));
3673 } 3678 }
3674 3679
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3816 } 3821 }
3817 3822
3818 void WebContentsImpl::OnFrameRemoved( 3823 void WebContentsImpl::OnFrameRemoved(
3819 RenderViewHostImpl* render_view_host, 3824 RenderViewHostImpl* render_view_host,
3820 int64 frame_id) { 3825 int64 frame_id) {
3821 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3826 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3822 FrameDetached(render_view_host, frame_id)); 3827 FrameDetached(render_view_host, frame_id));
3823 } 3828 }
3824 3829
3825 } // namespace content 3830 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_unittest.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