| 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 #include "net/base/capturing_net_log.h" | 5 #include "net/base/capturing_net_log.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 void CapturingNetLog::Clear() { | 74 void CapturingNetLog::Clear() { |
| 75 base::AutoLock lock(lock_); | 75 base::AutoLock lock(lock_); |
| 76 captured_entries_.clear(); | 76 captured_entries_.clear(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void CapturingNetLog::SetLogLevel(NetLog::LogLevel log_level) { | 79 void CapturingNetLog::SetLogLevel(NetLog::LogLevel log_level) { |
| 80 base::AutoLock lock(lock_); | 80 base::AutoLock lock(lock_); |
| 81 log_level_ = log_level; | 81 log_level_ = log_level; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void CapturingNetLog::AddEntry( | 84 void CapturingNetLog::OnAddEntry(const net::NetLog::Entry& entry) { |
| 85 EventType type, | 85 DCHECK(entry.source().is_valid()); |
| 86 const Source& source, | |
| 87 EventPhase phase, | |
| 88 const scoped_refptr<EventParameters>& extra_parameters) { | |
| 89 DCHECK(source.is_valid()); | |
| 90 base::AutoLock lock(lock_); | 86 base::AutoLock lock(lock_); |
| 91 if (captured_entries_.size() >= max_num_entries_) | 87 if (captured_entries_.size() >= max_num_entries_) |
| 92 return; | 88 return; |
| 93 // Using Dictionaries instead of Values makes checking values a little | 89 // Using Dictionaries instead of Values makes checking values a little |
| 94 // simpler. | 90 // simpler. |
| 95 DictionaryValue* param_dict = NULL; | 91 DictionaryValue* param_dict = NULL; |
| 96 if (extra_parameters) { | 92 Value* param_value = entry.ParametersToValue(); |
| 97 Value* param_value = extra_parameters->ToValue(); | 93 if (param_value && !param_value->GetAsDictionary(¶m_dict)) |
| 98 if (param_value && !param_value->GetAsDictionary(¶m_dict)) | 94 delete param_value; |
| 99 delete param_value; | |
| 100 } | |
| 101 captured_entries_.push_back( | 95 captured_entries_.push_back( |
| 102 CapturedEntry(type, | 96 CapturedEntry(entry.type(), |
| 103 base::TimeTicks::Now(), | 97 base::TimeTicks::Now(), |
| 104 source, | 98 entry.source(), |
| 105 phase, | 99 entry.phase(), |
| 106 scoped_ptr<DictionaryValue>(param_dict))); | 100 scoped_ptr<DictionaryValue>(param_dict))); |
| 107 } | 101 } |
| 108 | 102 |
| 109 uint32 CapturingNetLog::NextID() { | 103 uint32 CapturingNetLog::NextID() { |
| 110 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1); | 104 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1); |
| 111 } | 105 } |
| 112 | 106 |
| 113 NetLog::LogLevel CapturingNetLog::GetLogLevel() const { | 107 NetLog::LogLevel CapturingNetLog::GetLogLevel() const { |
| 114 base::AutoLock lock(lock_); | 108 base::AutoLock lock(lock_); |
| 115 return log_level_; | 109 return log_level_; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 146 | 140 |
| 147 void CapturingBoundNetLog::Clear() { | 141 void CapturingBoundNetLog::Clear() { |
| 148 capturing_net_log_.Clear(); | 142 capturing_net_log_.Clear(); |
| 149 } | 143 } |
| 150 | 144 |
| 151 void CapturingBoundNetLog::SetLogLevel(NetLog::LogLevel log_level) { | 145 void CapturingBoundNetLog::SetLogLevel(NetLog::LogLevel log_level) { |
| 152 capturing_net_log_.SetLogLevel(log_level); | 146 capturing_net_log_.SetLogLevel(log_level); |
| 153 } | 147 } |
| 154 | 148 |
| 155 } // namespace net | 149 } // namespace net |
| OLD | NEW |