Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/trace_net_log_observer.h" | 5 #include "net/base/trace_net_log_observer.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 TraceNetLogObserver::~TraceNetLogObserver() { | 48 TraceNetLogObserver::~TraceNetLogObserver() { |
| 49 DCHECK(!net_log_to_watch_); | 49 DCHECK(!net_log_to_watch_); |
| 50 DCHECK(!net_log()); | 50 DCHECK(!net_log()); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void TraceNetLogObserver::OnAddEntry(const NetLog::Entry& entry) { | 53 void TraceNetLogObserver::OnAddEntry(const NetLog::Entry& entry) { |
| 54 scoped_ptr<base::Value> params(entry.ParametersToValue()); | 54 scoped_ptr<base::Value> params(entry.ParametersToValue()); |
| 55 switch (entry.phase()) { | 55 switch (entry.phase()) { |
| 56 case NetLog::PHASE_BEGIN: | 56 case NetLog::PHASE_BEGIN: |
| 57 TRACE_EVENT_NESTABLE_ASYNC_BEGIN2( | 57 TRACE_EVENT_NESTABLE_ASYNC_BEGIN2( |
| 58 "netlog", NetLog::EventTypeToString(entry.type()), entry.source().id, | 58 "netlog", |
| 59 "source_type", NetLog::SourceTypeToString(entry.source().type), | 59 NetLog::EventTypeToString(entry.type()), |
| 60 "params", scoped_refptr<base::debug::ConvertableToTraceFormat>( | 60 entry.source().id, |
| 61 "source_type", | |
| 62 NetLog::SourceTypeToString(entry.source().type), | |
| 63 "params", | |
| 64 scoped_refptr<base::debug::ConvertableToTraceFormat>( | |
|
davidben
2014/10/10 20:24:16
No action: The old one is a little better for this
| |
| 61 new TracedValue(params.Pass()))); | 65 new TracedValue(params.Pass()))); |
| 62 break; | 66 break; |
| 63 case NetLog::PHASE_END: | 67 case NetLog::PHASE_END: |
| 64 TRACE_EVENT_NESTABLE_ASYNC_END2( | 68 TRACE_EVENT_NESTABLE_ASYNC_END2( |
| 65 "netlog", NetLog::EventTypeToString(entry.type()), entry.source().id, | 69 "netlog", |
| 66 "source_type", NetLog::SourceTypeToString(entry.source().type), | 70 NetLog::EventTypeToString(entry.type()), |
| 67 "params", scoped_refptr<base::debug::ConvertableToTraceFormat>( | 71 entry.source().id, |
| 72 "source_type", | |
| 73 NetLog::SourceTypeToString(entry.source().type), | |
| 74 "params", | |
| 75 scoped_refptr<base::debug::ConvertableToTraceFormat>( | |
| 68 new TracedValue(params.Pass()))); | 76 new TracedValue(params.Pass()))); |
| 69 break; | 77 break; |
| 70 case NetLog::PHASE_NONE: | 78 case NetLog::PHASE_NONE: |
| 71 TRACE_EVENT_NESTABLE_ASYNC_INSTANT2( | 79 TRACE_EVENT_NESTABLE_ASYNC_INSTANT2( |
| 72 "netlog", NetLog::EventTypeToString(entry.type()), entry.source().id, | 80 "netlog", |
| 73 "source_type", NetLog::SourceTypeToString(entry.source().type), | 81 NetLog::EventTypeToString(entry.type()), |
| 74 "params", scoped_refptr<base::debug::ConvertableToTraceFormat>( | 82 entry.source().id, |
| 83 "source_type", | |
| 84 NetLog::SourceTypeToString(entry.source().type), | |
| 85 "params", | |
| 86 scoped_refptr<base::debug::ConvertableToTraceFormat>( | |
| 75 new TracedValue(params.Pass()))); | 87 new TracedValue(params.Pass()))); |
| 76 break; | 88 break; |
| 77 } | 89 } |
| 78 } | 90 } |
| 79 | 91 |
| 80 void TraceNetLogObserver::WatchForTraceStart(NetLog* netlog) { | 92 void TraceNetLogObserver::WatchForTraceStart(NetLog* netlog) { |
| 81 DCHECK(!net_log_to_watch_); | 93 DCHECK(!net_log_to_watch_); |
| 82 DCHECK(!net_log()); | 94 DCHECK(!net_log()); |
| 83 net_log_to_watch_ = netlog; | 95 net_log_to_watch_ = netlog; |
| 84 base::debug::TraceLog::GetInstance()->AddEnabledStateObserver(this); | 96 base::debug::TraceLog::GetInstance()->AddEnabledStateObserver(this); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 97 net_log_to_watch_->AddThreadSafeObserver(this, | 109 net_log_to_watch_->AddThreadSafeObserver(this, |
| 98 NetLog::LOG_STRIP_PRIVATE_DATA); | 110 NetLog::LOG_STRIP_PRIVATE_DATA); |
| 99 } | 111 } |
| 100 | 112 |
| 101 void TraceNetLogObserver::OnTraceLogDisabled() { | 113 void TraceNetLogObserver::OnTraceLogDisabled() { |
| 102 if (net_log()) | 114 if (net_log()) |
| 103 net_log()->RemoveThreadSafeObserver(this); | 115 net_log()->RemoveThreadSafeObserver(this); |
| 104 } | 116 } |
| 105 | 117 |
| 106 } // namespace net | 118 } // namespace net |
| OLD | NEW |