OLD | NEW |
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/browser/frame_host/frame_tree.h" | 5 #include "content/browser/frame_host/frame_tree.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include <queue> | 9 #include <queue> |
8 #include <utility> | 10 #include <utility> |
9 | 11 |
10 #include "base/bind.h" | 12 #include "base/bind.h" |
11 #include "base/callback.h" | 13 #include "base/callback.h" |
12 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
13 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
14 #include "content/browser/frame_host/frame_tree_node.h" | 16 #include "content/browser/frame_host/frame_tree_node.h" |
15 #include "content/browser/frame_host/navigator.h" | 17 #include "content/browser/frame_host/navigator.h" |
16 #include "content/browser/frame_host/render_frame_host_factory.h" | 18 #include "content/browser/frame_host/render_frame_host_factory.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 | 311 |
310 focused_frame_tree_node_id_ = node->frame_tree_node_id(); | 312 focused_frame_tree_node_id_ = node->frame_tree_node_id(); |
311 node->DidFocus(); | 313 node->DidFocus(); |
312 } | 314 } |
313 | 315 |
314 void FrameTree::SetFrameRemoveListener( | 316 void FrameTree::SetFrameRemoveListener( |
315 const base::Callback<void(RenderFrameHost*)>& on_frame_removed) { | 317 const base::Callback<void(RenderFrameHost*)>& on_frame_removed) { |
316 on_frame_removed_ = on_frame_removed; | 318 on_frame_removed_ = on_frame_removed; |
317 } | 319 } |
318 | 320 |
319 RenderViewHostImpl* FrameTree::CreateRenderViewHost(SiteInstance* site_instance, | 321 RenderViewHostImpl* FrameTree::CreateRenderViewHost( |
320 int32 routing_id, | 322 SiteInstance* site_instance, |
321 int32 main_frame_routing_id, | 323 int32_t routing_id, |
322 bool swapped_out, | 324 int32_t main_frame_routing_id, |
323 bool hidden) { | 325 bool swapped_out, |
| 326 bool hidden) { |
324 RenderViewHostMap::iterator iter = | 327 RenderViewHostMap::iterator iter = |
325 render_view_host_map_.find(site_instance->GetId()); | 328 render_view_host_map_.find(site_instance->GetId()); |
326 if (iter != render_view_host_map_.end()) { | 329 if (iter != render_view_host_map_.end()) { |
327 // If a RenderViewHost is pending deletion for this |site_instance|, it | 330 // If a RenderViewHost is pending deletion for this |site_instance|, it |
328 // shouldn't be reused, so put it in the map of RenderViewHosts pending | 331 // shouldn't be reused, so put it in the map of RenderViewHosts pending |
329 // shutdown. Otherwise, return the existing RenderViewHost for the | 332 // shutdown. Otherwise, return the existing RenderViewHost for the |
330 // SiteInstance. Note that if swapped-out is forbidden, the | 333 // SiteInstance. Note that if swapped-out is forbidden, the |
331 // RenderViewHost's main frame has already been cleared, so we cannot rely | 334 // RenderViewHost's main frame has already been cleared, so we cannot rely |
332 // on checking whether the main frame is pending deletion. | 335 // on checking whether the main frame is pending deletion. |
333 if (iter->second->is_pending_deletion()) { | 336 if (iter->second->is_pending_deletion()) { |
(...skipping 26 matching lines...) Expand all Loading... |
360 RenderViewHostMap::iterator iter = | 363 RenderViewHostMap::iterator iter = |
361 render_view_host_map_.find(site_instance->GetId()); | 364 render_view_host_map_.find(site_instance->GetId()); |
362 CHECK(iter != render_view_host_map_.end()); | 365 CHECK(iter != render_view_host_map_.end()); |
363 CHECK(iter->second == render_view_host); | 366 CHECK(iter->second == render_view_host); |
364 | 367 |
365 iter->second->increment_ref_count(); | 368 iter->second->increment_ref_count(); |
366 } | 369 } |
367 | 370 |
368 void FrameTree::ReleaseRenderViewHostRef(RenderViewHostImpl* render_view_host) { | 371 void FrameTree::ReleaseRenderViewHostRef(RenderViewHostImpl* render_view_host) { |
369 SiteInstance* site_instance = render_view_host->GetSiteInstance(); | 372 SiteInstance* site_instance = render_view_host->GetSiteInstance(); |
370 int32 site_instance_id = site_instance->GetId(); | 373 int32_t site_instance_id = site_instance->GetId(); |
371 RenderViewHostMap::iterator iter = | 374 RenderViewHostMap::iterator iter = |
372 render_view_host_map_.find(site_instance_id); | 375 render_view_host_map_.find(site_instance_id); |
373 if (iter != render_view_host_map_.end() && iter->second == render_view_host) { | 376 if (iter != render_view_host_map_.end() && iter->second == render_view_host) { |
374 // Decrement the refcount and shutdown the RenderViewHost if no one else is | 377 // Decrement the refcount and shutdown the RenderViewHost if no one else is |
375 // using it. | 378 // using it. |
376 CHECK_GT(iter->second->ref_count(), 0); | 379 CHECK_GT(iter->second->ref_count(), 0); |
377 iter->second->decrement_ref_count(); | 380 iter->second->decrement_ref_count(); |
378 if (iter->second->ref_count() == 0) { | 381 if (iter->second->ref_count() == 0) { |
379 iter->second->ShutdownAndDestroy(); | 382 iter->second->ShutdownAndDestroy(); |
380 render_view_host_map_.erase(iter); | 383 render_view_host_map_.erase(iter); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 // This is only used to set page-level focus in cross-process subframes, and | 470 // This is only used to set page-level focus in cross-process subframes, and |
468 // requests to set focus in main frame's SiteInstance are ignored. | 471 // requests to set focus in main frame's SiteInstance are ignored. |
469 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { | 472 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { |
470 RenderFrameProxyHost* proxy = | 473 RenderFrameProxyHost* proxy = |
471 root_manager->GetRenderFrameProxyHost(instance); | 474 root_manager->GetRenderFrameProxyHost(instance); |
472 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); | 475 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); |
473 } | 476 } |
474 } | 477 } |
475 | 478 |
476 } // namespace content | 479 } // namespace content |
OLD | NEW |