Skip to content

Commit

Permalink
Fix 2 access violation in resource_coordinator.
Browse files Browse the repository at this point in the history
Bug: 818454
Change-Id: I77f6ea60f38ad8956d7f7e042c57202f3f41a07c
Reviewed-on: https://chromium-review.googlesource.com/951749
Commit-Queue: Sébastien Marchand <[email protected]>
Reviewed-by: Chris Hamilton <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#541230}(cherry picked from commit 182f838)
Reviewed-on: https://chromium-review.googlesource.com/953366
Reviewed-by: Sébastien Marchand <[email protected]>
Cr-Commit-Position: refs/branch-heads/3359@{#73}
Cr-Branched-From: 66afc5e-refs/heads/master@{#540276}
  • Loading branch information
sebmarchand committed Mar 7, 2018
1 parent b7e5331 commit 74361db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ void TabLifecycleUnitSource::TabChangedAt(content::WebContents* contents,
if (change_type != TabChangeType::kAll)
return;
auto it = tabs_.find(contents);
DCHECK(it != tabs_.end());
// The WebContents destructor might cause this function to be called, at this
// point TabClosingAt has already been called and so this WebContents has
// been removed from |tabs_|.
if (it == tabs_.end())
return;
TabLifecycleUnit* lifecycle_unit = it->second.get();
lifecycle_unit->SetRecentlyAudible(contents->WasRecentlyAudible());
}
Expand Down
8 changes: 7 additions & 1 deletion chrome/browser/resource_coordinator/tab_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,13 @@ void TabManager::PurgeBackgroundedTabsIfNeeded() {
DCHECK(tab_lifecycle_unit_external);
content::WebContents* content =
tab_lifecycle_unit_external->GetWebContents();
DCHECK(content);
// TODO(fdoray): Check if TabLifecycleUnitSource should override
// WebContentsObserver::WebContentsDestroyed() as in some situations a
// WebContents might get destroyed without a call to
// TabStripModelObserver::TabClosingAt, in this case we'll have a
// TabLifecycleUnitExternal that points to a null WebContents.
if (content == nullptr)
return;

content::RenderProcessHost* render_process_host =
content->GetMainFrame()->GetProcess();
Expand Down

0 comments on commit 74361db

Please sign in to comment.