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

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

Issue 2524043002: Android: Make netlog available in startup traces. (Closed)
Patch Set: Address comment. Created 4 years 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
« no previous file with comments | « no previous file | net/log/trace_net_log_observer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>( 83 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>(
84 new TracedValue(std::move(params)))); 84 new TracedValue(std::move(params))));
85 break; 85 break;
86 } 86 }
87 } 87 }
88 88
89 void TraceNetLogObserver::WatchForTraceStart(NetLog* netlog) { 89 void TraceNetLogObserver::WatchForTraceStart(NetLog* netlog) {
90 DCHECK(!net_log_to_watch_); 90 DCHECK(!net_log_to_watch_);
91 DCHECK(!net_log()); 91 DCHECK(!net_log());
92 net_log_to_watch_ = netlog; 92 net_log_to_watch_ = netlog;
93 // Tracing can start before the observer is even created, for instance for
94 // startup tracing.
95 if (base::trace_event::TraceLog::GetInstance()->IsEnabled())
96 OnTraceLogEnabled();
93 base::trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this); 97 base::trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this);
94 } 98 }
95 99
96 void TraceNetLogObserver::StopWatchForTraceStart() { 100 void TraceNetLogObserver::StopWatchForTraceStart() {
97 // Should only stop if is currently watching. 101 // Should only stop if is currently watching.
98 DCHECK(net_log_to_watch_); 102 DCHECK(net_log_to_watch_);
99 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this); 103 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this);
100 if (net_log()) 104 if (net_log())
101 net_log()->DeprecatedRemoveObserver(this); 105 net_log()->DeprecatedRemoveObserver(this);
102 net_log_to_watch_ = NULL; 106 net_log_to_watch_ = NULL;
103 } 107 }
104 108
105 void TraceNetLogObserver::OnTraceLogEnabled() { 109 void TraceNetLogObserver::OnTraceLogEnabled() {
106 net_log_to_watch_->DeprecatedAddObserver(this, NetLogCaptureMode::Default()); 110 net_log_to_watch_->DeprecatedAddObserver(this, NetLogCaptureMode::Default());
107 } 111 }
108 112
109 void TraceNetLogObserver::OnTraceLogDisabled() { 113 void TraceNetLogObserver::OnTraceLogDisabled() {
110 if (net_log()) 114 if (net_log())
111 net_log()->DeprecatedRemoveObserver(this); 115 net_log()->DeprecatedRemoveObserver(this);
112 } 116 }
113 117
114 } // namespace net 118 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/log/trace_net_log_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698