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

Unified Diff: net/log/net_log.h

Issue 1122483004: Remove NetLog::GetCaptureMode() and NetLogCaptureMode::None() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mmenke_refactor
Patch Set: second attempt at fixing int --> bool warning on windows Created 5 years, 7 months 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 | « net/http/http_network_transaction_unittest.cc ('k') | net/log/net_log.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/log/net_log.h
diff --git a/net/log/net_log.h b/net/log/net_log.h
index 42d40a2e0f106b79b71b58be1f022ae1d411f2b5..3a1c7bcac663c2cb8979b91223c0803c8fef2bf7 100644
--- a/net/log/net_log.h
+++ b/net/log/net_log.h
@@ -207,9 +207,10 @@ 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 when there is no
+ // chance that the data will be consumed.
+ bool IsCapturing() 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 +295,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_|. Must have acquired |lock_| prior to calling.
+ void UpdateIsCapturing();
// |lock_| protects access to |observers_|.
base::Lock lock_;
@@ -304,10 +305,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_;
+ // |is_capturing_| will be 0 when there are no observers watching the NetLog,
+ // 1 otherwise. Note that this is stored as an Atomic32 rather than a boolean
+ // so it can be accessed without needing a lock.
+ base::subtle::Atomic32 is_capturing_;
// |lock_| must be acquired whenever reading or writing to this.
ObserverList<ThreadSafeObserver, true> observers_;
@@ -362,7 +363,7 @@ class NET_EXPORT BoundNetLog {
int byte_count,
const char* bytes) const;
- NetLogCaptureMode GetCaptureMode() const;
+ bool IsCapturing() const;
// 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.
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/log/net_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698