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

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

Issue 345823002: Move ownership of ChildFrameCompositingHelper from frame to proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 while ((observer = it.GetNext()) != NULL) { 676 while ((observer = it.GetNext()) != NULL) {
677 if (observer->OnMessageReceived(msg)) 677 if (observer->OnMessageReceived(msg))
678 return true; 678 return true;
679 } 679 }
680 680
681 bool handled = true; 681 bool handled = true;
682 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg) 682 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg)
683 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) 683 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate)
684 IPC_MESSAGE_HANDLER(FrameMsg_BeforeUnload, OnBeforeUnload) 684 IPC_MESSAGE_HANDLER(FrameMsg_BeforeUnload, OnBeforeUnload)
685 IPC_MESSAGE_HANDLER(FrameMsg_SwapOut, OnSwapOut) 685 IPC_MESSAGE_HANDLER(FrameMsg_SwapOut, OnSwapOut)
686 IPC_MESSAGE_HANDLER(FrameMsg_BuffersSwapped, OnBuffersSwapped)
687 IPC_MESSAGE_HANDLER_GENERIC(FrameMsg_CompositorFrameSwapped,
688 OnCompositorFrameSwapped(msg))
689 IPC_MESSAGE_HANDLER(FrameMsg_ChildFrameProcessGone, OnChildFrameProcessGone)
690 IPC_MESSAGE_HANDLER(FrameMsg_ContextMenuClosed, OnContextMenuClosed) 686 IPC_MESSAGE_HANDLER(FrameMsg_ContextMenuClosed, OnContextMenuClosed)
691 IPC_MESSAGE_HANDLER(FrameMsg_CustomContextMenuAction, 687 IPC_MESSAGE_HANDLER(FrameMsg_CustomContextMenuAction,
692 OnCustomContextMenuAction) 688 OnCustomContextMenuAction)
693 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo) 689 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo)
694 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo) 690 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo)
695 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut) 691 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut)
696 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy) 692 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy)
697 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste) 693 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste)
698 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) 694 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle)
699 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete) 695 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete)
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 // purposes of compositing and input events. 958 // purposes of compositing and input events.
963 if (frame_->parent()) 959 if (frame_->parent())
964 frame_->setIsRemote(true); 960 frame_->setIsRemote(true);
965 961
966 // Replace the page with a blank dummy URL. The unload handler will not be 962 // Replace the page with a blank dummy URL. The unload handler will not be
967 // run a second time, thanks to a check in FrameLoader::stopLoading. 963 // run a second time, thanks to a check in FrameLoader::stopLoading.
968 // TODO(creis): Need to add a better way to do this that avoids running the 964 // TODO(creis): Need to add a better way to do this that avoids running the
969 // beforeunload handler. For now, we just run it a second time silently. 965 // beforeunload handler. For now, we just run it a second time silently.
970 render_view_->NavigateToSwappedOutURL(frame_); 966 render_view_->NavigateToSwappedOutURL(frame_);
971 967
972 if (frame_->parent())
973 render_view_->RegisterSwappedOutChildFrame(this);
974
975 // Let WebKit know that this view is hidden so it can drop resources and 968 // Let WebKit know that this view is hidden so it can drop resources and
976 // stop compositing. 969 // stop compositing.
977 // TODO(creis): Support this for subframes as well. 970 // TODO(creis): Support this for subframes as well.
978 if (!frame_->parent()) { 971 if (!frame_->parent()) {
979 render_view_->webview()->setVisibilityState( 972 render_view_->webview()->setVisibilityState(
980 blink::WebPageVisibilityStateHidden, false); 973 blink::WebPageVisibilityStateHidden, false);
981 } 974 }
982 } 975 }
983 976
984 // It is now safe to show modal dialogs again. 977 // It is now safe to show modal dialogs again.
985 // TODO(creis): Deal with modal dialogs from subframes. 978 // TODO(creis): Deal with modal dialogs from subframes.
986 if (!frame_->parent()) 979 if (!frame_->parent())
987 render_view_->suppress_dialogs_until_swap_out_ = false; 980 render_view_->suppress_dialogs_until_swap_out_ = false;
988 981
989 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); 982 Send(new FrameHostMsg_SwapOut_ACK(routing_id_));
990 983
991 // Now that all of the cleanup is complete and the browser side is notified, 984 // Now that all of the cleanup is complete and the browser side is notified,
992 // start using the RenderFrameProxy, if one is created. 985 // start using the RenderFrameProxy, if one is created.
993 if (proxy) 986 if (proxy)
994 set_render_frame_proxy(proxy); 987 set_render_frame_proxy(proxy);
995 } 988 }
996 989
997 void RenderFrameImpl::OnBuffersSwapped(
998 const FrameMsg_BuffersSwapped_Params& params) {
999 if (!compositing_helper_.get()) {
1000 compositing_helper_ =
1001 ChildFrameCompositingHelper::CreateCompositingHelperForRenderFrame(
1002 frame_, this, routing_id_);
1003 compositing_helper_->EnableCompositing(true);
1004 }
1005 compositing_helper_->OnBuffersSwapped(
1006 params.size,
1007 params.mailbox,
1008 params.gpu_route_id,
1009 params.gpu_host_id,
1010 render_view_->GetWebView()->deviceScaleFactor());
1011 }
1012
1013 void RenderFrameImpl::OnCompositorFrameSwapped(const IPC::Message& message) {
1014 FrameMsg_CompositorFrameSwapped::Param param;
1015 if (!FrameMsg_CompositorFrameSwapped::Read(&message, &param))
1016 return;
1017 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame);
1018 param.a.frame.AssignTo(frame.get());
1019
1020 if (!compositing_helper_.get()) {
1021 compositing_helper_ =
1022 ChildFrameCompositingHelper::CreateCompositingHelperForRenderFrame(
1023 frame_, this, routing_id_);
1024 compositing_helper_->EnableCompositing(true);
1025 }
1026 compositing_helper_->OnCompositorFrameSwapped(frame.Pass(),
1027 param.a.producing_route_id,
1028 param.a.output_surface_id,
1029 param.a.producing_host_id,
1030 param.a.shared_memory_handle);
1031 }
1032
1033 void RenderFrameImpl::OnContextMenuClosed( 990 void RenderFrameImpl::OnContextMenuClosed(
1034 const CustomContextMenuContext& custom_context) { 991 const CustomContextMenuContext& custom_context) {
1035 if (custom_context.request_id) { 992 if (custom_context.request_id) {
1036 // External request, should be in our map. 993 // External request, should be in our map.
1037 ContextMenuClient* client = 994 ContextMenuClient* client =
1038 pending_context_menus_.Lookup(custom_context.request_id); 995 pending_context_menus_.Lookup(custom_context.request_id);
1039 if (client) { 996 if (client) {
1040 client->OnMenuClosed(custom_context.request_id); 997 client->OnMenuClosed(custom_context.request_id);
1041 pending_context_menus_.Remove(custom_context.request_id); 998 pending_context_menus_.Remove(custom_context.request_id);
1042 } 999 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 std::string error_html; 1226 std::string error_html;
1270 GetContentClient()->renderer()->GetNavigationErrorStrings( 1227 GetContentClient()->renderer()->GetNavigationErrorStrings(
1271 render_view(), frame_, failed_request, error, &error_html, NULL); 1228 render_view(), frame_, failed_request, error, &error_html, NULL);
1272 1229
1273 frame_->loadHTMLString(error_html, 1230 frame_->loadHTMLString(error_html,
1274 GURL(kUnreachableWebDataURL), 1231 GURL(kUnreachableWebDataURL),
1275 error.unreachableURL, 1232 error.unreachableURL,
1276 replace); 1233 replace);
1277 } 1234 }
1278 1235
1279 void RenderFrameImpl::DidCommitCompositorFrame() {
1280 if (compositing_helper_)
1281 compositing_helper_->DidCommitCompositorFrame();
1282 FOR_EACH_OBSERVER(
1283 RenderFrameObserver, observers_, DidCommitCompositorFrame());
1284 }
1285
1286 RenderView* RenderFrameImpl::GetRenderView() { 1236 RenderView* RenderFrameImpl::GetRenderView() {
1287 return render_view_.get(); 1237 return render_view_.get();
1288 } 1238 }
1289 1239
1290 int RenderFrameImpl::GetRoutingID() { 1240 int RenderFrameImpl::GetRoutingID() {
1291 return routing_id_; 1241 return routing_id_;
1292 } 1242 }
1293 1243
1294 blink::WebFrame* RenderFrameImpl::GetWebFrame() { 1244 blink::WebFrame* RenderFrameImpl::GetWebFrame() {
1295 DCHECK(frame_); 1245 DCHECK(frame_);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 const blink::WebURLRequest& request, 1298 const blink::WebURLRequest& request,
1349 blink::WebNavigationPolicy policy) { 1299 blink::WebNavigationPolicy policy) {
1350 DCHECK(!frame_ || frame_ == frame); 1300 DCHECK(!frame_ || frame_ == frame);
1351 loadURLExternally(frame, request, policy, WebString()); 1301 loadURLExternally(frame, request, policy, WebString());
1352 } 1302 }
1353 1303
1354 void RenderFrameImpl::ExecuteJavaScript(const base::string16& javascript) { 1304 void RenderFrameImpl::ExecuteJavaScript(const base::string16& javascript) {
1355 OnJavaScriptExecuteRequest(javascript, 0, false); 1305 OnJavaScriptExecuteRequest(javascript, 0, false);
1356 } 1306 }
1357 1307
1358 void RenderFrameImpl::OnChildFrameProcessGone() {
1359 if (compositing_helper_)
1360 compositing_helper_->ChildFrameGone();
1361 }
1362
1363 // blink::WebFrameClient implementation ---------------------------------------- 1308 // blink::WebFrameClient implementation ----------------------------------------
1364 1309
1365 blink::WebPlugin* RenderFrameImpl::createPlugin( 1310 blink::WebPlugin* RenderFrameImpl::createPlugin(
1366 blink::WebLocalFrame* frame, 1311 blink::WebLocalFrame* frame,
1367 const blink::WebPluginParams& params) { 1312 const blink::WebPluginParams& params) {
1368 DCHECK_EQ(frame_, frame); 1313 DCHECK_EQ(frame_, frame);
1369 blink::WebPlugin* plugin = NULL; 1314 blink::WebPlugin* plugin = NULL;
1370 if (GetContentClient()->renderer()->OverrideCreatePlugin( 1315 if (GetContentClient()->renderer()->OverrideCreatePlugin(
1371 this, frame, params, &plugin)) { 1316 this, frame, params, &plugin)) {
1372 return plugin; 1317 return plugin;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 // NOTE: This function is called on the frame that is being detached and not 1492 // NOTE: This function is called on the frame that is being detached and not
1548 // the parent frame. This is different from createChildFrame() which is 1493 // the parent frame. This is different from createChildFrame() which is
1549 // called on the parent frame. 1494 // called on the parent frame.
1550 CHECK(!is_detaching_); 1495 CHECK(!is_detaching_);
1551 DCHECK(!frame_ || frame_ == frame); 1496 DCHECK(!frame_ || frame_ == frame);
1552 1497
1553 bool is_subframe = !!frame->parent(); 1498 bool is_subframe = !!frame->parent();
1554 1499
1555 Send(new FrameHostMsg_Detach(routing_id_)); 1500 Send(new FrameHostMsg_Detach(routing_id_));
1556 1501
1557 render_view_->UnregisterSwappedOutChildFrame(this);
1558
1559 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be 1502 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be
1560 // sent before setting |is_detaching_| to true. In contrast, Observers 1503 // sent before setting |is_detaching_| to true. In contrast, Observers
1561 // should only be notified afterwards so they cannot call back into here and 1504 // should only be notified afterwards so they cannot call back into here and
1562 // have IPCs fired off. 1505 // have IPCs fired off.
1563 is_detaching_ = true; 1506 is_detaching_ = true;
1564 1507
1565 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 1508 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
1566 FrameDetached(frame)); 1509 FrameDetached(frame));
1567 1510
1568 // We need to clean up subframes by removing them from the map and deleting 1511 // We need to clean up subframes by removing them from the map and deleting
(...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after
3593 3536
3594 #if defined(ENABLE_BROWSER_CDMS) 3537 #if defined(ENABLE_BROWSER_CDMS)
3595 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 3538 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
3596 if (!cdm_manager_) 3539 if (!cdm_manager_)
3597 cdm_manager_ = new RendererCdmManager(this); 3540 cdm_manager_ = new RendererCdmManager(this);
3598 return cdm_manager_; 3541 return cdm_manager_;
3599 } 3542 }
3600 #endif // defined(ENABLE_BROWSER_CDMS) 3543 #endif // defined(ENABLE_BROWSER_CDMS)
3601 3544
3602 } // namespace content 3545 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698