Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: net/log/net_log.cc

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: one more fix, content bound_net_log_ Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 if (!IsCapturing()) 403 if (!IsCapturing())
404 return; 404 return;
405 EntryData entry_data(type, source, phase, base::TimeTicks::Now(), 405 EntryData entry_data(type, source, phase, base::TimeTicks::Now(),
406 parameters_callback); 406 parameters_callback);
407 407
408 // Notify all of the log observers. 408 // Notify all of the log observers.
409 base::AutoLock lock(lock_); 409 base::AutoLock lock(lock_);
410 FOR_EACH_OBSERVER(ThreadSafeObserver, observers_, OnAddEntryData(entry_data)); 410 FOR_EACH_OBSERVER(ThreadSafeObserver, observers_, OnAddEntryData(entry_data));
411 } 411 }
412 412
413 BoundNetLog::~BoundNetLog() { 413 NetLogWithSource::~NetLogWithSource() {
414 liveness_ = DEAD; 414 liveness_ = DEAD;
415 } 415 }
416 416
417 void BoundNetLog::AddEntry(NetLogEventType type, NetLogEventPhase phase) const { 417 void NetLogWithSource::AddEntry(NetLogEventType type,
418 NetLogEventPhase phase) const {
418 CrashIfInvalid(); 419 CrashIfInvalid();
419 420
420 if (!net_log_) 421 if (!net_log_)
421 return; 422 return;
422 net_log_->AddEntry(type, source_, phase, NULL); 423 net_log_->AddEntry(type, source_, phase, NULL);
423 } 424 }
424 425
425 void BoundNetLog::AddEntry( 426 void NetLogWithSource::AddEntry(
426 NetLogEventType type, 427 NetLogEventType type,
427 NetLogEventPhase phase, 428 NetLogEventPhase phase,
428 const NetLog::ParametersCallback& get_parameters) const { 429 const NetLog::ParametersCallback& get_parameters) const {
429 CrashIfInvalid(); 430 CrashIfInvalid();
430 431
431 if (!net_log_) 432 if (!net_log_)
432 return; 433 return;
433 net_log_->AddEntry(type, source_, phase, &get_parameters); 434 net_log_->AddEntry(type, source_, phase, &get_parameters);
434 } 435 }
435 436
436 void BoundNetLog::AddEvent(NetLogEventType type) const { 437 void NetLogWithSource::AddEvent(NetLogEventType type) const {
437 AddEntry(type, NetLogEventPhase::NONE); 438 AddEntry(type, NetLogEventPhase::NONE);
438 } 439 }
439 440
440 void BoundNetLog::AddEvent( 441 void NetLogWithSource::AddEvent(
441 NetLogEventType type, 442 NetLogEventType type,
442 const NetLog::ParametersCallback& get_parameters) const { 443 const NetLog::ParametersCallback& get_parameters) const {
443 AddEntry(type, NetLogEventPhase::NONE, get_parameters); 444 AddEntry(type, NetLogEventPhase::NONE, get_parameters);
444 } 445 }
445 446
446 void BoundNetLog::BeginEvent(NetLogEventType type) const { 447 void NetLogWithSource::BeginEvent(NetLogEventType type) const {
447 AddEntry(type, NetLogEventPhase::BEGIN); 448 AddEntry(type, NetLogEventPhase::BEGIN);
448 } 449 }
449 450
450 void BoundNetLog::BeginEvent( 451 void NetLogWithSource::BeginEvent(
451 NetLogEventType type, 452 NetLogEventType type,
452 const NetLog::ParametersCallback& get_parameters) const { 453 const NetLog::ParametersCallback& get_parameters) const {
453 AddEntry(type, NetLogEventPhase::BEGIN, get_parameters); 454 AddEntry(type, NetLogEventPhase::BEGIN, get_parameters);
454 } 455 }
455 456
456 void BoundNetLog::EndEvent(NetLogEventType type) const { 457 void NetLogWithSource::EndEvent(NetLogEventType type) const {
457 AddEntry(type, NetLogEventPhase::END); 458 AddEntry(type, NetLogEventPhase::END);
458 } 459 }
459 460
460 void BoundNetLog::EndEvent( 461 void NetLogWithSource::EndEvent(
461 NetLogEventType type, 462 NetLogEventType type,
462 const NetLog::ParametersCallback& get_parameters) const { 463 const NetLog::ParametersCallback& get_parameters) const {
463 AddEntry(type, NetLogEventPhase::END, get_parameters); 464 AddEntry(type, NetLogEventPhase::END, get_parameters);
464 } 465 }
465 466
466 void BoundNetLog::AddEventWithNetErrorCode(NetLogEventType event_type, 467 void NetLogWithSource::AddEventWithNetErrorCode(NetLogEventType event_type,
467 int net_error) const { 468 int net_error) const {
468 DCHECK_NE(ERR_IO_PENDING, net_error); 469 DCHECK_NE(ERR_IO_PENDING, net_error);
469 if (net_error >= 0) { 470 if (net_error >= 0) {
470 AddEvent(event_type); 471 AddEvent(event_type);
471 } else { 472 } else {
472 AddEvent(event_type, NetLog::IntCallback("net_error", net_error)); 473 AddEvent(event_type, NetLog::IntCallback("net_error", net_error));
473 } 474 }
474 } 475 }
475 476
476 void BoundNetLog::EndEventWithNetErrorCode(NetLogEventType event_type, 477 void NetLogWithSource::EndEventWithNetErrorCode(NetLogEventType event_type,
477 int net_error) const { 478 int net_error) const {
478 DCHECK_NE(ERR_IO_PENDING, net_error); 479 DCHECK_NE(ERR_IO_PENDING, net_error);
479 if (net_error >= 0) { 480 if (net_error >= 0) {
480 EndEvent(event_type); 481 EndEvent(event_type);
481 } else { 482 } else {
482 EndEvent(event_type, NetLog::IntCallback("net_error", net_error)); 483 EndEvent(event_type, NetLog::IntCallback("net_error", net_error));
483 } 484 }
484 } 485 }
485 486
486 void BoundNetLog::AddByteTransferEvent(NetLogEventType event_type, 487 void NetLogWithSource::AddByteTransferEvent(NetLogEventType event_type,
487 int byte_count, 488 int byte_count,
488 const char* bytes) const { 489 const char* bytes) const {
489 AddEvent(event_type, base::Bind(BytesTransferredCallback, byte_count, bytes)); 490 AddEvent(event_type, base::Bind(BytesTransferredCallback, byte_count, bytes));
490 } 491 }
491 492
492 bool BoundNetLog::IsCapturing() const { 493 bool NetLogWithSource::IsCapturing() const {
493 CrashIfInvalid(); 494 CrashIfInvalid();
494 return net_log_ && net_log_->IsCapturing(); 495 return net_log_ && net_log_->IsCapturing();
495 } 496 }
496 497
497 // static 498 // static
498 BoundNetLog BoundNetLog::Make(NetLog* net_log, NetLogSourceType source_type) { 499 NetLogWithSource NetLogWithSource::Make(NetLog* net_log,
500 NetLogSourceType source_type) {
499 if (!net_log) 501 if (!net_log)
500 return BoundNetLog(); 502 return NetLogWithSource();
501 503
502 NetLog::Source source(source_type, net_log->NextID()); 504 NetLog::Source source(source_type, net_log->NextID());
503 return BoundNetLog(source, net_log); 505 return NetLogWithSource(source, net_log);
504 } 506 }
505 507
506 void BoundNetLog::CrashIfInvalid() const { 508 void NetLogWithSource::CrashIfInvalid() const {
507 Liveness liveness = liveness_; 509 Liveness liveness = liveness_;
508 510
509 if (liveness == ALIVE) 511 if (liveness == ALIVE)
510 return; 512 return;
511 513
512 base::debug::Alias(&liveness); 514 base::debug::Alias(&liveness);
513 CHECK_EQ(ALIVE, liveness); 515 CHECK_EQ(ALIVE, liveness);
514 } 516 }
515 517
516 } // namespace net 518 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698