| 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 30 matching lines...) Expand all Loading... |
| 41 namespace content { | 41 namespace content { |
| 42 | 42 |
| 43 namespace { | 43 namespace { |
| 44 | 44 |
| 45 // Facilitates lookup of RenderFrameProxy by routing_id. | 45 // Facilitates lookup of RenderFrameProxy by routing_id. |
| 46 typedef std::map<int, RenderFrameProxy*> RoutingIDProxyMap; | 46 typedef std::map<int, RenderFrameProxy*> RoutingIDProxyMap; |
| 47 static base::LazyInstance<RoutingIDProxyMap>::DestructorAtExit | 47 static base::LazyInstance<RoutingIDProxyMap>::DestructorAtExit |
| 48 g_routing_id_proxy_map = LAZY_INSTANCE_INITIALIZER; | 48 g_routing_id_proxy_map = LAZY_INSTANCE_INITIALIZER; |
| 49 | 49 |
| 50 // Facilitates lookup of RenderFrameProxy by WebRemoteFrame. | 50 // Facilitates lookup of RenderFrameProxy by WebRemoteFrame. |
| 51 typedef std::map<blink::WebRemoteFrame*, RenderFrameProxy*> FrameMap; | 51 typedef std::map<blink::WebRemoteFrame*, RenderFrameProxy*> FrameProxyMap; |
| 52 base::LazyInstance<FrameMap>::DestructorAtExit g_frame_map = | 52 base::LazyInstance<FrameProxyMap>::DestructorAtExit g_frame_proxy_map = |
| 53 LAZY_INSTANCE_INITIALIZER; | 53 LAZY_INSTANCE_INITIALIZER; |
| 54 | 54 |
| 55 } // namespace | 55 } // namespace |
| 56 | 56 |
| 57 // static | 57 // static |
| 58 RenderFrameProxy* RenderFrameProxy::CreateProxyToReplaceFrame( | 58 RenderFrameProxy* RenderFrameProxy::CreateProxyToReplaceFrame( |
| 59 RenderFrameImpl* frame_to_replace, | 59 RenderFrameImpl* frame_to_replace, |
| 60 int routing_id, | 60 int routing_id, |
| 61 blink::WebTreeScopeType scope) { | 61 blink::WebTreeScopeType scope) { |
| 62 CHECK_NE(routing_id, MSG_ROUTING_NONE); | 62 CHECK_NE(routing_id, MSG_ROUTING_NONE); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 RoutingIDProxyMap* proxies = g_routing_id_proxy_map.Pointer(); | 154 RoutingIDProxyMap* proxies = g_routing_id_proxy_map.Pointer(); |
| 155 RoutingIDProxyMap::iterator it = proxies->find(routing_id); | 155 RoutingIDProxyMap::iterator it = proxies->find(routing_id); |
| 156 return it == proxies->end() ? NULL : it->second; | 156 return it == proxies->end() ? NULL : it->second; |
| 157 } | 157 } |
| 158 | 158 |
| 159 // static | 159 // static |
| 160 RenderFrameProxy* RenderFrameProxy::FromWebFrame( | 160 RenderFrameProxy* RenderFrameProxy::FromWebFrame( |
| 161 blink::WebRemoteFrame* web_frame) { | 161 blink::WebRemoteFrame* web_frame) { |
| 162 // TODO(dcheng): Turn this into a DCHECK() if it doesn't crash on canary. | 162 // TODO(dcheng): Turn this into a DCHECK() if it doesn't crash on canary. |
| 163 CHECK(web_frame); | 163 CHECK(web_frame); |
| 164 FrameMap::iterator iter = g_frame_map.Get().find(web_frame); | 164 FrameProxyMap::iterator iter = g_frame_proxy_map.Get().find(web_frame); |
| 165 if (iter != g_frame_map.Get().end()) { | 165 if (iter != g_frame_proxy_map.Get().end()) { |
| 166 RenderFrameProxy* proxy = iter->second; | 166 RenderFrameProxy* proxy = iter->second; |
| 167 DCHECK_EQ(web_frame, proxy->web_frame()); | 167 DCHECK_EQ(web_frame, proxy->web_frame()); |
| 168 return proxy; | 168 return proxy; |
| 169 } | 169 } |
| 170 // Reaching this is not expected: this implies that the |web_frame| in | 170 // Reaching this is not expected: this implies that the |web_frame| in |
| 171 // question is not managed by the content API, or the associated | 171 // question is not managed by the content API, or the associated |
| 172 // RenderFrameProxy is already deleted--in which case, it's not safe to touch | 172 // RenderFrameProxy is already deleted--in which case, it's not safe to touch |
| 173 // |web_frame|. | 173 // |web_frame|. |
| 174 NOTREACHED(); | 174 NOTREACHED(); |
| 175 return NULL; | 175 return NULL; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 201 CHECK(web_frame); | 201 CHECK(web_frame); |
| 202 CHECK(render_view); | 202 CHECK(render_view); |
| 203 CHECK(render_widget); | 203 CHECK(render_widget); |
| 204 | 204 |
| 205 web_frame_ = web_frame; | 205 web_frame_ = web_frame; |
| 206 render_view_ = render_view; | 206 render_view_ = render_view; |
| 207 render_widget_ = render_widget; | 207 render_widget_ = render_widget; |
| 208 | 208 |
| 209 render_widget_->RegisterRenderFrameProxy(this); | 209 render_widget_->RegisterRenderFrameProxy(this); |
| 210 | 210 |
| 211 std::pair<FrameMap::iterator, bool> result = | 211 std::pair<FrameProxyMap::iterator, bool> result = |
| 212 g_frame_map.Get().insert(std::make_pair(web_frame_, this)); | 212 g_frame_proxy_map.Get().insert(std::make_pair(web_frame_, this)); |
| 213 CHECK(result.second) << "Inserted a duplicate item."; | 213 CHECK(result.second) << "Inserted a duplicate item."; |
| 214 } | 214 } |
| 215 | 215 |
| 216 void RenderFrameProxy::WillBeginCompositorFrame() { | 216 void RenderFrameProxy::WillBeginCompositorFrame() { |
| 217 if (compositing_helper_) { | 217 if (compositing_helper_) { |
| 218 FrameHostMsg_HittestData_Params params; | 218 FrameHostMsg_HittestData_Params params; |
| 219 params.surface_id = compositing_helper_->surface_id(); | 219 params.surface_id = compositing_helper_->surface_id(); |
| 220 params.ignored_for_hittest = web_frame_->IsIgnoredForHitTest(); | 220 params.ignored_for_hittest = web_frame_->IsIgnoredForHitTest(); |
| 221 render_widget_->QueueMessage( | 221 render_widget_->QueueMessage( |
| 222 new FrameHostMsg_HittestData(render_widget_->routing_id(), params), | 222 new FrameHostMsg_HittestData(render_widget_->routing_id(), params), |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 // |provisional_frame| should always exist. If it was deleted via | 436 // |provisional_frame| should always exist. If it was deleted via |
| 437 // FrameMsg_Delete right before this proxy was removed, | 437 // FrameMsg_Delete right before this proxy was removed, |
| 438 // RenderFrameImpl::frameDetached would've cleared this proxy's | 438 // RenderFrameImpl::frameDetached would've cleared this proxy's |
| 439 // |provisional_frame_routing_id_| and we wouldn't get here. | 439 // |provisional_frame_routing_id_| and we wouldn't get here. |
| 440 CHECK(provisional_frame); | 440 CHECK(provisional_frame); |
| 441 provisional_frame->GetWebFrame()->Detach(); | 441 provisional_frame->GetWebFrame()->Detach(); |
| 442 } | 442 } |
| 443 | 443 |
| 444 // Remove the entry in the WebFrame->RenderFrameProxy map, as the |web_frame_| | 444 // Remove the entry in the WebFrame->RenderFrameProxy map, as the |web_frame_| |
| 445 // is no longer valid. | 445 // is no longer valid. |
| 446 FrameMap::iterator it = g_frame_map.Get().find(web_frame_); | 446 FrameProxyMap::iterator it = g_frame_proxy_map.Get().find(web_frame_); |
| 447 CHECK(it != g_frame_map.Get().end()); | 447 CHECK(it != g_frame_proxy_map.Get().end()); |
| 448 CHECK_EQ(it->second, this); | 448 CHECK_EQ(it->second, this); |
| 449 g_frame_map.Get().erase(it); | 449 g_frame_proxy_map.Get().erase(it); |
| 450 | 450 |
| 451 web_frame_ = nullptr; | 451 web_frame_ = nullptr; |
| 452 | 452 |
| 453 delete this; | 453 delete this; |
| 454 } | 454 } |
| 455 | 455 |
| 456 void RenderFrameProxy::ForwardPostMessage( | 456 void RenderFrameProxy::ForwardPostMessage( |
| 457 blink::WebLocalFrame* source_frame, | 457 blink::WebLocalFrame* source_frame, |
| 458 blink::WebRemoteFrame* target_frame, | 458 blink::WebRemoteFrame* target_frame, |
| 459 blink::WebSecurityOrigin target_origin, | 459 blink::WebSecurityOrigin target_origin, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 blink::WebLocalFrame* source) { | 544 blink::WebLocalFrame* source) { |
| 545 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID(); | 545 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID(); |
| 546 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id)); | 546 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id)); |
| 547 } | 547 } |
| 548 | 548 |
| 549 void RenderFrameProxy::FrameFocused() { | 549 void RenderFrameProxy::FrameFocused() { |
| 550 Send(new FrameHostMsg_FrameFocused(routing_id_)); | 550 Send(new FrameHostMsg_FrameFocused(routing_id_)); |
| 551 } | 551 } |
| 552 | 552 |
| 553 } // namespace | 553 } // namespace |
| OLD | NEW |