OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_LOG_CAPTURING_NET_LOG_H_ | 5 #ifndef NET_LOG_CAPTURING_NET_LOG_H_ |
eroman
2015/04/14 20:06:12
Update this ifdef:
NET_LOG_CAPTURING_NET_LOG_H_ -
| |
6 #define NET_LOG_CAPTURING_NET_LOG_H_ | 6 #define NET_LOG_CAPTURING_NET_LOG_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "net/log/captured_net_log_entry.h" | 13 #include "net/log/captured_net_log_entry.h" |
14 #include "net/log/capturing_net_log_observer.h" | 14 #include "net/log/capturing_net_log_observer.h" |
15 #include "net/log/net_log.h" | 15 #include "net/log/net_log.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 // CapturingNetLog is convenience class which combines a NetLog and a | 19 // TestNetLog is convenience class which combines a NetLog and a |
20 // CapturingNetLogObserver. It is intended for testing only, and is part of the | 20 // CapturingNetLogObserver. It is intended for testing only, and is part of the |
21 // net_test_support project. | 21 // net_test_support project. |
22 class CapturingNetLog : public NetLog { | 22 class TestNetLog : public NetLog { |
23 public: | 23 public: |
24 // TODO(mmenke): Get rid of these. | 24 // TODO(mmenke): Get rid of these. |
25 typedef CapturedNetLogEntry CapturedEntry; | 25 typedef CapturedNetLogEntry CapturedEntry; |
26 typedef CapturedNetLogEntry::List CapturedEntryList; | 26 typedef CapturedNetLogEntry::List CapturedEntryList; |
27 | 27 |
28 CapturingNetLog(); | 28 TestNetLog(); |
29 ~CapturingNetLog() override; | 29 ~TestNetLog() override; |
30 | 30 |
31 void SetLogLevel(LogLevel log_level); | 31 void SetLogLevel(LogLevel log_level); |
32 | 32 |
33 // Below methods are forwarded to capturing_net_log_observer_. | 33 // Below methods are forwarded to capturing_net_log_observer_. |
34 void GetEntries(CapturedEntryList* entry_list) const; | 34 void GetEntries(CapturedEntryList* entry_list) const; |
35 void GetEntriesForSource(Source source, CapturedEntryList* entry_list) const; | 35 void GetEntriesForSource(Source source, CapturedEntryList* entry_list) const; |
36 size_t GetSize() const; | 36 size_t GetSize() const; |
37 void Clear(); | 37 void Clear(); |
38 | 38 |
39 private: | 39 private: |
40 CapturingNetLogObserver capturing_net_log_observer_; | 40 CapturingNetLogObserver capturing_net_log_observer_; |
41 | 41 |
42 DISALLOW_COPY_AND_ASSIGN(CapturingNetLog); | 42 DISALLOW_COPY_AND_ASSIGN(TestNetLog); |
43 }; | 43 }; |
44 | 44 |
45 // Helper class that exposes a similar API as BoundNetLog, but uses a | 45 // Helper class that exposes a similar API as BoundNetLog, but uses a |
46 // CapturingNetLog rather than the more generic NetLog. | 46 // TestNetLog rather than the more generic NetLog. |
47 // | 47 // |
48 // A CapturingBoundNetLog can easily be converted to a BoundNetLog using the | 48 // A CapturingBoundNetLog can easily be converted to a BoundNetLog using the |
49 // bound() method. | 49 // bound() method. |
50 class CapturingBoundNetLog { | 50 class CapturingBoundNetLog { |
eroman
2015/04/14 20:06:12
This should be renamed too, either as part of this
| |
51 public: | 51 public: |
52 CapturingBoundNetLog(); | 52 CapturingBoundNetLog(); |
53 ~CapturingBoundNetLog(); | 53 ~CapturingBoundNetLog(); |
54 | 54 |
55 // The returned BoundNetLog is only valid while |this| is alive. | 55 // The returned BoundNetLog is only valid while |this| is alive. |
56 BoundNetLog bound() const { return net_log_; } | 56 BoundNetLog bound() const { return net_log_; } |
57 | 57 |
58 // Fills |entry_list| with all entries in the log. | 58 // Fills |entry_list| with all entries in the log. |
59 void GetEntries(CapturingNetLog::CapturedEntryList* entry_list) const; | 59 void GetEntries(TestNetLog::CapturedEntryList* entry_list) const; |
60 | 60 |
61 // Fills |entry_list| with all entries in the log from the specified Source. | 61 // Fills |entry_list| with all entries in the log from the specified Source. |
62 void GetEntriesForSource( | 62 void GetEntriesForSource(NetLog::Source source, |
63 NetLog::Source source, | 63 TestNetLog::CapturedEntryList* entry_list) const; |
64 CapturingNetLog::CapturedEntryList* entry_list) const; | |
65 | 64 |
66 // Returns number of entries in the log. | 65 // Returns number of entries in the log. |
67 size_t GetSize() const; | 66 size_t GetSize() const; |
68 | 67 |
69 void Clear(); | 68 void Clear(); |
70 | 69 |
71 // Sets the log level of the underlying CapturingNetLog. | 70 // Sets the log level of the underlying TestNetLog. |
72 void SetLogLevel(NetLog::LogLevel log_level); | 71 void SetLogLevel(NetLog::LogLevel log_level); |
73 | 72 |
74 private: | 73 private: |
75 CapturingNetLog capturing_net_log_; | 74 TestNetLog capturing_net_log_; |
76 const BoundNetLog net_log_; | 75 const BoundNetLog net_log_; |
77 | 76 |
78 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog); | 77 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog); |
79 }; | 78 }; |
80 | 79 |
81 } // namespace net | 80 } // namespace net |
82 | 81 |
83 #endif // NET_LOG_CAPTURING_NET_LOG_H_ | 82 #endif // NET_LOG_CAPTURING_NET_LOG_H_ |
OLD | NEW |