histograms: Added Platform.TPM.DictionaryAttackResetStatus.
[chromium-blink-merge.git] / net / base / capturing_net_log_observer.h
blob267352a6b6e45a1553a04d9992510ec5891e26d2
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.
5 #ifndef NET_BASE_CAPTURING_NET_LOG_OBSERVER_H_
6 #define NET_BASE_CAPTURING_NET_LOG_OBSERVER_H_
8 #include <string>
9 #include <vector>
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"
17 namespace base {
18 class DictionaryValue;
19 class ListValue;
22 namespace net {
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;
32 // Returns the list of all entries in the log.
33 void GetEntries(CapturedNetLogEntry::List* entry_list) const;
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;
39 // Returns number of entries in the log.
40 size_t GetSize() const;
42 void Clear();
44 private:
45 // ThreadSafeObserver implementation:
46 void OnAddEntry(const NetLog::Entry& entry) override;
48 // Needs to be "mutable" so can use it in GetEntries().
49 mutable base::Lock lock_;
51 CapturedNetLogEntry::List captured_entries_;
53 DISALLOW_COPY_AND_ASSIGN(CapturingNetLogObserver);
56 } // namespace net
58 #endif // NET_BASE_CAPTURING_NET_LOG_OBSERVER_H_