| 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/log/net_log.h" | 5 #include "net/log/net_log.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 new base::DictionaryValue()); | 103 new base::DictionaryValue()); |
| 104 event_params->SetString(name, *value); | 104 event_params->SetString(name, *value); |
| 105 return std::move(event_params); | 105 return std::move(event_params); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace | 108 } // namespace |
| 109 | 109 |
| 110 // LoadTimingInfo requires this be 0. | 110 // LoadTimingInfo requires this be 0. |
| 111 const uint32_t NetLog::Source::kInvalidId = 0; | 111 const uint32_t NetLog::Source::kInvalidId = 0; |
| 112 | 112 |
| 113 NetLog::Source::Source() : type(SOURCE_NONE), id(kInvalidId) { | 113 NetLog::Source::Source() : type(NetLogSourceType::NONE), id(kInvalidId) {} |
| 114 } | |
| 115 | 114 |
| 116 NetLog::Source::Source(SourceType type, uint32_t id) : type(type), id(id) {} | 115 NetLog::Source::Source(NetLogSourceType type, uint32_t id) |
| 116 : type(type), id(id) {} |
| 117 | 117 |
| 118 bool NetLog::Source::IsValid() const { | 118 bool NetLog::Source::IsValid() const { |
| 119 return id != kInvalidId; | 119 return id != kInvalidId; |
| 120 } | 120 } |
| 121 | 121 |
| 122 void NetLog::Source::AddToEventParameters( | 122 void NetLog::Source::AddToEventParameters( |
| 123 base::DictionaryValue* event_params) const { | 123 base::DictionaryValue* event_params) const { |
| 124 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 124 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 125 dict->SetInteger("type", static_cast<int>(type)); | 125 dict->SetInteger("type", static_cast<int>(type)); |
| 126 dict->SetInteger("id", static_cast<int>(id)); | 126 dict->SetInteger("id", static_cast<int>(id)); |
| 127 event_params->Set("source_dependency", std::move(dict)); | 127 event_params->Set("source_dependency", std::move(dict)); |
| 128 } | 128 } |
| 129 | 129 |
| 130 NetLog::ParametersCallback NetLog::Source::ToEventParametersCallback() const { | 130 NetLog::ParametersCallback NetLog::Source::ToEventParametersCallback() const { |
| 131 return base::Bind(&SourceEventParametersCallback, *this); | 131 return base::Bind(&SourceEventParametersCallback, *this); |
| 132 } | 132 } |
| 133 | 133 |
| 134 // static | 134 // static |
| 135 bool NetLog::Source::FromEventParameters(base::Value* event_params, | 135 bool NetLog::Source::FromEventParameters(base::Value* event_params, |
| 136 Source* source) { | 136 Source* source) { |
| 137 base::DictionaryValue* dict = NULL; | 137 base::DictionaryValue* dict = NULL; |
| 138 base::DictionaryValue* source_dict = NULL; | 138 base::DictionaryValue* source_dict = NULL; |
| 139 int source_id = -1; | 139 int source_id = -1; |
| 140 int source_type = NetLog::SOURCE_COUNT; | 140 int source_type = static_cast<int>(NetLogSourceType::COUNT); |
| 141 if (!event_params || !event_params->GetAsDictionary(&dict) || | 141 if (!event_params || !event_params->GetAsDictionary(&dict) || |
| 142 !dict->GetDictionary("source_dependency", &source_dict) || | 142 !dict->GetDictionary("source_dependency", &source_dict) || |
| 143 !source_dict->GetInteger("id", &source_id) || | 143 !source_dict->GetInteger("id", &source_id) || |
| 144 !source_dict->GetInteger("type", &source_type)) { | 144 !source_dict->GetInteger("type", &source_type)) { |
| 145 *source = Source(); | 145 *source = Source(); |
| 146 return false; | 146 return false; |
| 147 } | 147 } |
| 148 | 148 |
| 149 DCHECK_GE(source_id, 0); | 149 DCHECK_GE(source_id, 0); |
| 150 DCHECK_LT(source_type, NetLog::SOURCE_COUNT); | 150 DCHECK_LT(source_type, static_cast<int>(NetLogSourceType::COUNT)); |
| 151 *source = Source(static_cast<SourceType>(source_type), source_id); | 151 *source = Source(static_cast<NetLogSourceType>(source_type), source_id); |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 | 154 |
| 155 std::unique_ptr<base::Value> NetLog::Entry::ToValue() const { | 155 std::unique_ptr<base::Value> NetLog::Entry::ToValue() const { |
| 156 std::unique_ptr<base::DictionaryValue> entry_dict( | 156 std::unique_ptr<base::DictionaryValue> entry_dict( |
| 157 new base::DictionaryValue()); | 157 new base::DictionaryValue()); |
| 158 | 158 |
| 159 entry_dict->SetString("time", TickCountToString(data_->time)); | 159 entry_dict->SetString("time", TickCountToString(data_->time)); |
| 160 | 160 |
| 161 // Set the entry source. | 161 // Set the entry source. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 179 | 179 |
| 180 return std::move(entry_dict); | 180 return std::move(entry_dict); |
| 181 } | 181 } |
| 182 | 182 |
| 183 std::unique_ptr<base::Value> NetLog::Entry::ParametersToValue() const { | 183 std::unique_ptr<base::Value> NetLog::Entry::ParametersToValue() const { |
| 184 if (data_->parameters_callback) | 184 if (data_->parameters_callback) |
| 185 return data_->parameters_callback->Run(capture_mode_); | 185 return data_->parameters_callback->Run(capture_mode_); |
| 186 return nullptr; | 186 return nullptr; |
| 187 } | 187 } |
| 188 | 188 |
| 189 NetLog::EntryData::EntryData(EventType type, | 189 NetLog::EntryData::EntryData(NetLogEventType type, |
| 190 Source source, | 190 Source source, |
| 191 EventPhase phase, | 191 NetLogEventPhase phase, |
| 192 base::TimeTicks time, | 192 base::TimeTicks time, |
| 193 const ParametersCallback* parameters_callback) | 193 const ParametersCallback* parameters_callback) |
| 194 : type(type), | 194 : type(type), |
| 195 source(source), | 195 source(source), |
| 196 phase(phase), | 196 phase(phase), |
| 197 time(time), | 197 time(time), |
| 198 parameters_callback(parameters_callback) { | 198 parameters_callback(parameters_callback) {} |
| 199 } | |
| 200 | 199 |
| 201 NetLog::EntryData::~EntryData() { | 200 NetLog::EntryData::~EntryData() { |
| 202 } | 201 } |
| 203 | 202 |
| 204 NetLog::Entry::Entry(const EntryData* data, NetLogCaptureMode capture_mode) | 203 NetLog::Entry::Entry(const EntryData* data, NetLogCaptureMode capture_mode) |
| 205 : data_(data), capture_mode_(capture_mode) { | 204 : data_(data), capture_mode_(capture_mode) { |
| 206 } | 205 } |
| 207 | 206 |
| 208 NetLog::Entry::~Entry() { | 207 NetLog::Entry::~Entry() { |
| 209 } | 208 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 230 void NetLog::ThreadSafeObserver::OnAddEntryData(const EntryData& entry_data) { | 229 void NetLog::ThreadSafeObserver::OnAddEntryData(const EntryData& entry_data) { |
| 231 OnAddEntry(Entry(&entry_data, capture_mode())); | 230 OnAddEntry(Entry(&entry_data, capture_mode())); |
| 232 } | 231 } |
| 233 | 232 |
| 234 NetLog::NetLog() : last_id_(0), is_capturing_(0) { | 233 NetLog::NetLog() : last_id_(0), is_capturing_(0) { |
| 235 } | 234 } |
| 236 | 235 |
| 237 NetLog::~NetLog() { | 236 NetLog::~NetLog() { |
| 238 } | 237 } |
| 239 | 238 |
| 240 void NetLog::AddGlobalEntry(EventType type) { | 239 void NetLog::AddGlobalEntry(NetLogEventType type) { |
| 241 AddEntry(type, Source(NetLog::SOURCE_NONE, NextID()), NetLog::PHASE_NONE, | 240 AddEntry(type, Source(NetLogSourceType::NONE, NextID()), |
| 242 NULL); | 241 NetLogEventPhase::NONE, NULL); |
| 243 } | 242 } |
| 244 | 243 |
| 245 void NetLog::AddGlobalEntry( | 244 void NetLog::AddGlobalEntry( |
| 246 EventType type, | 245 NetLogEventType type, |
| 247 const NetLog::ParametersCallback& parameters_callback) { | 246 const NetLog::ParametersCallback& parameters_callback) { |
| 248 AddEntry(type, Source(NetLog::SOURCE_NONE, NextID()), NetLog::PHASE_NONE, | 247 AddEntry(type, Source(NetLogSourceType::NONE, NextID()), |
| 249 ¶meters_callback); | 248 NetLogEventPhase::NONE, ¶meters_callback); |
| 250 } | 249 } |
| 251 | 250 |
| 252 uint32_t NetLog::NextID() { | 251 uint32_t NetLog::NextID() { |
| 253 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1); | 252 return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1); |
| 254 } | 253 } |
| 255 | 254 |
| 256 bool NetLog::IsCapturing() const { | 255 bool NetLog::IsCapturing() const { |
| 257 return base::subtle::NoBarrier_Load(&is_capturing_) != 0; | 256 return base::subtle::NoBarrier_Load(&is_capturing_) != 0; |
| 258 } | 257 } |
| 259 | 258 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 observers_.might_have_observers() ? 1 : 0); | 293 observers_.might_have_observers() ? 1 : 0); |
| 295 } | 294 } |
| 296 | 295 |
| 297 // static | 296 // static |
| 298 std::string NetLog::TickCountToString(const base::TimeTicks& time) { | 297 std::string NetLog::TickCountToString(const base::TimeTicks& time) { |
| 299 int64_t delta_time = (time - base::TimeTicks()).InMilliseconds(); | 298 int64_t delta_time = (time - base::TimeTicks()).InMilliseconds(); |
| 300 return base::Int64ToString(delta_time); | 299 return base::Int64ToString(delta_time); |
| 301 } | 300 } |
| 302 | 301 |
| 303 // static | 302 // static |
| 304 const char* NetLog::EventTypeToString(EventType event) { | 303 const char* NetLog::EventTypeToString(NetLogEventType event) { |
| 305 switch (event) { | 304 switch (event) { |
| 306 #define EVENT_TYPE(label) \ | 305 #define EVENT_TYPE(label) \ |
| 307 case TYPE_##label: \ | 306 case NetLogEventType::label: \ |
| 308 return #label; | 307 return #label; |
| 309 #include "net/log/net_log_event_type_list.h" | 308 #include "net/log/net_log_event_type_list.h" |
| 310 #undef EVENT_TYPE | 309 #undef EVENT_TYPE |
| 311 default: | 310 default: |
| 312 NOTREACHED(); | 311 NOTREACHED(); |
| 313 return NULL; | 312 return NULL; |
| 314 } | 313 } |
| 315 } | 314 } |
| 316 | 315 |
| 317 // static | 316 // static |
| 318 base::Value* NetLog::GetEventTypesAsValue() { | 317 base::Value* NetLog::GetEventTypesAsValue() { |
| 319 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 318 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 320 for (int i = 0; i < EVENT_COUNT; ++i) { | 319 for (int i = 0; i < static_cast<int>(NetLogEventType::COUNT); ++i) { |
| 321 dict->SetInteger(EventTypeToString(static_cast<EventType>(i)), i); | 320 dict->SetInteger(EventTypeToString(static_cast<NetLogEventType>(i)), i); |
| 322 } | 321 } |
| 323 return dict.release(); | 322 return dict.release(); |
| 324 } | 323 } |
| 325 | 324 |
| 326 // static | 325 // static |
| 327 const char* NetLog::SourceTypeToString(SourceType source) { | 326 const char* NetLog::SourceTypeToString(NetLogSourceType source) { |
| 328 switch (source) { | 327 switch (source) { |
| 329 #define SOURCE_TYPE(label) \ | 328 #define SOURCE_TYPE(label) \ |
| 330 case SOURCE_##label: \ | 329 case NetLogSourceType::label: \ |
| 331 return #label; | 330 return #label; |
| 332 #include "net/log/net_log_source_type_list.h" | 331 #include "net/log/net_log_source_type_list.h" |
| 333 #undef SOURCE_TYPE | 332 #undef SOURCE_TYPE |
| 334 default: | 333 default: |
| 335 NOTREACHED(); | 334 NOTREACHED(); |
| 336 return NULL; | 335 return NULL; |
| 337 } | 336 } |
| 338 } | 337 } |
| 339 | 338 |
| 340 // static | 339 // static |
| 341 base::Value* NetLog::GetSourceTypesAsValue() { | 340 base::Value* NetLog::GetSourceTypesAsValue() { |
| 342 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 341 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 343 for (int i = 0; i < SOURCE_COUNT; ++i) { | 342 for (int i = 0; i < static_cast<int>(NetLogSourceType::COUNT); ++i) { |
| 344 dict->SetInteger(SourceTypeToString(static_cast<SourceType>(i)), i); | 343 dict->SetInteger(SourceTypeToString(static_cast<NetLogSourceType>(i)), i); |
| 345 } | 344 } |
| 346 return dict.release(); | 345 return dict.release(); |
| 347 } | 346 } |
| 348 | 347 |
| 349 // static | 348 // static |
| 350 const char* NetLog::EventPhaseToString(EventPhase phase) { | 349 const char* NetLog::EventPhaseToString(NetLogEventPhase phase) { |
| 351 switch (phase) { | 350 switch (phase) { |
| 352 case PHASE_BEGIN: | 351 case NetLogEventPhase::BEGIN: |
| 353 return "PHASE_BEGIN"; | 352 return "PHASE_BEGIN"; |
| 354 case PHASE_END: | 353 case NetLogEventPhase::END: |
| 355 return "PHASE_END"; | 354 return "PHASE_END"; |
| 356 case PHASE_NONE: | 355 case NetLogEventPhase::NONE: |
| 357 return "PHASE_NONE"; | 356 return "PHASE_NONE"; |
| 358 } | 357 } |
| 359 NOTREACHED(); | 358 NOTREACHED(); |
| 360 return NULL; | 359 return NULL; |
| 361 } | 360 } |
| 362 | 361 |
| 363 // static | 362 // static |
| 364 NetLog::ParametersCallback NetLog::BoolCallback(const char* name, bool value) { | 363 NetLog::ParametersCallback NetLog::BoolCallback(const char* name, bool value) { |
| 365 return base::Bind(&NetLogBoolCallback, name, value); | 364 return base::Bind(&NetLogBoolCallback, name, value); |
| 366 } | 365 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 390 return base::Bind(&NetLogCharStringCallback, name, value); | 389 return base::Bind(&NetLogCharStringCallback, name, value); |
| 391 } | 390 } |
| 392 | 391 |
| 393 // static | 392 // static |
| 394 NetLog::ParametersCallback NetLog::StringCallback(const char* name, | 393 NetLog::ParametersCallback NetLog::StringCallback(const char* name, |
| 395 const base::string16* value) { | 394 const base::string16* value) { |
| 396 DCHECK(value); | 395 DCHECK(value); |
| 397 return base::Bind(&NetLogString16Callback, name, value); | 396 return base::Bind(&NetLogString16Callback, name, value); |
| 398 } | 397 } |
| 399 | 398 |
| 400 void NetLog::AddEntry(EventType type, | 399 void NetLog::AddEntry(NetLogEventType type, |
| 401 const Source& source, | 400 const Source& source, |
| 402 EventPhase phase, | 401 NetLogEventPhase phase, |
| 403 const NetLog::ParametersCallback* parameters_callback) { | 402 const NetLog::ParametersCallback* parameters_callback) { |
| 404 if (!IsCapturing()) | 403 if (!IsCapturing()) |
| 405 return; | 404 return; |
| 406 EntryData entry_data(type, source, phase, base::TimeTicks::Now(), | 405 EntryData entry_data(type, source, phase, base::TimeTicks::Now(), |
| 407 parameters_callback); | 406 parameters_callback); |
| 408 | 407 |
| 409 // Notify all of the log observers. | 408 // Notify all of the log observers. |
| 410 base::AutoLock lock(lock_); | 409 base::AutoLock lock(lock_); |
| 411 FOR_EACH_OBSERVER(ThreadSafeObserver, observers_, OnAddEntryData(entry_data)); | 410 FOR_EACH_OBSERVER(ThreadSafeObserver, observers_, OnAddEntryData(entry_data)); |
| 412 } | 411 } |
| 413 | 412 |
| 414 BoundNetLog::~BoundNetLog() { | 413 BoundNetLog::~BoundNetLog() { |
| 415 liveness_ = DEAD; | 414 liveness_ = DEAD; |
| 416 } | 415 } |
| 417 | 416 |
| 418 void BoundNetLog::AddEntry(NetLog::EventType type, | 417 void BoundNetLog::AddEntry(NetLogEventType type, NetLogEventPhase phase) const { |
| 419 NetLog::EventPhase phase) const { | |
| 420 CrashIfInvalid(); | 418 CrashIfInvalid(); |
| 421 | 419 |
| 422 if (!net_log_) | 420 if (!net_log_) |
| 423 return; | 421 return; |
| 424 net_log_->AddEntry(type, source_, phase, NULL); | 422 net_log_->AddEntry(type, source_, phase, NULL); |
| 425 } | 423 } |
| 426 | 424 |
| 427 void BoundNetLog::AddEntry( | 425 void BoundNetLog::AddEntry( |
| 428 NetLog::EventType type, | 426 NetLogEventType type, |
| 429 NetLog::EventPhase phase, | 427 NetLogEventPhase phase, |
| 430 const NetLog::ParametersCallback& get_parameters) const { | 428 const NetLog::ParametersCallback& get_parameters) const { |
| 431 CrashIfInvalid(); | 429 CrashIfInvalid(); |
| 432 | 430 |
| 433 if (!net_log_) | 431 if (!net_log_) |
| 434 return; | 432 return; |
| 435 net_log_->AddEntry(type, source_, phase, &get_parameters); | 433 net_log_->AddEntry(type, source_, phase, &get_parameters); |
| 436 } | 434 } |
| 437 | 435 |
| 438 void BoundNetLog::AddEvent(NetLog::EventType type) const { | 436 void BoundNetLog::AddEvent(NetLogEventType type) const { |
| 439 AddEntry(type, NetLog::PHASE_NONE); | 437 AddEntry(type, NetLogEventPhase::NONE); |
| 440 } | 438 } |
| 441 | 439 |
| 442 void BoundNetLog::AddEvent( | 440 void BoundNetLog::AddEvent( |
| 443 NetLog::EventType type, | 441 NetLogEventType type, |
| 444 const NetLog::ParametersCallback& get_parameters) const { | 442 const NetLog::ParametersCallback& get_parameters) const { |
| 445 AddEntry(type, NetLog::PHASE_NONE, get_parameters); | 443 AddEntry(type, NetLogEventPhase::NONE, get_parameters); |
| 446 } | 444 } |
| 447 | 445 |
| 448 void BoundNetLog::BeginEvent(NetLog::EventType type) const { | 446 void BoundNetLog::BeginEvent(NetLogEventType type) const { |
| 449 AddEntry(type, NetLog::PHASE_BEGIN); | 447 AddEntry(type, NetLogEventPhase::BEGIN); |
| 450 } | 448 } |
| 451 | 449 |
| 452 void BoundNetLog::BeginEvent( | 450 void BoundNetLog::BeginEvent( |
| 453 NetLog::EventType type, | 451 NetLogEventType type, |
| 454 const NetLog::ParametersCallback& get_parameters) const { | 452 const NetLog::ParametersCallback& get_parameters) const { |
| 455 AddEntry(type, NetLog::PHASE_BEGIN, get_parameters); | 453 AddEntry(type, NetLogEventPhase::BEGIN, get_parameters); |
| 456 } | 454 } |
| 457 | 455 |
| 458 void BoundNetLog::EndEvent(NetLog::EventType type) const { | 456 void BoundNetLog::EndEvent(NetLogEventType type) const { |
| 459 AddEntry(type, NetLog::PHASE_END); | 457 AddEntry(type, NetLogEventPhase::END); |
| 460 } | 458 } |
| 461 | 459 |
| 462 void BoundNetLog::EndEvent( | 460 void BoundNetLog::EndEvent( |
| 463 NetLog::EventType type, | 461 NetLogEventType type, |
| 464 const NetLog::ParametersCallback& get_parameters) const { | 462 const NetLog::ParametersCallback& get_parameters) const { |
| 465 AddEntry(type, NetLog::PHASE_END, get_parameters); | 463 AddEntry(type, NetLogEventPhase::END, get_parameters); |
| 466 } | 464 } |
| 467 | 465 |
| 468 void BoundNetLog::AddEventWithNetErrorCode(NetLog::EventType event_type, | 466 void BoundNetLog::AddEventWithNetErrorCode(NetLogEventType event_type, |
| 469 int net_error) const { | 467 int net_error) const { |
| 470 DCHECK_NE(ERR_IO_PENDING, net_error); | 468 DCHECK_NE(ERR_IO_PENDING, net_error); |
| 471 if (net_error >= 0) { | 469 if (net_error >= 0) { |
| 472 AddEvent(event_type); | 470 AddEvent(event_type); |
| 473 } else { | 471 } else { |
| 474 AddEvent(event_type, NetLog::IntCallback("net_error", net_error)); | 472 AddEvent(event_type, NetLog::IntCallback("net_error", net_error)); |
| 475 } | 473 } |
| 476 } | 474 } |
| 477 | 475 |
| 478 void BoundNetLog::EndEventWithNetErrorCode(NetLog::EventType event_type, | 476 void BoundNetLog::EndEventWithNetErrorCode(NetLogEventType event_type, |
| 479 int net_error) const { | 477 int net_error) const { |
| 480 DCHECK_NE(ERR_IO_PENDING, net_error); | 478 DCHECK_NE(ERR_IO_PENDING, net_error); |
| 481 if (net_error >= 0) { | 479 if (net_error >= 0) { |
| 482 EndEvent(event_type); | 480 EndEvent(event_type); |
| 483 } else { | 481 } else { |
| 484 EndEvent(event_type, NetLog::IntCallback("net_error", net_error)); | 482 EndEvent(event_type, NetLog::IntCallback("net_error", net_error)); |
| 485 } | 483 } |
| 486 } | 484 } |
| 487 | 485 |
| 488 void BoundNetLog::AddByteTransferEvent(NetLog::EventType event_type, | 486 void BoundNetLog::AddByteTransferEvent(NetLogEventType event_type, |
| 489 int byte_count, | 487 int byte_count, |
| 490 const char* bytes) const { | 488 const char* bytes) const { |
| 491 AddEvent(event_type, base::Bind(BytesTransferredCallback, byte_count, bytes)); | 489 AddEvent(event_type, base::Bind(BytesTransferredCallback, byte_count, bytes)); |
| 492 } | 490 } |
| 493 | 491 |
| 494 bool BoundNetLog::IsCapturing() const { | 492 bool BoundNetLog::IsCapturing() const { |
| 495 CrashIfInvalid(); | 493 CrashIfInvalid(); |
| 496 return net_log_ && net_log_->IsCapturing(); | 494 return net_log_ && net_log_->IsCapturing(); |
| 497 } | 495 } |
| 498 | 496 |
| 499 // static | 497 // static |
| 500 BoundNetLog BoundNetLog::Make(NetLog* net_log, NetLog::SourceType source_type) { | 498 BoundNetLog BoundNetLog::Make(NetLog* net_log, NetLogSourceType source_type) { |
| 501 if (!net_log) | 499 if (!net_log) |
| 502 return BoundNetLog(); | 500 return BoundNetLog(); |
| 503 | 501 |
| 504 NetLog::Source source(source_type, net_log->NextID()); | 502 NetLog::Source source(source_type, net_log->NextID()); |
| 505 return BoundNetLog(source, net_log); | 503 return BoundNetLog(source, net_log); |
| 506 } | 504 } |
| 507 | 505 |
| 508 void BoundNetLog::CrashIfInvalid() const { | 506 void BoundNetLog::CrashIfInvalid() const { |
| 509 Liveness liveness = liveness_; | 507 Liveness liveness = liveness_; |
| 510 | 508 |
| 511 if (liveness == ALIVE) | 509 if (liveness == ALIVE) |
| 512 return; | 510 return; |
| 513 | 511 |
| 514 base::debug::Alias(&liveness); | 512 base::debug::Alias(&liveness); |
| 515 CHECK_EQ(ALIVE, liveness); | 513 CHECK_EQ(ALIVE, liveness); |
| 516 } | 514 } |
| 517 | 515 |
| 518 } // namespace net | 516 } // namespace net |
| OLD | NEW |