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

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

Issue 1717283003: tracing: Make ConvertableToTraceFormat move-only scoped_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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 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/log/trace_net_log_observer.h" 5 #include "net/log/trace_net_log_observer.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 } 55 }
56 56
57 void TraceNetLogObserver::OnAddEntry(const NetLog::Entry& entry) { 57 void TraceNetLogObserver::OnAddEntry(const NetLog::Entry& entry) {
58 scoped_ptr<base::Value> params(entry.ParametersToValue()); 58 scoped_ptr<base::Value> params(entry.ParametersToValue());
59 switch (entry.phase()) { 59 switch (entry.phase()) {
60 case NetLog::PHASE_BEGIN: 60 case NetLog::PHASE_BEGIN:
61 TRACE_EVENT_NESTABLE_ASYNC_BEGIN2( 61 TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(
62 kNetLogTracingCategory, NetLog::EventTypeToString(entry.type()), 62 kNetLogTracingCategory, NetLog::EventTypeToString(entry.type()),
63 entry.source().id, "source_type", 63 entry.source().id, "source_type",
64 NetLog::SourceTypeToString(entry.source().type), "params", 64 NetLog::SourceTypeToString(entry.source().type), "params",
65 scoped_refptr<base::trace_event::ConvertableToTraceFormat>( 65 scoped_ptr<base::trace_event::ConvertableToTraceFormat>(
66 new TracedValue(std::move(params)))); 66 new TracedValue(std::move(params))));
67 break; 67 break;
68 case NetLog::PHASE_END: 68 case NetLog::PHASE_END:
69 TRACE_EVENT_NESTABLE_ASYNC_END2( 69 TRACE_EVENT_NESTABLE_ASYNC_END2(
70 kNetLogTracingCategory, NetLog::EventTypeToString(entry.type()), 70 kNetLogTracingCategory, NetLog::EventTypeToString(entry.type()),
71 entry.source().id, "source_type", 71 entry.source().id, "source_type",
72 NetLog::SourceTypeToString(entry.source().type), "params", 72 NetLog::SourceTypeToString(entry.source().type), "params",
73 scoped_refptr<base::trace_event::ConvertableToTraceFormat>( 73 scoped_ptr<base::trace_event::ConvertableToTraceFormat>(
74 new TracedValue(std::move(params)))); 74 new TracedValue(std::move(params))));
75 break; 75 break;
76 case NetLog::PHASE_NONE: 76 case NetLog::PHASE_NONE:
77 TRACE_EVENT_NESTABLE_ASYNC_INSTANT2( 77 TRACE_EVENT_NESTABLE_ASYNC_INSTANT2(
78 kNetLogTracingCategory, NetLog::EventTypeToString(entry.type()), 78 kNetLogTracingCategory, NetLog::EventTypeToString(entry.type()),
79 entry.source().id, "source_type", 79 entry.source().id, "source_type",
80 NetLog::SourceTypeToString(entry.source().type), "params", 80 NetLog::SourceTypeToString(entry.source().type), "params",
81 scoped_refptr<base::trace_event::ConvertableToTraceFormat>( 81 scoped_ptr<base::trace_event::ConvertableToTraceFormat>(
82 new TracedValue(std::move(params)))); 82 new TracedValue(std::move(params))));
83 break; 83 break;
84 } 84 }
85 } 85 }
86 86
87 void TraceNetLogObserver::WatchForTraceStart(NetLog* netlog) { 87 void TraceNetLogObserver::WatchForTraceStart(NetLog* netlog) {
88 DCHECK(!net_log_to_watch_); 88 DCHECK(!net_log_to_watch_);
89 DCHECK(!net_log()); 89 DCHECK(!net_log());
90 net_log_to_watch_ = netlog; 90 net_log_to_watch_ = netlog;
91 base::trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this); 91 base::trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this);
(...skipping 11 matching lines...) Expand all
103 void TraceNetLogObserver::OnTraceLogEnabled() { 103 void TraceNetLogObserver::OnTraceLogEnabled() {
104 net_log_to_watch_->DeprecatedAddObserver(this, NetLogCaptureMode::Default()); 104 net_log_to_watch_->DeprecatedAddObserver(this, NetLogCaptureMode::Default());
105 } 105 }
106 106
107 void TraceNetLogObserver::OnTraceLogDisabled() { 107 void TraceNetLogObserver::OnTraceLogDisabled() {
108 if (net_log()) 108 if (net_log())
109 net_log()->DeprecatedRemoveObserver(this); 109 net_log()->DeprecatedRemoveObserver(this);
110 } 110 }
111 111
112 } // namespace net 112 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698