Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / net / log / test_net_log.h
blob7dc301147364e6d8e5039689cb3c62c6008602ad
1 // Copyright (c) 2012 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_LOG_TEST_NET_LOG_H_
6 #define NET_LOG_TEST_NET_LOG_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "net/log/net_log.h"
14 #include "net/log/test_net_log_entry.h"
16 namespace net {
18 // TestNetLog is NetLog subclass which records all NetLog events that occur and
19 // their parameters. It is intended for testing only, and is part of the
20 // net_test_support project.
21 class TestNetLog : public NetLog {
22 public:
23 TestNetLog();
24 ~TestNetLog() override;
26 void SetCaptureMode(NetLogCaptureMode capture_mode);
28 // Below methods are forwarded to test_net_log_observer_.
29 void GetEntries(TestNetLogEntry::List* entry_list) const;
30 void GetEntriesForSource(Source source,
31 TestNetLogEntry::List* entry_list) const;
32 size_t GetSize() const;
33 void Clear();
35 // Returns a NetLog observer that will write entries to the TestNetLog's event
36 // store. For testing code that bypasses NetLogs and adds events directly to
37 // an observer.
38 NetLog::ThreadSafeObserver* GetObserver() const;
40 private:
41 // The underlying observer class that does all the work.
42 class Observer;
44 scoped_ptr<Observer> observer_;
46 DISALLOW_COPY_AND_ASSIGN(TestNetLog);
49 // Helper class that exposes a similar API as BoundNetLog, but uses a
50 // TestNetLog rather than the more generic NetLog.
52 // A BoundTestNetLog can easily be converted to a BoundNetLog using the
53 // bound() method.
54 class BoundTestNetLog {
55 public:
56 BoundTestNetLog();
57 ~BoundTestNetLog();
59 // The returned BoundNetLog is only valid while |this| is alive.
60 BoundNetLog bound() const { return net_log_; }
62 // Fills |entry_list| with all entries in the log.
63 void GetEntries(TestNetLogEntry::List* entry_list) const;
65 // Fills |entry_list| with all entries in the log from the specified Source.
66 void GetEntriesForSource(NetLog::Source source,
67 TestNetLogEntry::List* entry_list) const;
69 // Returns number of entries in the log.
70 size_t GetSize() const;
72 void Clear();
74 // Sets the capture mode of the underlying TestNetLog.
75 void SetCaptureMode(NetLogCaptureMode capture_mode);
77 private:
78 TestNetLog test_net_log_;
79 const BoundNetLog net_log_;
81 DISALLOW_COPY_AND_ASSIGN(BoundTestNetLog);
84 } // namespace net
86 #endif // NET_LOG_TEST_NET_LOG_H_