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