OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_BASE_CAPTURING_NET_LOG_OBSERVER_H_ |
| 6 #define NET_BASE_CAPTURING_NET_LOG_OBSERVER_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
| 13 #include "base/synchronization/lock.h" |
| 14 #include "net/base/captured_net_log_entry.h" |
| 15 #include "net/base/net_log.h" |
| 16 |
| 17 namespace base { |
| 18 class DictionaryValue; |
| 19 class ListValue; |
| 20 } |
| 21 |
| 22 namespace net { |
| 23 |
| 24 // CapturingNetLogObserver is an implementation of NetLog::ThreadSafeObserver |
| 25 // that saves messages to a bounded buffer. It is intended for testing only, |
| 26 // and is part of the net_test_support project. |
| 27 class CapturingNetLogObserver : public NetLog::ThreadSafeObserver { |
| 28 public: |
| 29 CapturingNetLogObserver(); |
| 30 ~CapturingNetLogObserver() override; |
| 31 |
| 32 // Returns the list of all entries in the log. |
| 33 void GetEntries(CapturedNetLogEntry::List* entry_list) const; |
| 34 |
| 35 // Fills |entry_list| with all entries in the log from the specified Source. |
| 36 void GetEntriesForSource(NetLog::Source source, |
| 37 CapturedNetLogEntry::List* entry_list) const; |
| 38 |
| 39 // Returns number of entries in the log. |
| 40 size_t GetSize() const; |
| 41 |
| 42 void Clear(); |
| 43 |
| 44 private: |
| 45 // ThreadSafeObserver implementation: |
| 46 void OnAddEntry(const NetLog::Entry& entry) override; |
| 47 |
| 48 // Needs to be "mutable" so can use it in GetEntries(). |
| 49 mutable base::Lock lock_; |
| 50 |
| 51 CapturedNetLogEntry::List captured_entries_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(CapturingNetLogObserver); |
| 54 }; |
| 55 |
| 56 } // namespace net |
| 57 |
| 58 #endif // NET_BASE_CAPTURING_NET_LOG_OBSERVER_H_ |
OLD | NEW |