Index: net/log/net_log.h |
diff --git a/net/log/net_log.h b/net/log/net_log.h |
index 42d40a2e0f106b79b71b58be1f022ae1d411f2b5..e213f45c53e5f42c4c72234ab9147c6a49a2dc41 100644 |
--- a/net/log/net_log.h |
+++ b/net/log/net_log.h |
@@ -207,9 +207,9 @@ class NET_EXPORT NetLog { |
// will be unique and greater than 0. |
uint32 NextID(); |
- // Returns the capture mode for this NetLog. This is used to avoid computing |
- // and saving expensive log entries. |
- NetLogCaptureMode GetCaptureMode() const; |
+ // Returns true if there are any observers attached to the NetLog. This can be |
+ // used as an optimization to avoid emitting log entries. |
+ bool HasObservers() const; |
// Adds an observer and sets its log capture mode. The observer must not be |
// watching any NetLog, including this one, when this is called. |
@@ -294,9 +294,9 @@ class NET_EXPORT NetLog { |
EventPhase phase, |
const NetLog::ParametersCallback* parameters_callback); |
- // Called whenever an observer is added or removed, or has its log |
- // capture mode changed. Must have acquired |lock_| prior to calling. |
- void UpdateCaptureMode(); |
+ // Called whenever an observer is added or removed, to update has_observers_. |
mmenke
2015/05/05 19:45:15
|observers_| is more consistent with the other com
eroman
2015/05/05 22:54:38
Done (I presume you meant |has_observers_|)
|
+ // Must have acquired |lock_| prior to calling. |
+ void UpdateHasObservers(); |
// |lock_| protects access to |observers_|. |
base::Lock lock_; |
@@ -304,10 +304,10 @@ class NET_EXPORT NetLog { |
// Last assigned source ID. Incremented to get the next one. |
base::subtle::Atomic32 last_id_; |
- // The current capture mode. Note that the capture mode is stored as an |
- // integer rather than a NetLogCaptureMode so that it can be easily |
- // read/written without a lock using Atomic32. |
- base::subtle::Atomic32 effective_capture_mode_int32_; |
+ // Whether there are any observers in |observers_|. Note that this is stored |
+ // as an Atomic32 rather than a boolean so it can be accessed/written without |
+ // needing a lock. |
+ base::subtle::Atomic32 has_observers_; |
// |lock_| must be acquired whenever reading or writing to this. |
ObserverList<ThreadSafeObserver, true> observers_; |
@@ -362,7 +362,7 @@ class NET_EXPORT BoundNetLog { |
int byte_count, |
const char* bytes) const; |
- NetLogCaptureMode GetCaptureMode() const; |
+ bool HasObservers() const; |
mmenke
2015/05/05 19:45:15
Maybe IsLogging? I don't think consumers of the B
eroman
2015/05/05 22:54:38
Renamed to IsCapturing().
Which I think is in line
|
// Helper to create a BoundNetLog given a NetLog and a SourceType. Takes care |
// of creating a unique source ID, and handles the case of NULL net_log. |