Index: net/log/net_log.cc |
diff --git a/net/log/net_log.cc b/net/log/net_log.cc |
index 33243d3c3f63c48bafa818b29c4bc31bc05380e8..d5d4a2f79d9d9f4d66fd5e9db2a0c945ebb4f799 100644 |
--- a/net/log/net_log.cc |
+++ b/net/log/net_log.cc |
@@ -205,10 +205,7 @@ void NetLog::ThreadSafeObserver::OnAddEntryData(const EntryData& entry_data) { |
OnAddEntry(Entry(&entry_data, capture_mode())); |
} |
-NetLog::NetLog() |
- : last_id_(0), |
- effective_capture_mode_int32_( |
- NetLogCaptureMode::None().ToInternalValue()) { |
+NetLog::NetLog() : last_id_(0), has_observers_(0) { |
} |
NetLog::~NetLog() { |
@@ -230,10 +227,10 @@ uint32 NetLog::NextID() { |
return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1); |
} |
-NetLogCaptureMode NetLog::GetCaptureMode() const { |
- base::subtle::Atomic32 capture_mode = |
- base::subtle::NoBarrier_Load(&effective_capture_mode_int32_); |
- return NetLogCaptureMode::FromInternalValue(capture_mode); |
+bool NetLog::HasObservers() const { |
+ base::subtle::Atomic32 has_observers = |
+ base::subtle::NoBarrier_Load(&has_observers_); |
+ return has_observers; |
} |
void NetLog::DeprecatedAddObserver(NetLog::ThreadSafeObserver* observer, |
@@ -247,7 +244,7 @@ void NetLog::DeprecatedAddObserver(NetLog::ThreadSafeObserver* observer, |
observers_.AddObserver(observer); |
observer->net_log_ = this; |
observer->capture_mode_ = capture_mode; |
- UpdateCaptureMode(); |
+ UpdateHasObservers(); |
} |
void NetLog::SetObserverCaptureMode(NetLog::ThreadSafeObserver* observer, |
@@ -259,7 +256,6 @@ void NetLog::SetObserverCaptureMode(NetLog::ThreadSafeObserver* observer, |
DCHECK_EQ(this, observer->net_log_); |
DCHECK(observer->capture_mode_.enabled()); |
observer->capture_mode_ = capture_mode; |
mmenke
2015/05/05 19:45:15
Do we ever explicitly disallow observers from watc
eroman
2015/05/05 22:54:37
I updated the CL and just removed NetLogCaptureMod
|
- UpdateCaptureMode(); |
} |
void NetLog::DeprecatedRemoveObserver(NetLog::ThreadSafeObserver* observer) { |
@@ -271,22 +267,13 @@ void NetLog::DeprecatedRemoveObserver(NetLog::ThreadSafeObserver* observer) { |
observers_.RemoveObserver(observer); |
observer->net_log_ = NULL; |
observer->capture_mode_ = NetLogCaptureMode(); |
- UpdateCaptureMode(); |
+ UpdateHasObservers(); |
} |
-void NetLog::UpdateCaptureMode() { |
+void NetLog::UpdateHasObservers() { |
lock_.AssertAcquired(); |
- |
- // Accumulate the capture mode of all the observers to find the maximum level. |
- NetLogCaptureMode new_capture_mode = NetLogCaptureMode::None(); |
- ObserverListBase<ThreadSafeObserver>::Iterator it(&observers_); |
- ThreadSafeObserver* observer; |
- while ((observer = it.GetNext()) != NULL) { |
- new_capture_mode = |
- NetLogCaptureMode::Max(new_capture_mode, observer->capture_mode()); |
- } |
- base::subtle::NoBarrier_Store(&effective_capture_mode_int32_, |
- new_capture_mode.ToInternalValue()); |
+ base::subtle::NoBarrier_Store( |
+ &has_observers_, static_cast<int>(observers_.might_have_observers())); |
} |
// static |
@@ -390,7 +377,7 @@ void NetLog::AddEntry(EventType type, |
const Source& source, |
EventPhase phase, |
const NetLog::ParametersCallback* parameters_callback) { |
- if (!GetCaptureMode().enabled()) |
+ if (!HasObservers()) |
return; |
EntryData entry_data(type, source, phase, base::TimeTicks::Now(), |
parameters_callback); |
@@ -480,12 +467,9 @@ void BoundNetLog::AddByteTransferEvent(NetLog::EventType event_type, |
AddEvent(event_type, base::Bind(BytesTransferredCallback, byte_count, bytes)); |
} |
-NetLogCaptureMode BoundNetLog::GetCaptureMode() const { |
+bool BoundNetLog::HasObservers() const { |
CrashIfInvalid(); |
- |
- if (net_log_) |
- return net_log_->GetCaptureMode(); |
- return NetLogCaptureMode(); |
+ return net_log_ && net_log_->HasObservers(); |
} |
// static |