| 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 <queue> | 7 #include <queue> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 292 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 293 RenderViewHostFactory::Create(site_instance, | 293 RenderViewHostFactory::Create(site_instance, |
| 294 render_view_delegate_, | 294 render_view_delegate_, |
| 295 render_widget_delegate_, | 295 render_widget_delegate_, |
| 296 routing_id, | 296 routing_id, |
| 297 main_frame_routing_id, | 297 main_frame_routing_id, |
| 298 swapped_out, | 298 swapped_out, |
| 299 hidden)); | 299 hidden)); |
| 300 | 300 |
| 301 render_view_host_map_[site_instance->GetId()] = rvh; | 301 render_view_host_map_[site_instance->GetId()] = rvh; |
| 302 LOG(ERROR) << "FT[" << this << "]::CreateRenderViewHost: " |
| 303 << " created " << rvh << " with refcount:" << rvh->ref_count(); |
| 302 return rvh; | 304 return rvh; |
| 303 } | 305 } |
| 304 | 306 |
| 305 RenderViewHostImpl* FrameTree::GetRenderViewHost(SiteInstance* site_instance) { | 307 RenderViewHostImpl* FrameTree::GetRenderViewHost(SiteInstance* site_instance) { |
| 306 RenderViewHostMap::iterator iter = | 308 RenderViewHostMap::iterator iter = |
| 307 render_view_host_map_.find(site_instance->GetId()); | 309 render_view_host_map_.find(site_instance->GetId()); |
| 308 if (iter == render_view_host_map_.end()) | 310 if (iter == render_view_host_map_.end()) { |
| 311 LOG(ERROR) << "FT[" << this << "]::GetRenderViewHost: " |
| 312 << " could not find RVH for site:" |
| 313 << site_instance->GetId() << "," << site_instance->GetSiteURL(); |
| 309 return nullptr; | 314 return nullptr; |
| 315 } |
| 310 return iter->second; | 316 return iter->second; |
| 311 } | 317 } |
| 312 | 318 |
| 313 void FrameTree::AddRenderViewHostRef(RenderViewHostImpl* render_view_host) { | 319 void FrameTree::AddRenderViewHostRef(RenderViewHostImpl* render_view_host) { |
| 314 SiteInstance* site_instance = render_view_host->GetSiteInstance(); | 320 SiteInstance* site_instance = render_view_host->GetSiteInstance(); |
| 315 RenderViewHostMap::iterator iter = | 321 RenderViewHostMap::iterator iter = |
| 316 render_view_host_map_.find(site_instance->GetId()); | 322 render_view_host_map_.find(site_instance->GetId()); |
| 317 CHECK(iter != render_view_host_map_.end()); | 323 CHECK(iter != render_view_host_map_.end()); |
| 318 CHECK(iter->second == render_view_host); | 324 CHECK(iter->second == render_view_host); |
| 319 | 325 |
| 320 iter->second->increment_ref_count(); | 326 iter->second->increment_ref_count(); |
| 327 LOG(ERROR) << "FT[" << this << "]::AddRenderViewHostRef: " |
| 328 << iter->second << "|" << iter->second->GetSiteInstance()->GetSiteURL() |
| 329 << " up to " << iter->second->ref_count(); |
| 321 } | 330 } |
| 322 | 331 |
| 323 void FrameTree::ReleaseRenderViewHostRef(RenderViewHostImpl* render_view_host) { | 332 void FrameTree::ReleaseRenderViewHostRef(RenderViewHostImpl* render_view_host) { |
| 324 SiteInstance* site_instance = render_view_host->GetSiteInstance(); | 333 SiteInstance* site_instance = render_view_host->GetSiteInstance(); |
| 325 int32 site_instance_id = site_instance->GetId(); | 334 int32 site_instance_id = site_instance->GetId(); |
| 326 RenderViewHostMap::iterator iter = | 335 RenderViewHostMap::iterator iter = |
| 327 render_view_host_map_.find(site_instance_id); | 336 render_view_host_map_.find(site_instance_id); |
| 328 if (iter != render_view_host_map_.end() && iter->second == render_view_host) { | 337 if (iter != render_view_host_map_.end() && iter->second == render_view_host) { |
| 329 // Decrement the refcount and shutdown the RenderViewHost if no one else is | 338 // Decrement the refcount and shutdown the RenderViewHost if no one else is |
| 330 // using it. | 339 // using it. |
| 331 CHECK_GT(iter->second->ref_count(), 0); | 340 CHECK_GT(iter->second->ref_count(), 0); |
| 332 iter->second->decrement_ref_count(); | 341 iter->second->decrement_ref_count(); |
| 342 LOG(ERROR) << "FT[" << this << "]::ReleaseRenderViewHostRef: " |
| 343 << iter->second << "|" << iter->second->GetSiteInstance()->GetSiteURL() |
| 344 << " down to " << iter->second->ref_count(); |
| 333 if (iter->second->ref_count() == 0) { | 345 if (iter->second->ref_count() == 0) { |
| 334 iter->second->Shutdown(); | 346 iter->second->Shutdown(); |
| 335 render_view_host_map_.erase(iter); | 347 render_view_host_map_.erase(iter); |
| 336 } | 348 } |
| 337 } else { | 349 } else { |
| 350 LOG(ERROR) << "FT[" << this << "]::ReleaseRenderViewHostRef: " |
| 351 << site_instance_id << " not found in map:" << (iter != render_view_host_m
ap_.end()); |
| 352 |
| 338 // The RenderViewHost should be in the list of RenderViewHosts pending | 353 // The RenderViewHost should be in the list of RenderViewHosts pending |
| 339 // shutdown. | 354 // shutdown. |
| 340 bool render_view_host_found = false; | 355 bool render_view_host_found = false; |
| 341 std::pair<RenderViewHostMultiMap::iterator, | 356 std::pair<RenderViewHostMultiMap::iterator, |
| 342 RenderViewHostMultiMap::iterator> result = | 357 RenderViewHostMultiMap::iterator> result = |
| 343 render_view_host_pending_shutdown_map_.equal_range(site_instance_id); | 358 render_view_host_pending_shutdown_map_.equal_range(site_instance_id); |
| 344 for (RenderViewHostMultiMap::iterator multi_iter = result.first; | 359 for (RenderViewHostMultiMap::iterator multi_iter = result.first; |
| 345 multi_iter != result.second; | 360 multi_iter != result.second; |
| 346 ++multi_iter) { | 361 ++multi_iter) { |
| 347 if (multi_iter->second != render_view_host) | 362 if (multi_iter->second != render_view_host) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 load_progress_ = 0.0; | 412 load_progress_ = 0.0; |
| 398 } | 413 } |
| 399 | 414 |
| 400 bool FrameTree::IsLoading() { | 415 bool FrameTree::IsLoading() { |
| 401 bool is_loading = false; | 416 bool is_loading = false; |
| 402 ForEach(base::Bind(&IsNodeLoading, &is_loading)); | 417 ForEach(base::Bind(&IsNodeLoading, &is_loading)); |
| 403 return is_loading; | 418 return is_loading; |
| 404 } | 419 } |
| 405 | 420 |
| 406 } // namespace content | 421 } // namespace content |
| OLD | NEW |