| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 const scoped_refptr<NetLog::EventParameters>& params) const { | 185 const scoped_refptr<NetLog::EventParameters>& params) const { |
| 186 AddEntry(event_type, NetLog::PHASE_BEGIN, params); | 186 AddEntry(event_type, NetLog::PHASE_BEGIN, params); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void BoundNetLog::EndEvent( | 189 void BoundNetLog::EndEvent( |
| 190 NetLog::EventType event_type, | 190 NetLog::EventType event_type, |
| 191 const scoped_refptr<NetLog::EventParameters>& params) const { | 191 const scoped_refptr<NetLog::EventParameters>& params) const { |
| 192 AddEntry(event_type, NetLog::PHASE_END, params); | 192 AddEntry(event_type, NetLog::PHASE_END, params); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void BoundNetLog::AddEventWithNetErrorCode(NetLog::EventType event_type, |
| 196 int net_error) const { |
| 197 DCHECK_GT(0, net_error); |
| 198 DCHECK_NE(ERR_IO_PENDING, net_error); |
| 199 AddEvent( |
| 200 event_type, |
| 201 make_scoped_refptr(new NetLogIntegerParameter("net_error", net_error))); |
| 202 } |
| 203 |
| 195 void BoundNetLog::EndEventWithNetErrorCode(NetLog::EventType event_type, | 204 void BoundNetLog::EndEventWithNetErrorCode(NetLog::EventType event_type, |
| 196 int net_error) const { | 205 int net_error) const { |
| 197 DCHECK_NE(net_error, ERR_IO_PENDING); | 206 DCHECK_NE(ERR_IO_PENDING, net_error); |
| 198 if (net_error >= 0) { | 207 if (net_error >= 0) { |
| 199 EndEvent(event_type, NULL); | 208 EndEvent(event_type, NULL); |
| 200 } else { | 209 } else { |
| 201 EndEvent( | 210 EndEvent( |
| 202 event_type, | 211 event_type, |
| 203 make_scoped_refptr(new NetLogIntegerParameter("net_error", net_error))); | 212 make_scoped_refptr(new NetLogIntegerParameter("net_error", net_error))); |
| 204 } | 213 } |
| 205 } | 214 } |
| 206 | 215 |
| 207 void BoundNetLog::AddByteTransferEvent(NetLog::EventType event_type, | 216 void BoundNetLog::AddByteTransferEvent(NetLog::EventType event_type, |
| 208 int byte_count, char* bytes) const { | 217 int byte_count, |
| 218 const char* bytes) const { |
| 209 scoped_refptr<NetLog::EventParameters> params; | 219 scoped_refptr<NetLog::EventParameters> params; |
| 210 if (IsLoggingBytes()) { | 220 if (IsLoggingBytes()) { |
| 211 params = new NetLogBytesTransferredParameter(byte_count, bytes); | 221 params = new NetLogBytesTransferredParameter(byte_count, bytes); |
| 212 } else { | 222 } else { |
| 213 params = new NetLogBytesTransferredParameter(byte_count, NULL); | 223 params = new NetLogBytesTransferredParameter(byte_count, NULL); |
| 214 } | 224 } |
| 215 AddEvent(event_type, params); | 225 AddEvent(event_type, params); |
| 216 } | 226 } |
| 217 | 227 |
| 218 NetLog::LogLevel BoundNetLog::GetLogLevel() const { | 228 NetLog::LogLevel BoundNetLog::GetLogLevel() const { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 const scoped_refptr<NetLog::EventParameters>& end_event_params) { | 293 const scoped_refptr<NetLog::EventParameters>& end_event_params) { |
| 284 DCHECK(!end_event_params_.get()); | 294 DCHECK(!end_event_params_.get()); |
| 285 end_event_params_ = end_event_params; | 295 end_event_params_ = end_event_params; |
| 286 } | 296 } |
| 287 | 297 |
| 288 const BoundNetLog& ScopedNetLogEvent::net_log() const { | 298 const BoundNetLog& ScopedNetLogEvent::net_log() const { |
| 289 return net_log_; | 299 return net_log_; |
| 290 } | 300 } |
| 291 | 301 |
| 292 } // namespace net | 302 } // namespace net |
| OLD | NEW |