Skip to content

Commit

Permalink
Clean up g_memory_coordinator after each MemoryCoordinatorImpl test
Browse files Browse the repository at this point in the history
MemoryCoordinatorImpl tests fail the first time and should be re-run separately.
g_memory_coordinator need to be cleaned up between tests, otherwise the subsequent tests
will crash trying to reset g_memory_coordinator.

This CL implements reset method which called after each MemoryCoordinatorImpl in destructor.

BUG=698282

Review-Url: https://codereview.chromium.org/2726983006
Cr-Commit-Position: refs/heads/master@{#454926}
  • Loading branch information
dimaa authored and Commit bot committed Mar 6, 2017
1 parent e8cf2b3 commit aba3097
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/memory/memory_coordinator_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ MemoryCoordinatorProxy* MemoryCoordinatorProxy::GetInstance() {
// static
void MemoryCoordinatorProxy::SetMemoryCoordinator(
MemoryCoordinator* coordinator) {
DCHECK(!g_memory_coordinator);
DCHECK(!g_memory_coordinator || !coordinator);
g_memory_coordinator = coordinator;
}

Expand Down
4 changes: 3 additions & 1 deletion content/browser/memory/memory_coordinator_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ MemoryCoordinatorImpl::MemoryCoordinatorImpl(
base::MemoryCoordinatorProxy::SetMemoryCoordinator(this);
}

MemoryCoordinatorImpl::~MemoryCoordinatorImpl() {}
MemoryCoordinatorImpl::~MemoryCoordinatorImpl() {
base::MemoryCoordinatorProxy::SetMemoryCoordinator(nullptr);
}

void MemoryCoordinatorImpl::Start() {
DCHECK(CalledOnValidThread());
Expand Down

0 comments on commit aba3097

Please sign in to comment.