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

Side by Side Diff: content/browser/frame_host/frame_tree.cc

Issue 1157563002: Revert of Add ref-count on RenderViewHost for each new RenderFrameProxyHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
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/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
292 } 292 }
293 293
294 RenderViewHostImpl* FrameTree::GetRenderViewHost(SiteInstance* site_instance) { 294 RenderViewHostImpl* FrameTree::GetRenderViewHost(SiteInstance* site_instance) {
295 RenderViewHostMap::iterator iter = 295 RenderViewHostMap::iterator iter =
296 render_view_host_map_.find(site_instance->GetId()); 296 render_view_host_map_.find(site_instance->GetId());
297 if (iter == render_view_host_map_.end()) 297 if (iter == render_view_host_map_.end())
298 return nullptr; 298 return nullptr;
299 return iter->second; 299 return iter->second;
300 } 300 }
301 301
302 void FrameTree::AddRenderViewHostRef( 302 void FrameTree::RegisterRenderFrameHost(
303 RenderViewHostImpl* render_view_host) { 303 RenderFrameHostImpl* render_frame_host) {
304 SiteInstance* site_instance = render_view_host->GetSiteInstance(); 304 SiteInstance* site_instance = render_frame_host->GetSiteInstance();
305 RenderViewHostMap::iterator iter = 305 RenderViewHostMap::iterator iter =
306 render_view_host_map_.find(site_instance->GetId()); 306 render_view_host_map_.find(site_instance->GetId());
307 CHECK(iter != render_view_host_map_.end()); 307 CHECK(iter != render_view_host_map_.end());
308 CHECK(iter->second == render_view_host);
309 308
310 iter->second->increment_ref_count(); 309 iter->second->increment_ref_count();
311 } 310 }
312 311
313 void FrameTree::ReleaseRenderViewHostRef( 312 void FrameTree::UnregisterRenderFrameHost(
314 RenderViewHostImpl* render_view_host) { 313 RenderFrameHostImpl* render_frame_host) {
315 SiteInstance* site_instance = render_view_host->GetSiteInstance(); 314 SiteInstance* site_instance = render_frame_host->GetSiteInstance();
316 int32 site_instance_id = site_instance->GetId(); 315 int32 site_instance_id = site_instance->GetId();
317 RenderViewHostMap::iterator iter = 316 RenderViewHostMap::iterator iter =
318 render_view_host_map_.find(site_instance_id); 317 render_view_host_map_.find(site_instance_id);
319 if (iter != render_view_host_map_.end() && iter->second == render_view_host) { 318 if (iter != render_view_host_map_.end() &&
319 iter->second == render_frame_host->render_view_host()) {
320 // Decrement the refcount and shutdown the RenderViewHost if no one else is 320 // Decrement the refcount and shutdown the RenderViewHost if no one else is
321 // using it. 321 // using it.
322 CHECK_GT(iter->second->ref_count(), 0); 322 CHECK_GT(iter->second->ref_count(), 0);
323 iter->second->decrement_ref_count(); 323 iter->second->decrement_ref_count();
324 if (iter->second->ref_count() == 0) { 324 if (iter->second->ref_count() == 0) {
325 iter->second->Shutdown(); 325 iter->second->Shutdown();
326 render_view_host_map_.erase(iter); 326 render_view_host_map_.erase(iter);
327 } 327 }
328 } else { 328 } else {
329 // The RenderViewHost should be in the list of RenderViewHosts pending 329 // The RenderViewHost should be in the list of RenderViewHosts pending
330 // shutdown. 330 // shutdown.
331 bool render_view_host_found = false; 331 bool render_view_host_found = false;
332 std::pair<RenderViewHostMultiMap::iterator, 332 std::pair<RenderViewHostMultiMap::iterator,
333 RenderViewHostMultiMap::iterator> result = 333 RenderViewHostMultiMap::iterator> result =
334 render_view_host_pending_shutdown_map_.equal_range(site_instance_id); 334 render_view_host_pending_shutdown_map_.equal_range(site_instance_id);
335 for (RenderViewHostMultiMap::iterator multi_iter = result.first; 335 for (RenderViewHostMultiMap::iterator multi_iter = result.first;
336 multi_iter != result.second; 336 multi_iter != result.second;
337 ++multi_iter) { 337 ++multi_iter) {
338 if (multi_iter->second != render_view_host) 338 if (multi_iter->second != render_frame_host->render_view_host())
339 continue; 339 continue;
340 render_view_host_found = true; 340 render_view_host_found = true;
341 RenderViewHostImpl* rvh = multi_iter->second;
341 // Decrement the refcount and shutdown the RenderViewHost if no one else 342 // Decrement the refcount and shutdown the RenderViewHost if no one else
342 // is using it. 343 // is using it.
343 CHECK_GT(render_view_host->ref_count(), 0); 344 CHECK_GT(rvh->ref_count(), 0);
344 render_view_host->decrement_ref_count(); 345 rvh->decrement_ref_count();
345 if (render_view_host->ref_count() == 0) { 346 if (rvh->ref_count() == 0) {
346 render_view_host->Shutdown(); 347 rvh->Shutdown();
347 render_view_host_pending_shutdown_map_.erase(multi_iter); 348 render_view_host_pending_shutdown_map_.erase(multi_iter);
348 } 349 }
349 break; 350 break;
350 } 351 }
351 CHECK(render_view_host_found); 352 CHECK(render_view_host_found);
352 } 353 }
353 } 354 }
354 355
355 void FrameTree::FrameRemoved(FrameTreeNode* frame) { 356 void FrameTree::FrameRemoved(FrameTreeNode* frame) {
356 if (frame->frame_tree_node_id() == focused_frame_tree_node_id_) 357 if (frame->frame_tree_node_id() == focused_frame_tree_node_id_)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 load_progress_ = 0.0; 389 load_progress_ = 0.0;
389 } 390 }
390 391
391 bool FrameTree::IsLoading() { 392 bool FrameTree::IsLoading() {
392 bool is_loading = false; 393 bool is_loading = false;
393 ForEach(base::Bind(&IsNodeLoading, &is_loading)); 394 ForEach(base::Bind(&IsNodeLoading, &is_loading));
394 return is_loading; 395 return is_loading;
395 } 396 }
396 397
397 } // namespace content 398 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree.h ('k') | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698