| 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 | |
| 66 private: | 64 private: |
| 67 // Needs to be "mutable" so can use it in GetEntries(). | 65 // Needs to be "mutable" so can use it in GetEntries(). |
| 68 mutable Lock lock_; | 66 mutable Lock lock_; |
| 69 | 67 |
| 70 // Last assigned source ID. Incremented to get the next one. | 68 // Last assigned source ID. Incremented to get the next one. |
| 71 base::subtle::Atomic32 last_id_; | 69 base::subtle::Atomic32 last_id_; |
| 72 | 70 |
| 73 size_t max_num_entries_; | 71 size_t max_num_entries_; |
| 74 EntryList entries_; | 72 EntryList entries_; |
| 75 | 73 |
| 76 NetLog::LogLevel log_level_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(CapturingNetLog); | 74 DISALLOW_COPY_AND_ASSIGN(CapturingNetLog); |
| 79 }; | 75 }; |
| 80 | 76 |
| 81 // Helper class that exposes a similar API as BoundNetLog, but uses a | 77 // Helper class that exposes a similar API as BoundNetLog, but uses a |
| 82 // CapturingNetLog rather than the more generic NetLog. | 78 // CapturingNetLog rather than the more generic NetLog. |
| 83 // | 79 // |
| 84 // CapturingBoundNetLog can easily be converted to a BoundNetLog using the | 80 // CapturingBoundNetLog can easily be converted to a BoundNetLog using the |
| 85 // bound() method. | 81 // bound() method. |
| 86 class CapturingBoundNetLog { | 82 class CapturingBoundNetLog { |
| 87 public: | 83 public: |
| 88 CapturingBoundNetLog(const NetLog::Source& source, CapturingNetLog* net_log); | 84 CapturingBoundNetLog(const NetLog::Source& source, CapturingNetLog* net_log); |
| 89 | 85 |
| 90 explicit CapturingBoundNetLog(size_t max_num_entries); | 86 explicit CapturingBoundNetLog(size_t max_num_entries); |
| 91 | 87 |
| 92 ~CapturingBoundNetLog(); | 88 ~CapturingBoundNetLog(); |
| 93 | 89 |
| 94 // The returned BoundNetLog is only valid while |this| is alive. | 90 // The returned BoundNetLog is only valid while |this| is alive. |
| 95 BoundNetLog bound() const { | 91 BoundNetLog bound() const { |
| 96 return BoundNetLog(source_, capturing_net_log_.get()); | 92 return BoundNetLog(source_, capturing_net_log_.get()); |
| 97 } | 93 } |
| 98 | 94 |
| 99 // Fills |entry_list| with all entries in the log. | 95 // Fills |entry_list| with all entries in the log. |
| 100 void GetEntries(CapturingNetLog::EntryList* entry_list) const; | 96 void GetEntries(CapturingNetLog::EntryList* entry_list) const; |
| 101 | 97 |
| 102 void Clear(); | 98 void Clear(); |
| 103 | 99 |
| 104 // Sets the log level of the underlying CapturingNetLog. | |
| 105 void SetLogLevel(NetLog::LogLevel log_level); | |
| 106 | |
| 107 private: | 100 private: |
| 108 NetLog::Source source_; | 101 NetLog::Source source_; |
| 109 scoped_ptr<CapturingNetLog> capturing_net_log_; | 102 scoped_ptr<CapturingNetLog> capturing_net_log_; |
| 110 | 103 |
| 111 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog); | 104 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog); |
| 112 }; | 105 }; |
| 113 | 106 |
| 114 } // namespace net | 107 } // namespace net |
| 115 | 108 |
| 116 #endif // NET_BASE_CAPTURING_NET_LOG_H_ | 109 #endif // NET_BASE_CAPTURING_NET_LOG_H_ |
| 117 | 110 |
| OLD | NEW |