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_TEST_NET_LOG_H_ | 5 #ifndef NET_LOG_TEST_NET_LOG_H_ |
6 #define NET_LOG_TEST_NET_LOG_H_ | 6 #define NET_LOG_TEST_NET_LOG_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 private: | 42 private: |
43 // The underlying observer class that does all the work. | 43 // The underlying observer class that does all the work. |
44 class Observer; | 44 class Observer; |
45 | 45 |
46 std::unique_ptr<Observer> observer_; | 46 std::unique_ptr<Observer> observer_; |
47 | 47 |
48 DISALLOW_COPY_AND_ASSIGN(TestNetLog); | 48 DISALLOW_COPY_AND_ASSIGN(TestNetLog); |
49 }; | 49 }; |
50 | 50 |
51 // Helper class that exposes a similar API as BoundNetLog, but uses a | 51 // Helper class that exposes a similar API as NetLogWithSource, but uses a |
52 // TestNetLog rather than the more generic NetLog. | 52 // TestNetLog rather than the more generic NetLog. |
53 // | 53 // |
54 // A BoundTestNetLog can easily be converted to a BoundNetLog using the | 54 // A BoundTestNetLog can easily be converted to a NetLogWithSource using the |
55 // bound() method. | 55 // bound() method. |
56 class BoundTestNetLog { | 56 class BoundTestNetLog { |
57 public: | 57 public: |
58 BoundTestNetLog(); | 58 BoundTestNetLog(); |
59 ~BoundTestNetLog(); | 59 ~BoundTestNetLog(); |
60 | 60 |
61 // The returned BoundNetLog is only valid while |this| is alive. | 61 // The returned NetLogWithSource is only valid while |this| is alive. |
62 BoundNetLog bound() const { return net_log_; } | 62 NetLogWithSource bound() const { return net_log_; } |
63 | 63 |
64 // Fills |entry_list| with all entries in the log. | 64 // Fills |entry_list| with all entries in the log. |
65 void GetEntries(TestNetLogEntry::List* entry_list) const; | 65 void GetEntries(TestNetLogEntry::List* entry_list) const; |
66 | 66 |
67 // Fills |entry_list| with all entries in the log from the specified Source. | 67 // Fills |entry_list| with all entries in the log from the specified Source. |
68 void GetEntriesForSource(NetLog::Source source, | 68 void GetEntriesForSource(NetLog::Source source, |
69 TestNetLogEntry::List* entry_list) const; | 69 TestNetLogEntry::List* entry_list) const; |
70 | 70 |
71 // Returns number of entries in the log. | 71 // Returns number of entries in the log. |
72 size_t GetSize() const; | 72 size_t GetSize() const; |
73 | 73 |
74 void Clear(); | 74 void Clear(); |
75 | 75 |
76 // Sets the capture mode of the underlying TestNetLog. | 76 // Sets the capture mode of the underlying TestNetLog. |
77 void SetCaptureMode(NetLogCaptureMode capture_mode); | 77 void SetCaptureMode(NetLogCaptureMode capture_mode); |
78 | 78 |
79 private: | 79 private: |
80 TestNetLog test_net_log_; | 80 TestNetLog test_net_log_; |
81 const BoundNetLog net_log_; | 81 const NetLogWithSource net_log_; |
82 | 82 |
83 DISALLOW_COPY_AND_ASSIGN(BoundTestNetLog); | 83 DISALLOW_COPY_AND_ASSIGN(BoundTestNetLog); |
84 }; | 84 }; |
85 | 85 |
86 } // namespace net | 86 } // namespace net |
87 | 87 |
88 #endif // NET_LOG_TEST_NET_LOG_H_ | 88 #endif // NET_LOG_TEST_NET_LOG_H_ |
OLD | NEW |