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

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

Issue 2333923004: Extracting NetLog inner classes into their own classes. (Closed)
Patch Set: Some nit fixes and better, impl-agnostic naming of net_log_parameters_callback_typedef.h -> 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 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>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "net/log/net_log.h" 17 #include "net/log/net_log_entry.h"
18 #include "net/log/net_log_event_type.h" 18 #include "net/log/net_log_event_type.h"
19 19
20 namespace net { 20 namespace net {
21 21
22 namespace { 22 namespace {
23 23
24 // TraceLog category for NetLog events. 24 // TraceLog category for NetLog events.
25 const char kNetLogTracingCategory[] = "netlog"; 25 const char kNetLogTracingCategory[] = "netlog";
26 26
27 class TracedValue : public base::trace_event::ConvertableToTraceFormat { 27 class TracedValue : public base::trace_event::ConvertableToTraceFormat {
(...skipping 21 matching lines...) Expand all
49 } // namespace 49 } // namespace
50 50
51 TraceNetLogObserver::TraceNetLogObserver() : net_log_to_watch_(NULL) { 51 TraceNetLogObserver::TraceNetLogObserver() : net_log_to_watch_(NULL) {
52 } 52 }
53 53
54 TraceNetLogObserver::~TraceNetLogObserver() { 54 TraceNetLogObserver::~TraceNetLogObserver() {
55 DCHECK(!net_log_to_watch_); 55 DCHECK(!net_log_to_watch_);
56 DCHECK(!net_log()); 56 DCHECK(!net_log());
57 } 57 }
58 58
59 void TraceNetLogObserver::OnAddEntry(const NetLog::Entry& entry) { 59 void TraceNetLogObserver::OnAddEntry(const NetLogEntry& entry) {
60 std::unique_ptr<base::Value> params(entry.ParametersToValue()); 60 std::unique_ptr<base::Value> params(entry.ParametersToValue());
61 switch (entry.phase()) { 61 switch (entry.phase()) {
62 case NetLogEventPhase::BEGIN: 62 case NetLogEventPhase::BEGIN:
63 TRACE_EVENT_NESTABLE_ASYNC_BEGIN2( 63 TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(
64 kNetLogTracingCategory, NetLog::EventTypeToString(entry.type()), 64 kNetLogTracingCategory, NetLog::EventTypeToString(entry.type()),
65 entry.source().id, "source_type", 65 entry.source().id, "source_type",
66 NetLog::SourceTypeToString(entry.source().type), "params", 66 NetLog::SourceTypeToString(entry.source().type), "params",
67 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>( 67 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>(
68 new TracedValue(std::move(params)))); 68 new TracedValue(std::move(params))));
69 break; 69 break;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void TraceNetLogObserver::OnTraceLogEnabled() { 105 void TraceNetLogObserver::OnTraceLogEnabled() {
106 net_log_to_watch_->DeprecatedAddObserver(this, NetLogCaptureMode::Default()); 106 net_log_to_watch_->DeprecatedAddObserver(this, NetLogCaptureMode::Default());
107 } 107 }
108 108
109 void TraceNetLogObserver::OnTraceLogDisabled() { 109 void TraceNetLogObserver::OnTraceLogDisabled() {
110 if (net_log()) 110 if (net_log())
111 net_log()->DeprecatedRemoveObserver(this); 111 net_log()->DeprecatedRemoveObserver(this);
112 } 112 }
113 113
114 } // namespace net 114 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698