| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_proxy.h" | 5 #include "content/renderer/render_frame_proxy.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 namespace content { | 43 namespace content { |
| 44 | 44 |
| 45 namespace { | 45 namespace { |
| 46 | 46 |
| 47 // Facilitates lookup of RenderFrameProxy by routing_id. | 47 // Facilitates lookup of RenderFrameProxy by routing_id. |
| 48 typedef std::map<int, RenderFrameProxy*> RoutingIDProxyMap; | 48 typedef std::map<int, RenderFrameProxy*> RoutingIDProxyMap; |
| 49 static base::LazyInstance<RoutingIDProxyMap>::DestructorAtExit | 49 static base::LazyInstance<RoutingIDProxyMap>::DestructorAtExit |
| 50 g_routing_id_proxy_map = LAZY_INSTANCE_INITIALIZER; | 50 g_routing_id_proxy_map = LAZY_INSTANCE_INITIALIZER; |
| 51 | 51 |
| 52 // Facilitates lookup of RenderFrameProxy by WebRemoteFrame. | 52 // Facilitates lookup of RenderFrameProxy by WebRemoteFrame. |
| 53 typedef std::map<blink::WebRemoteFrame*, RenderFrameProxy*> FrameMap; | 53 typedef std::map<blink::WebRemoteFrame*, RenderFrameProxy*> FrameProxyMap; |
| 54 base::LazyInstance<FrameMap>::DestructorAtExit g_frame_map = | 54 base::LazyInstance<FrameProxyMap>::DestructorAtExit g_frame_proxy_map = |
| 55 LAZY_INSTANCE_INITIALIZER; | 55 LAZY_INSTANCE_INITIALIZER; |
| 56 | 56 |
| 57 } // namespace | 57 } // namespace |
| 58 | 58 |
| 59 // static | 59 // static |
| 60 RenderFrameProxy* RenderFrameProxy::CreateProxyToReplaceFrame( | 60 RenderFrameProxy* RenderFrameProxy::CreateProxyToReplaceFrame( |
| 61 RenderFrameImpl* frame_to_replace, | 61 RenderFrameImpl* frame_to_replace, |
| 62 int routing_id, | 62 int routing_id, |
| 63 blink::WebTreeScopeType scope) { | 63 blink::WebTreeScopeType scope) { |
| 64 CHECK_NE(routing_id, MSG_ROUTING_NONE); | 64 CHECK_NE(routing_id, MSG_ROUTING_NONE); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 RoutingIDProxyMap* proxies = g_routing_id_proxy_map.Pointer(); | 156 RoutingIDProxyMap* proxies = g_routing_id_proxy_map.Pointer(); |
| 157 RoutingIDProxyMap::iterator it = proxies->find(routing_id); | 157 RoutingIDProxyMap::iterator it = proxies->find(routing_id); |
| 158 return it == proxies->end() ? NULL : it->second; | 158 return it == proxies->end() ? NULL : it->second; |
| 159 } | 159 } |
| 160 | 160 |
| 161 // static | 161 // static |
| 162 RenderFrameProxy* RenderFrameProxy::FromWebFrame( | 162 RenderFrameProxy* RenderFrameProxy::FromWebFrame( |
| 163 blink::WebRemoteFrame* web_frame) { | 163 blink::WebRemoteFrame* web_frame) { |
| 164 // TODO(dcheng): Turn this into a DCHECK() if it doesn't crash on canary. | 164 // TODO(dcheng): Turn this into a DCHECK() if it doesn't crash on canary. |
| 165 CHECK(web_frame); | 165 CHECK(web_frame); |
| 166 FrameMap::iterator iter = g_frame_map.Get().find(web_frame); | 166 FrameProxyMap::iterator iter = g_frame_proxy_map.Get().find(web_frame); |
| 167 if (iter != g_frame_map.Get().end()) { | 167 if (iter != g_frame_proxy_map.Get().end()) { |
| 168 RenderFrameProxy* proxy = iter->second; | 168 RenderFrameProxy* proxy = iter->second; |
| 169 DCHECK_EQ(web_frame, proxy->web_frame()); | 169 DCHECK_EQ(web_frame, proxy->web_frame()); |
| 170 return proxy; | 170 return proxy; |
| 171 } | 171 } |
| 172 // Reaching this is not expected: this implies that the |web_frame| in | 172 // Reaching this is not expected: this implies that the |web_frame| in |
| 173 // question is not managed by the content API, or the associated | 173 // question is not managed by the content API, or the associated |
| 174 // RenderFrameProxy is already deleted--in which case, it's not safe to touch | 174 // RenderFrameProxy is already deleted--in which case, it's not safe to touch |
| 175 // |web_frame|. | 175 // |web_frame|. |
| 176 NOTREACHED(); | 176 NOTREACHED(); |
| 177 return NULL; | 177 return NULL; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 203 CHECK(web_frame); | 203 CHECK(web_frame); |
| 204 CHECK(render_view); | 204 CHECK(render_view); |
| 205 CHECK(render_widget); | 205 CHECK(render_widget); |
| 206 | 206 |
| 207 web_frame_ = web_frame; | 207 web_frame_ = web_frame; |
| 208 render_view_ = render_view; | 208 render_view_ = render_view; |
| 209 render_widget_ = render_widget; | 209 render_widget_ = render_widget; |
| 210 | 210 |
| 211 render_widget_->RegisterRenderFrameProxy(this); | 211 render_widget_->RegisterRenderFrameProxy(this); |
| 212 | 212 |
| 213 std::pair<FrameMap::iterator, bool> result = | 213 std::pair<FrameProxyMap::iterator, bool> result = |
| 214 g_frame_map.Get().insert(std::make_pair(web_frame_, this)); | 214 g_frame_proxy_map.Get().insert(std::make_pair(web_frame_, this)); |
| 215 CHECK(result.second) << "Inserted a duplicate item."; | 215 CHECK(result.second) << "Inserted a duplicate item."; |
| 216 | 216 |
| 217 const base::CommandLine& command_line = | 217 const base::CommandLine& command_line = |
| 218 *base::CommandLine::ForCurrentProcess(); | 218 *base::CommandLine::ForCurrentProcess(); |
| 219 enable_surface_synchronization_ = | 219 enable_surface_synchronization_ = |
| 220 command_line.HasSwitch(switches::kEnableSurfaceSynchronization); | 220 command_line.HasSwitch(switches::kEnableSurfaceSynchronization); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void RenderFrameProxy::ResendFrameRects() { | 223 void RenderFrameProxy::ResendFrameRects() { |
| 224 // Reset |frame_rect_| in order to allocate a new viz::LocalSurfaceId. | 224 // Reset |frame_rect_| in order to allocate a new viz::LocalSurfaceId. |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 // |provisional_frame| should always exist. If it was deleted via | 475 // |provisional_frame| should always exist. If it was deleted via |
| 476 // FrameMsg_Delete right before this proxy was removed, | 476 // FrameMsg_Delete right before this proxy was removed, |
| 477 // RenderFrameImpl::frameDetached would've cleared this proxy's | 477 // RenderFrameImpl::frameDetached would've cleared this proxy's |
| 478 // |provisional_frame_routing_id_| and we wouldn't get here. | 478 // |provisional_frame_routing_id_| and we wouldn't get here. |
| 479 CHECK(provisional_frame); | 479 CHECK(provisional_frame); |
| 480 provisional_frame->GetWebFrame()->Detach(); | 480 provisional_frame->GetWebFrame()->Detach(); |
| 481 } | 481 } |
| 482 | 482 |
| 483 // Remove the entry in the WebFrame->RenderFrameProxy map, as the |web_frame_| | 483 // Remove the entry in the WebFrame->RenderFrameProxy map, as the |web_frame_| |
| 484 // is no longer valid. | 484 // is no longer valid. |
| 485 FrameMap::iterator it = g_frame_map.Get().find(web_frame_); | 485 FrameProxyMap::iterator it = g_frame_proxy_map.Get().find(web_frame_); |
| 486 CHECK(it != g_frame_map.Get().end()); | 486 CHECK(it != g_frame_proxy_map.Get().end()); |
| 487 CHECK_EQ(it->second, this); | 487 CHECK_EQ(it->second, this); |
| 488 g_frame_map.Get().erase(it); | 488 g_frame_proxy_map.Get().erase(it); |
| 489 | 489 |
| 490 web_frame_ = nullptr; | 490 web_frame_ = nullptr; |
| 491 | 491 |
| 492 delete this; | 492 delete this; |
| 493 } | 493 } |
| 494 | 494 |
| 495 void RenderFrameProxy::ForwardPostMessage( | 495 void RenderFrameProxy::ForwardPostMessage( |
| 496 blink::WebLocalFrame* source_frame, | 496 blink::WebLocalFrame* source_frame, |
| 497 blink::WebRemoteFrame* target_frame, | 497 blink::WebRemoteFrame* target_frame, |
| 498 blink::WebSecurityOrigin target_origin, | 498 blink::WebSecurityOrigin target_origin, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 blink::WebLocalFrame* source) { | 600 blink::WebLocalFrame* source) { |
| 601 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID(); | 601 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID(); |
| 602 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id)); | 602 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id)); |
| 603 } | 603 } |
| 604 | 604 |
| 605 void RenderFrameProxy::FrameFocused() { | 605 void RenderFrameProxy::FrameFocused() { |
| 606 Send(new FrameHostMsg_FrameFocused(routing_id_)); | 606 Send(new FrameHostMsg_FrameFocused(routing_id_)); |
| 607 } | 607 } |
| 608 | 608 |
| 609 } // namespace | 609 } // namespace |
| OLD | NEW |