OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_BASE_CAPTURING_NET_LOG_H_ | 5 #ifndef NET_BASE_CAPTURING_NET_LOG_H_ |
6 #define NET_BASE_CAPTURING_NET_LOG_H_ | 6 #define NET_BASE_CAPTURING_NET_LOG_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 EventPhase phase, | 54 EventPhase phase, |
55 EventParameters* extra_parameters); | 55 EventParameters* extra_parameters); |
56 virtual uint32 NextID(); | 56 virtual uint32 NextID(); |
57 virtual LogLevel GetLogLevel() const; | 57 virtual LogLevel GetLogLevel() const; |
58 | 58 |
59 // Returns the list of all entries in the log. | 59 // Returns the list of all entries in the log. |
60 void GetEntries(EntryList* entry_list) const; | 60 void GetEntries(EntryList* entry_list) const; |
61 | 61 |
62 void Clear(); | 62 void Clear(); |
63 | 63 |
| 64 void SetLogLevel(NetLog::LogLevel log_level); |
| 65 |
64 private: | 66 private: |
65 // Needs to be "mutable" so can use it in GetEntries(). | 67 // Needs to be "mutable" so can use it in GetEntries(). |
66 mutable Lock lock_; | 68 mutable Lock lock_; |
67 | 69 |
68 // Last assigned source ID. Incremented to get the next one. | 70 // Last assigned source ID. Incremented to get the next one. |
69 base::subtle::Atomic32 last_id_; | 71 base::subtle::Atomic32 last_id_; |
70 | 72 |
71 size_t max_num_entries_; | 73 size_t max_num_entries_; |
72 EntryList entries_; | 74 EntryList entries_; |
73 | 75 |
| 76 NetLog::LogLevel log_level_; |
| 77 |
74 DISALLOW_COPY_AND_ASSIGN(CapturingNetLog); | 78 DISALLOW_COPY_AND_ASSIGN(CapturingNetLog); |
75 }; | 79 }; |
76 | 80 |
77 // Helper class that exposes a similar API as BoundNetLog, but uses a | 81 // Helper class that exposes a similar API as BoundNetLog, but uses a |
78 // CapturingNetLog rather than the more generic NetLog. | 82 // CapturingNetLog rather than the more generic NetLog. |
79 // | 83 // |
80 // CapturingBoundNetLog can easily be converted to a BoundNetLog using the | 84 // CapturingBoundNetLog can easily be converted to a BoundNetLog using the |
81 // bound() method. | 85 // bound() method. |
82 class CapturingBoundNetLog { | 86 class CapturingBoundNetLog { |
83 public: | 87 public: |
84 CapturingBoundNetLog(const NetLog::Source& source, CapturingNetLog* net_log); | 88 CapturingBoundNetLog(const NetLog::Source& source, CapturingNetLog* net_log); |
85 | 89 |
86 explicit CapturingBoundNetLog(size_t max_num_entries); | 90 explicit CapturingBoundNetLog(size_t max_num_entries); |
87 | 91 |
88 ~CapturingBoundNetLog(); | 92 ~CapturingBoundNetLog(); |
89 | 93 |
90 // The returned BoundNetLog is only valid while |this| is alive. | 94 // The returned BoundNetLog is only valid while |this| is alive. |
91 BoundNetLog bound() const { | 95 BoundNetLog bound() const { |
92 return BoundNetLog(source_, capturing_net_log_.get()); | 96 return BoundNetLog(source_, capturing_net_log_.get()); |
93 } | 97 } |
94 | 98 |
95 // Fills |entry_list| with all entries in the log. | 99 // Fills |entry_list| with all entries in the log. |
96 void GetEntries(CapturingNetLog::EntryList* entry_list) const; | 100 void GetEntries(CapturingNetLog::EntryList* entry_list) const; |
97 | 101 |
98 void Clear(); | 102 void Clear(); |
99 | 103 |
| 104 // Sets the log level of the underlying CapturingNetLog. |
| 105 void SetLogLevel(NetLog::LogLevel log_level); |
| 106 |
100 private: | 107 private: |
101 NetLog::Source source_; | 108 NetLog::Source source_; |
102 scoped_ptr<CapturingNetLog> capturing_net_log_; | 109 scoped_ptr<CapturingNetLog> capturing_net_log_; |
103 | 110 |
104 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog); | 111 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog); |
105 }; | 112 }; |
106 | 113 |
107 } // namespace net | 114 } // namespace net |
108 | 115 |
109 #endif // NET_BASE_CAPTURING_NET_LOG_H_ | 116 #endif // NET_BASE_CAPTURING_NET_LOG_H_ |
110 | 117 |
OLD | NEW |