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

Unified Diff: net/log/trace_net_log_observer.cc

Issue 2554483002: netlog: Don't enable recording if the "netlog" tracing category is disabled. (Closed)
Patch Set: Address comment. Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/log/trace_net_log_observer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/log/trace_net_log_observer.cc
diff --git a/net/log/trace_net_log_observer.cc b/net/log/trace_net_log_observer.cc
index bae83a5ac141af05e17ad43ee8cd4063687843bd..af69aca14ad561c3163fd0113603fcbd83d965be 100644
--- a/net/log/trace_net_log_observer.cc
+++ b/net/log/trace_net_log_observer.cc
@@ -101,12 +101,21 @@ void TraceNetLogObserver::StopWatchForTraceStart() {
// Should only stop if is currently watching.
DCHECK(net_log_to_watch_);
base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this);
+ // net_log() != nullptr iff NetLog::DeprecatedAddObserver() has been called.
+ // This implies that if the netlog category wasn't enabled, then
+ // NetLog::DeprecatedRemoveObserver() will not get called, and there won't be
+ // a crash in NetLog::DeprecatedRemoveObserver().
if (net_log())
net_log()->DeprecatedRemoveObserver(this);
- net_log_to_watch_ = NULL;
+ net_log_to_watch_ = nullptr;
}
void TraceNetLogObserver::OnTraceLogEnabled() {
+ bool enabled;
+ TRACE_EVENT_CATEGORY_GROUP_ENABLED(kNetLogTracingCategory, &enabled);
+ if (!enabled)
+ return;
+
net_log_to_watch_->DeprecatedAddObserver(this, NetLogCaptureMode::Default());
}
« no previous file with comments | « no previous file | net/log/trace_net_log_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698