Commit 2f88261b authored by Wez's avatar Wez Committed by Commit Bot

Promote KeepAliveRegistry logging and DCHECKs to CHECKs.

- Enable CHECK against registration of new keep-alives during shutdown.
- Promote some DLOG() checks to DCHECKs to make issues more visible.

Bug: 720078
Change-Id: I11e24a8de0ec5ab9e0a71f776d4b7149bb847ad2
Reviewed-on: https://chromium-review.googlesource.com/1013394Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551033}
parent a4614ed6
......@@ -81,9 +81,7 @@ bool KeepAliveRegistry::WouldRestartWithout(
}
void KeepAliveRegistry::SetIsShuttingDown(bool value) {
#if DCHECK_IS_ON()
is_shutting_down_ = value;
#endif
}
////////////////////////////////////////////////////////////////////////////////
......@@ -93,15 +91,14 @@ KeepAliveRegistry::KeepAliveRegistry()
: registered_count_(0), restart_allowed_count_(0) {}
KeepAliveRegistry::~KeepAliveRegistry() {
DLOG_IF(ERROR, registered_count_ > 0 || registered_keep_alives_.size() > 0)
<< "KeepAliveRegistry not empty at destruction time. State:" << *this;
DCHECK_LE(registered_count_, 0) << "KeepAliveRegistry state:" << *this;
DCHECK_EQ(registered_keep_alives_.size(), 0u)
<< "KeepAliveRegistry state:" << *this;
}
void KeepAliveRegistry::Register(KeepAliveOrigin origin,
KeepAliveRestartOption restart) {
#if DCHECK_IS_ON()
DCHECK(!is_shutting_down_);
#endif
CHECK(!is_shutting_down_);
bool old_keeping_alive = IsKeepingAlive();
bool old_restart_allowed = IsRestartAllowed();
......
......@@ -8,7 +8,6 @@
#include <unordered_map>
#include <vector>
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/singleton.h"
#include "base/observer_list.h"
......@@ -92,10 +91,8 @@ class KeepAliveRegistry {
// Number of registered keep alives that have KeepAliveRestartOption::ENABLED.
int restart_allowed_count_;
#if DCHECK_IS_ON()
// Used to guard against registering during shutdown.
bool is_shutting_down_ = false;
#endif
base::ObserverList<KeepAliveStateObserver> observers_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment