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