| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 void CapturingNetLog::Clear() { | 73 void CapturingNetLog::Clear() { |
| 74 base::AutoLock lock(lock_); | 74 base::AutoLock lock(lock_); |
| 75 captured_entries_.clear(); | 75 captured_entries_.clear(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void CapturingNetLog::SetLogLevel(NetLog::LogLevel log_level) { | 78 void CapturingNetLog::SetLogLevel(NetLog::LogLevel log_level) { |
| 79 base::AutoLock lock(lock_); | 79 base::AutoLock lock(lock_); |
| 80 log_level_ = log_level; | 80 log_level_ = log_level; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void CapturingNetLog::AddEntry( | 83 void CapturingNetLog::OnAddEntry(const net::NetLog::Entry& entry) { |
| 84 EventType type, | |
| 85 const Source& source, | |
| 86 EventPhase phase, | |
| 87 const scoped_refptr<EventParameters>& extra_parameters) { | |
| 88 // Only BoundNetLogs without a NetLog should have an invalid source. | 84 // Only BoundNetLogs without a NetLog should have an invalid source. |
| 89 DCHECK(source.is_valid()); | 85 DCHECK(entry.source().is_valid()); |
| 90 | 86 |
| 91 // Using Dictionaries instead of Values makes checking values a little | 87 // Using Dictionaries instead of Values makes checking values a little |
| 92 // simpler. | 88 // simpler. |
| 93 DictionaryValue* param_dict = NULL; | 89 DictionaryValue* param_dict = NULL; |
| 94 if (extra_parameters) { | 90 Value* param_value = entry.ParametersToValue(); |
| 95 Value* param_value = extra_parameters->ToValue(); | 91 if (param_value && !param_value->GetAsDictionary(¶m_dict)) |
| 96 if (param_value && !param_value->GetAsDictionary(¶m_dict)) | 92 delete param_value; |
| 97 delete param_value; | |
| 98 } | |
| 99 | 93 |
| 100 // Only need to acquire the lock when accessing class variables. | 94 // Only need to acquire the lock when accessing class variables. |
| 101 base::AutoLock lock(lock_); | 95 base::AutoLock lock(lock_); |
| 102 captured_entries_.push_back( | 96 captured_entries_.push_back( |
| 103 CapturedEntry(type, | 97 CapturedEntry(entry.type(), |
| 104 base::TimeTicks::Now(), | 98 base::TimeTicks::Now(), |
| 105 source, | 99 entry.source(), |
| 106 phase, | 100 entry.phase(), |
| 107 scoped_ptr<DictionaryValue>(param_dict))); | 101 scoped_ptr<DictionaryValue>(param_dict))); |
| 108 } | 102 } |
| 109 | 103 |
| 110 uint32 CapturingNetLog::NextID() { | 104 uint32 CapturingNetLog::NextID() { |
| 111 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1); | 105 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1); |
| 112 } | 106 } |
| 113 | 107 |
| 114 NetLog::LogLevel CapturingNetLog::GetLogLevel() const { | 108 NetLog::LogLevel CapturingNetLog::GetLogLevel() const { |
| 115 base::AutoLock lock(lock_); | 109 base::AutoLock lock(lock_); |
| 116 return log_level_; | 110 return log_level_; |
| (...skipping 29 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 |