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 #include "net/base/net_log.h" | 5 #include "net/base/net_log.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 void BoundNetLog::AddEntryWithTime( | 120 void BoundNetLog::AddEntryWithTime( |
121 NetLog::EventType type, | 121 NetLog::EventType type, |
122 const base::TimeTicks& time, | 122 const base::TimeTicks& time, |
123 NetLog::EventPhase phase, | 123 NetLog::EventPhase phase, |
124 const scoped_refptr<NetLog::EventParameters>& params) const { | 124 const scoped_refptr<NetLog::EventParameters>& params) const { |
125 if (net_log_) { | 125 if (net_log_) { |
126 net_log_->AddEntry(type, time, source_, phase, params); | 126 net_log_->AddEntry(type, time, source_, phase, params); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 NetLog::LogLevel BoundNetLog::GetLogLevel() const { | |
131 if (net_log_) | |
132 return net_log_->GetLogLevel(); | |
133 return NetLog::LOG_BASIC; | |
134 } | |
135 | |
136 bool BoundNetLog::IsLoggingBytes() const { | |
137 return GetLogLevel() == NetLog::LOG_ALL; | |
138 } | |
139 | |
140 bool BoundNetLog::IsLoggingAllEvents() const { | |
141 return GetLogLevel() <= NetLog::LOG_ALL_BUT_BYTES; | |
142 } | |
143 | |
144 void BoundNetLog::AddEvent( | 130 void BoundNetLog::AddEvent( |
145 NetLog::EventType event_type, | 131 NetLog::EventType event_type, |
146 const scoped_refptr<NetLog::EventParameters>& params) const { | 132 const scoped_refptr<NetLog::EventParameters>& params) const { |
147 AddEntry(event_type, NetLog::PHASE_NONE, params); | 133 AddEntry(event_type, NetLog::PHASE_NONE, params); |
148 } | 134 } |
149 | 135 |
150 void BoundNetLog::BeginEvent( | 136 void BoundNetLog::BeginEvent( |
151 NetLog::EventType event_type, | 137 NetLog::EventType event_type, |
152 const scoped_refptr<NetLog::EventParameters>& params) const { | 138 const scoped_refptr<NetLog::EventParameters>& params) const { |
153 AddEntry(event_type, NetLog::PHASE_BEGIN, params); | 139 AddEntry(event_type, NetLog::PHASE_BEGIN, params); |
(...skipping 10 matching lines...) Expand all Loading... |
164 DCHECK_NE(net_error, net::ERR_IO_PENDING); | 150 DCHECK_NE(net_error, net::ERR_IO_PENDING); |
165 if (net_error >= 0) { | 151 if (net_error >= 0) { |
166 EndEvent(event_type, NULL); | 152 EndEvent(event_type, NULL); |
167 } else { | 153 } else { |
168 EndEvent( | 154 EndEvent( |
169 event_type, | 155 event_type, |
170 make_scoped_refptr(new NetLogIntegerParameter("net_error", net_error))); | 156 make_scoped_refptr(new NetLogIntegerParameter("net_error", net_error))); |
171 } | 157 } |
172 } | 158 } |
173 | 159 |
| 160 NetLog::LogLevel BoundNetLog::GetLogLevel() const { |
| 161 if (net_log_) |
| 162 return net_log_->GetLogLevel(); |
| 163 return NetLog::LOG_BASIC; |
| 164 } |
| 165 |
| 166 bool BoundNetLog::IsLoggingBytes() const { |
| 167 return GetLogLevel() == NetLog::LOG_ALL; |
| 168 } |
| 169 |
| 170 bool BoundNetLog::IsLoggingAllEvents() const { |
| 171 return GetLogLevel() <= NetLog::LOG_ALL_BUT_BYTES; |
| 172 } |
| 173 |
174 // static | 174 // static |
175 BoundNetLog BoundNetLog::Make(NetLog* net_log, | 175 BoundNetLog BoundNetLog::Make(NetLog* net_log, |
176 NetLog::SourceType source_type) { | 176 NetLog::SourceType source_type) { |
177 if (!net_log) | 177 if (!net_log) |
178 return BoundNetLog(); | 178 return BoundNetLog(); |
179 | 179 |
180 NetLog::Source source(source_type, net_log->NextID()); | 180 NetLog::Source source(source_type, net_log->NextID()); |
181 return BoundNetLog(source, net_log); | 181 return BoundNetLog(source, net_log); |
182 } | 182 } |
183 | 183 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 const scoped_refptr<NetLog::EventParameters>& end_event_params) { | 225 const scoped_refptr<NetLog::EventParameters>& end_event_params) { |
226 DCHECK(!end_event_params_.get()); | 226 DCHECK(!end_event_params_.get()); |
227 end_event_params_ = end_event_params; | 227 end_event_params_ = end_event_params; |
228 } | 228 } |
229 | 229 |
230 const BoundNetLog& ScopedNetLogEvent::net_log() const { | 230 const BoundNetLog& ScopedNetLogEvent::net_log() const { |
231 return net_log_; | 231 return net_log_; |
232 } | 232 } |
233 | 233 |
234 } // namespace net | 234 } // namespace net |
OLD | NEW |