| 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 #include "base/logging.h" | 7 #include "base/logging.h" |
| 7 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 8 #include "base/time.h" | 9 #include "base/time.h" |
| 9 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "net/base/net_errors.h" |
| 11 | 13 |
| 12 namespace net { | 14 namespace net { |
| 13 | 15 |
| 14 Value* NetLog::Source::ToValue() const { | 16 Value* NetLog::Source::ToValue() const { |
| 15 DictionaryValue* dict = new DictionaryValue(); | 17 DictionaryValue* dict = new DictionaryValue(); |
| 16 dict->SetInteger("type", static_cast<int>(type)); | 18 dict->SetInteger("type", static_cast<int>(type)); |
| 17 dict->SetInteger("id", static_cast<int>(id)); | 19 dict->SetInteger("id", static_cast<int>(id)); |
| 18 return dict; | 20 return dict; |
| 19 } | 21 } |
| 20 | 22 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 const scoped_refptr<NetLog::EventParameters>& params) const { | 152 const scoped_refptr<NetLog::EventParameters>& params) const { |
| 151 AddEntry(event_type, NetLog::PHASE_BEGIN, params); | 153 AddEntry(event_type, NetLog::PHASE_BEGIN, params); |
| 152 } | 154 } |
| 153 | 155 |
| 154 void BoundNetLog::EndEvent( | 156 void BoundNetLog::EndEvent( |
| 155 NetLog::EventType event_type, | 157 NetLog::EventType event_type, |
| 156 const scoped_refptr<NetLog::EventParameters>& params) const { | 158 const scoped_refptr<NetLog::EventParameters>& params) const { |
| 157 AddEntry(event_type, NetLog::PHASE_END, params); | 159 AddEntry(event_type, NetLog::PHASE_END, params); |
| 158 } | 160 } |
| 159 | 161 |
| 162 void BoundNetLog::EndEventWithNetErrorCode(NetLog::EventType event_type, |
| 163 int net_error) const { |
| 164 DCHECK_NE(net_error, net::ERR_IO_PENDING); |
| 165 if (net_error >= 0) { |
| 166 EndEvent(event_type, NULL); |
| 167 } else { |
| 168 EndEvent( |
| 169 event_type, |
| 170 make_scoped_refptr(new NetLogIntegerParameter("net_error", net_error))); |
| 171 } |
| 172 } |
| 173 |
| 160 // static | 174 // static |
| 161 BoundNetLog BoundNetLog::Make(NetLog* net_log, | 175 BoundNetLog BoundNetLog::Make(NetLog* net_log, |
| 162 NetLog::SourceType source_type) { | 176 NetLog::SourceType source_type) { |
| 163 if (!net_log) | 177 if (!net_log) |
| 164 return BoundNetLog(); | 178 return BoundNetLog(); |
| 165 | 179 |
| 166 NetLog::Source source(source_type, net_log->NextID()); | 180 NetLog::Source source(source_type, net_log->NextID()); |
| 167 return BoundNetLog(source, net_log); | 181 return BoundNetLog(source, net_log); |
| 168 } | 182 } |
| 169 | 183 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 const scoped_refptr<NetLog::EventParameters>& end_event_params) { | 225 const scoped_refptr<NetLog::EventParameters>& end_event_params) { |
| 212 DCHECK(!end_event_params_.get()); | 226 DCHECK(!end_event_params_.get()); |
| 213 end_event_params_ = end_event_params; | 227 end_event_params_ = end_event_params; |
| 214 } | 228 } |
| 215 | 229 |
| 216 const BoundNetLog& ScopedNetLogEvent::net_log() const { | 230 const BoundNetLog& ScopedNetLogEvent::net_log() const { |
| 217 return net_log_; | 231 return net_log_; |
| 218 } | 232 } |
| 219 | 233 |
| 220 } // namespace net | 234 } // namespace net |
| OLD | NEW |