| 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/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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 NetLog::LogLevel NetLog::ThreadSafeObserver::log_level() const { | 70 NetLog::LogLevel NetLog::ThreadSafeObserver::log_level() const { |
| 71 DCHECK(net_log_); | 71 DCHECK(net_log_); |
| 72 return log_level_; | 72 return log_level_; |
| 73 } | 73 } |
| 74 | 74 |
| 75 NetLog* NetLog::ThreadSafeObserver::net_log() const { | 75 NetLog* NetLog::ThreadSafeObserver::net_log() const { |
| 76 return net_log_; | 76 return net_log_; |
| 77 } | 77 } |
| 78 | 78 |
| 79 void NetLog::AddGlobalEntry(EventType type, |
| 80 const scoped_refptr<EventParameters>& params) { |
| 81 AddEntry(type, |
| 82 Source(net::NetLog::SOURCE_NONE, this->NextID()), |
| 83 net::NetLog::PHASE_NONE, |
| 84 params); |
| 85 } |
| 86 |
| 79 // static | 87 // static |
| 80 std::string NetLog::TickCountToString(const base::TimeTicks& time) { | 88 std::string NetLog::TickCountToString(const base::TimeTicks& time) { |
| 81 int64 delta_time = (time - base::TimeTicks()).InMilliseconds(); | 89 int64 delta_time = (time - base::TimeTicks()).InMilliseconds(); |
| 82 return base::Int64ToString(delta_time); | 90 return base::Int64ToString(delta_time); |
| 83 } | 91 } |
| 84 | 92 |
| 85 // static | 93 // static |
| 86 const char* NetLog::EventTypeToString(EventType event) { | 94 const char* NetLog::EventTypeToString(EventType event) { |
| 87 switch (event) { | 95 switch (event) { |
| 88 #define EVENT_TYPE(label) case TYPE_ ## label: return #label; | 96 #define EVENT_TYPE(label) case TYPE_ ## label: return #label; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 198 |
| 191 void NetLog::OnRemoveObserver(ThreadSafeObserver* observer) { | 199 void NetLog::OnRemoveObserver(ThreadSafeObserver* observer) { |
| 192 DCHECK_EQ(this, observer->net_log_); | 200 DCHECK_EQ(this, observer->net_log_); |
| 193 observer->net_log_ = NULL; | 201 observer->net_log_ = NULL; |
| 194 } | 202 } |
| 195 | 203 |
| 196 void BoundNetLog::AddEntry( | 204 void BoundNetLog::AddEntry( |
| 197 NetLog::EventType type, | 205 NetLog::EventType type, |
| 198 NetLog::EventPhase phase, | 206 NetLog::EventPhase phase, |
| 199 const scoped_refptr<NetLog::EventParameters>& params) const { | 207 const scoped_refptr<NetLog::EventParameters>& params) const { |
| 200 if (net_log_) { | 208 if (net_log_) |
| 201 net_log_->AddEntry(type, base::TimeTicks::Now(), source_, phase, params); | 209 net_log_->AddEntry(type, source_, phase, params); |
| 202 } | |
| 203 } | |
| 204 | |
| 205 void BoundNetLog::AddEntryWithTime( | |
| 206 NetLog::EventType type, | |
| 207 const base::TimeTicks& time, | |
| 208 NetLog::EventPhase phase, | |
| 209 const scoped_refptr<NetLog::EventParameters>& params) const { | |
| 210 if (net_log_) { | |
| 211 net_log_->AddEntry(type, time, source_, phase, params); | |
| 212 } | |
| 213 } | 210 } |
| 214 | 211 |
| 215 void BoundNetLog::AddEvent( | 212 void BoundNetLog::AddEvent( |
| 216 NetLog::EventType event_type, | 213 NetLog::EventType event_type, |
| 217 const scoped_refptr<NetLog::EventParameters>& params) const { | 214 const scoped_refptr<NetLog::EventParameters>& params) const { |
| 218 AddEntry(event_type, NetLog::PHASE_NONE, params); | 215 AddEntry(event_type, NetLog::PHASE_NONE, params); |
| 219 } | 216 } |
| 220 | 217 |
| 221 void BoundNetLog::BeginEvent( | 218 void BoundNetLog::BeginEvent( |
| 222 NetLog::EventType event_type, | 219 NetLog::EventType event_type, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 const scoped_refptr<NetLog::EventParameters>& end_event_params) { | 328 const scoped_refptr<NetLog::EventParameters>& end_event_params) { |
| 332 DCHECK(!end_event_params_.get()); | 329 DCHECK(!end_event_params_.get()); |
| 333 end_event_params_ = end_event_params; | 330 end_event_params_ = end_event_params; |
| 334 } | 331 } |
| 335 | 332 |
| 336 const BoundNetLog& ScopedNetLogEvent::net_log() const { | 333 const BoundNetLog& ScopedNetLogEvent::net_log() const { |
| 337 return net_log_; | 334 return net_log_; |
| 338 } | 335 } |
| 339 | 336 |
| 340 } // namespace net | 337 } // namespace net |
| OLD | NEW |