summaryrefslogtreecommitdiffstats
path: root/net/base/capturing_net_log.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/capturing_net_log.h')
-rw-r--r--net/base/capturing_net_log.h63
1 files changed, 36 insertions, 27 deletions
diff --git a/net/base/capturing_net_log.h b/net/base/capturing_net_log.h
index d3586d1..d23beb9 100644
--- a/net/base/capturing_net_log.h
+++ b/net/base/capturing_net_log.h
@@ -23,9 +23,10 @@ class DictionaryValue;
namespace net {
-// CapturingNetLog is an implementation of NetLog that saves messages to a
-// bounded buffer. It is intended for testing only, and is part of the
-// net_test_support project.
+// CapturingNetLog is a NetLog which instantiates Observer that saves messages
+// to a bounded buffer. It is intended for testing only, and is part of the
+// net_test_support project. This is provided for convinience and compatilbility
+// with the old unittests.
class CapturingNetLog : public NetLog {
public:
struct CapturedEntry {
@@ -71,40 +72,48 @@ class CapturingNetLog : public NetLog {
CapturingNetLog();
virtual ~CapturingNetLog();
- // Returns the list of all entries in the log.
+ void SetLogLevel(LogLevel log_level);
+
+ // Below methods are forwarded to capturing_net_log_observer_.
void GetEntries(CapturedEntryList* entry_list) const;
+ void GetEntriesForSource(Source source, CapturedEntryList* entry_list) const;
+ size_t GetSize() const;
+ void Clear();
- // Fills |entry_list| with all entries in the log from the specified Source.
- void GetEntriesForSource(NetLog::Source source,
- CapturedEntryList* entry_list) const;
+ private:
+ // Observer is an implementation of NetLog::ThreadSafeObserver
+ // that saves messages to a bounded buffer. It is intended for testing only,
+ // and is part of the net_test_support project.
+ class Observer : public NetLog::ThreadSafeObserver {
+ public:
+ Observer();
+ virtual ~Observer();
- // Returns number of entries in the log.
- size_t GetSize() const;
+ // Returns the list of all entries in the log.
+ void GetEntries(CapturedEntryList* entry_list) const;
- void Clear();
+ // Fills |entry_list| with all entries in the log from the specified Source.
+ void GetEntriesForSource(Source source,
+ CapturedEntryList* entry_list) const;
- void SetLogLevel(NetLog::LogLevel log_level);
+ // Returns number of entries in the log.
+ size_t GetSize() const;
- // NetLog implementation:
- virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE;
- virtual uint32 NextID() OVERRIDE;
- virtual LogLevel GetLogLevel() const OVERRIDE;
- virtual void AddThreadSafeObserver(ThreadSafeObserver* observer,
- LogLevel log_level) OVERRIDE;
- virtual void SetObserverLogLevel(ThreadSafeObserver* observer,
- LogLevel log_level) OVERRIDE;
- virtual void RemoveThreadSafeObserver(ThreadSafeObserver* observer) OVERRIDE;
+ void Clear();
- private:
- // Needs to be "mutable" so can use it in GetEntries().
- mutable base::Lock lock_;
+ private:
+ // ThreadSafeObserver implementation:
+ virtual void OnAddEntry(const Entry& entry) OVERRIDE;
+
+ // Needs to be "mutable" so can use it in GetEntries().
+ mutable base::Lock lock_;
- // Last assigned source ID. Incremented to get the next one.
- base::subtle::Atomic32 last_id_;
+ CapturedEntryList captured_entries_;
- CapturedEntryList captured_entries_;
+ DISALLOW_COPY_AND_ASSIGN(Observer);
+ };
- NetLog::LogLevel log_level_;
+ Observer capturing_net_log_observer_;
DISALLOW_COPY_AND_ASSIGN(CapturingNetLog);
};