Skip to content

Commit 74361db

Browse files
committed
Fix 2 access violation in resource_coordinator.
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}
1 parent b7e5331 commit 74361db

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

chrome/browser/resource_coordinator/tab_lifecycle_unit_source.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ void TabLifecycleUnitSource::TabChangedAt(content::WebContents* contents,
161161
if (change_type != TabChangeType::kAll)
162162
return;
163163
auto it = tabs_.find(contents);
164-
DCHECK(it != tabs_.end());
164+
// The WebContents destructor might cause this function to be called, at this
165+
// point TabClosingAt has already been called and so this WebContents has
166+
// been removed from |tabs_|.
167+
if (it == tabs_.end())
168+
return;
165169
TabLifecycleUnit* lifecycle_unit = it->second.get();
166170
lifecycle_unit->SetRecentlyAudible(contents->WasRecentlyAudible());
167171
}

chrome/browser/resource_coordinator/tab_manager.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,13 @@ void TabManager::PurgeBackgroundedTabsIfNeeded() {
482482
DCHECK(tab_lifecycle_unit_external);
483483
content::WebContents* content =
484484
tab_lifecycle_unit_external->GetWebContents();
485-
DCHECK(content);
485+
// TODO(fdoray): Check if TabLifecycleUnitSource should override
486+
// WebContentsObserver::WebContentsDestroyed() as in some situations a
487+
// WebContents might get destroyed without a call to
488+
// TabStripModelObserver::TabClosingAt, in this case we'll have a
489+
// TabLifecycleUnitExternal that points to a null WebContents.
490+
if (content == nullptr)
491+
return;
486492

487493
content::RenderProcessHost* render_process_host =
488494
content->GetMainFrame()->GetProcess();

0 commit comments

Comments
 (0)