summaryrefslogtreecommitdiffstats
path: root/net/base/net_log.h
diff options
context:
space:
mode:
authorkouhei@chromium.org <kouhei@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-07 19:18:26 +0000
committerkouhei@chromium.org <kouhei@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-07 19:18:26 +0000
commit1cf7fd079ca5d2638c816e91bd4b50bed915eba0 (patch)
treea55a4f4e6fd0a72669ddae31da738e62301ddb1d /net/base/net_log.h
parent89a94a7913b6bbc6eb2ad9510b82a519bce2bd61 (diff)
downloadchromium_src-1cf7fd079ca5d2638c816e91bd4b50bed915eba0.zip
chromium_src-1cf7fd079ca5d2638c816e91bd4b50bed915eba0.tar.gz
chromium_src-1cf7fd079ca5d2638c816e91bd4b50bed915eba0.tar.bz2
Revert 204861 "Refactor net::NetLog to provide implementation of..."
> Refactor net::NetLog to provide implementation of observer pattern, not just the interface. > This would make use of net::NetLog::ThreadSafeObserver available from base/net, so custom NetLog implementations can focus on implementing OnAddEntry() without re-implementing all NetLog methods. > > The implementation of observer pattern was previously provided in ChromeNetLog. > The contents of chrome_net_log_unittest are merged to net_log_unittest. > > TESTS=net_log_unittest > BUG=None > > Review URL: https://chromiumcodereview.appspot.com/16137008 TBR=kouhei@chromium.org Review URL: https://codereview.chromium.org/15927035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204892 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/net_log.h')
-rw-r--r--net/base/net_log.h51
1 files changed, 19 insertions, 32 deletions
diff --git a/net/base/net_log.h b/net/base/net_log.h
index fb5637d..8ae33e9 100644
--- a/net/base/net_log.h
+++ b/net/base/net_log.h
@@ -7,13 +7,10 @@
#include <string>
-#include "base/atomicops.h"
#include "base/basictypes.h"
#include "base/callback_forward.h"
#include "base/compiler_specific.h"
-#include "base/observer_list.h"
#include "base/string16.h"
-#include "base/synchronization/lock.h"
#include "base/time.h"
#include "net/base/net_export.h"
@@ -201,8 +198,8 @@ class NET_EXPORT NetLog {
DISALLOW_COPY_AND_ASSIGN(ThreadSafeObserver);
};
- NetLog();
- virtual ~NetLog();
+ NetLog() {}
+ virtual ~NetLog() {}
// Emits a global event to the log stream, with its own unique source ID.
void AddGlobalEntry(EventType type);
@@ -211,11 +208,11 @@ class NET_EXPORT NetLog {
// Returns a unique ID which can be used as a source ID. All returned IDs
// will be unique and greater than 0.
- uint32 NextID();
+ virtual uint32 NextID() = 0;
// Returns the logging level for this NetLog. This is used to avoid computing
// and saving expensive log entries.
- LogLevel GetLogLevel() const;
+ virtual LogLevel GetLogLevel() const = 0;
// Adds an observer and sets its log level. The observer must not be
// watching any NetLog, including this one, when this is called.
@@ -227,19 +224,21 @@ class NET_EXPORT NetLog {
//
// NetLog implementations must call NetLog::OnAddObserver to update the
// observer's internal state.
- void AddThreadSafeObserver(ThreadSafeObserver* observer, LogLevel log_level);
+ virtual void AddThreadSafeObserver(ThreadSafeObserver* observer,
+ LogLevel log_level) = 0;
// Sets the log level of |observer| to |log_level|. |observer| must be
// watching |this|. NetLog implementations must call
// NetLog::OnSetObserverLogLevel to update the observer's internal state.
- void SetObserverLogLevel(ThreadSafeObserver* observer, LogLevel log_level);
+ virtual void SetObserverLogLevel(ThreadSafeObserver* observer,
+ LogLevel log_level) = 0;
// Removes an observer. NetLog implementations must call
// NetLog::OnAddObserver to update the observer's internal state.
//
// For thread safety reasons, it is recommended that this not be called in
// an object's destructor.
- void RemoveThreadSafeObserver(ThreadSafeObserver* observer);
+ virtual void RemoveThreadSafeObserver(ThreadSafeObserver* observer) = 0;
// Converts a time to the string format that the NetLog uses to represent
// times. Strings are used since integers may overflow.
@@ -294,8 +293,16 @@ class NET_EXPORT NetLog {
const base::string16* value);
protected:
- // Set the lowest allowed log level, regardless of any Observers.
- void SetBaseLogLevel(LogLevel log_level);
+ // Child classes should respond to the new entry here. This includes
+ // creating the Entry object and alerting their observers.
+ virtual void OnAddEntry(const Entry& entry) = 0;
+
+ // Subclasses must call these in the corresponding functions to set an
+ // observer's |net_log_| and |log_level_| values.
+ void OnAddObserver(ThreadSafeObserver* observer, LogLevel log_level);
+ void OnSetObserverLogLevel(ThreadSafeObserver* observer,
+ LogLevel log_level);
+ void OnRemoveObserver(ThreadSafeObserver* observer);
private:
friend class BoundNetLog;
@@ -305,26 +312,6 @@ class NET_EXPORT NetLog {
EventPhase phase,
const NetLog::ParametersCallback* parameters_callback);
- // Called whenever an observer is added or removed, or has its log level
- // changed. Must have acquired |lock_| prior to calling.
- void UpdateLogLevel();
-
- // |lock_| protects access to |observers_|.
- base::Lock lock_;
-
- // Last assigned source ID. Incremented to get the next one.
- base::subtle::Atomic32 last_id_;
-
- // The lowest allowed log level, regardless of any Observers.
- // Normally defaults to LOG_NONE, but can be changed with SetBaseLogLevel
- LogLevel base_log_level_;
-
- // The current log level.
- base::subtle::Atomic32 effective_log_level_;
-
- // |lock_| must be acquired whenever reading or writing to this.
- ObserverList<ThreadSafeObserver, true> observers_;
-
DISALLOW_COPY_AND_ASSIGN(NetLog);
};