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 // This function is not thread safe, so must only be called when the | |
eroman
2011/01/05 02:39:06
I suggest making this threadsafe -- simply read-wr
mmenke
2011/01/05 16:32:25
Done, and renamed to SetLogLevel.
| |
65 // CapturingNetLog is not being actively used. | |
66 void set_log_level(NetLog::LogLevel log_level); | |
67 | |
64 private: | 68 private: |
65 // Needs to be "mutable" so can use it in GetEntries(). | 69 // Needs to be "mutable" so can use it in GetEntries(). |
66 mutable Lock lock_; | 70 mutable Lock lock_; |
67 | 71 |
68 // Last assigned source ID. Incremented to get the next one. | 72 // Last assigned source ID. Incremented to get the next one. |
69 base::subtle::Atomic32 last_id_; | 73 base::subtle::Atomic32 last_id_; |
70 | 74 |
71 size_t max_num_entries_; | 75 size_t max_num_entries_; |
72 EntryList entries_; | 76 EntryList entries_; |
73 | 77 |
78 NetLog::LogLevel log_level_; | |
79 | |
74 DISALLOW_COPY_AND_ASSIGN(CapturingNetLog); | 80 DISALLOW_COPY_AND_ASSIGN(CapturingNetLog); |
75 }; | 81 }; |
76 | 82 |
77 // Helper class that exposes a similar API as BoundNetLog, but uses a | 83 // Helper class that exposes a similar API as BoundNetLog, but uses a |
78 // CapturingNetLog rather than the more generic NetLog. | 84 // CapturingNetLog rather than the more generic NetLog. |
79 // | 85 // |
80 // CapturingBoundNetLog can easily be converted to a BoundNetLog using the | 86 // CapturingBoundNetLog can easily be converted to a BoundNetLog using the |
81 // bound() method. | 87 // bound() method. |
82 class CapturingBoundNetLog { | 88 class CapturingBoundNetLog { |
83 public: | 89 public: |
84 CapturingBoundNetLog(const NetLog::Source& source, CapturingNetLog* net_log); | 90 CapturingBoundNetLog(const NetLog::Source& source, CapturingNetLog* net_log); |
85 | 91 |
86 explicit CapturingBoundNetLog(size_t max_num_entries); | 92 explicit CapturingBoundNetLog(size_t max_num_entries); |
87 | 93 |
88 ~CapturingBoundNetLog(); | 94 ~CapturingBoundNetLog(); |
89 | 95 |
90 // The returned BoundNetLog is only valid while |this| is alive. | 96 // The returned BoundNetLog is only valid while |this| is alive. |
91 BoundNetLog bound() const { | 97 BoundNetLog bound() const { |
92 return BoundNetLog(source_, capturing_net_log_.get()); | 98 return BoundNetLog(source_, capturing_net_log_.get()); |
93 } | 99 } |
94 | 100 |
95 // Fills |entry_list| with all entries in the log. | 101 // Fills |entry_list| with all entries in the log. |
96 void GetEntries(CapturingNetLog::EntryList* entry_list) const; | 102 void GetEntries(CapturingNetLog::EntryList* entry_list) const; |
97 | 103 |
98 void Clear(); | 104 void Clear(); |
99 | 105 |
106 // This function is not thread safe, so must only be called when the | |
eroman
2011/01/05 02:39:06
Ditto to comment above.
(Also note that if you do
mmenke
2011/01/05 16:32:25
Done.
| |
107 // CapturingBoundNetLog and underlying CapturingNetLog are not actively being | |
108 // used. | |
109 void set_log_level(NetLog::LogLevel log_level); | |
110 | |
100 private: | 111 private: |
101 NetLog::Source source_; | 112 NetLog::Source source_; |
102 scoped_ptr<CapturingNetLog> capturing_net_log_; | 113 scoped_ptr<CapturingNetLog> capturing_net_log_; |
103 | 114 |
104 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog); | 115 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog); |
105 }; | 116 }; |
106 | 117 |
107 } // namespace net | 118 } // namespace net |
108 | 119 |
109 #endif // NET_BASE_CAPTURING_NET_LOG_H_ | 120 #endif // NET_BASE_CAPTURING_NET_LOG_H_ |
110 | 121 |
OLD | NEW |