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 2315613002: Extracted NetLog class's inner enum types into their own enum classes and (Closed)
Patch Set: Ran "git cl format" on code. Much formatting ensued. Created 4 years, 3 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
« no previous file with comments | « net/log/test_net_log_util.cc ('k') | 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>
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.h"
18 #include "net/log/net_log_event_type.h"
18 19
19 namespace net { 20 namespace net {
20 21
21 namespace { 22 namespace {
22 23
23 // TraceLog category for NetLog events. 24 // TraceLog category for NetLog events.
24 const char kNetLogTracingCategory[] = "netlog"; 25 const char kNetLogTracingCategory[] = "netlog";
25 26
26 class TracedValue : public base::trace_event::ConvertableToTraceFormat { 27 class TracedValue : public base::trace_event::ConvertableToTraceFormat {
27 public: 28 public:
(...skipping 23 matching lines...) Expand all
51 } 52 }
52 53
53 TraceNetLogObserver::~TraceNetLogObserver() { 54 TraceNetLogObserver::~TraceNetLogObserver() {
54 DCHECK(!net_log_to_watch_); 55 DCHECK(!net_log_to_watch_);
55 DCHECK(!net_log()); 56 DCHECK(!net_log());
56 } 57 }
57 58
58 void TraceNetLogObserver::OnAddEntry(const NetLog::Entry& entry) { 59 void TraceNetLogObserver::OnAddEntry(const NetLog::Entry& entry) {
59 std::unique_ptr<base::Value> params(entry.ParametersToValue()); 60 std::unique_ptr<base::Value> params(entry.ParametersToValue());
60 switch (entry.phase()) { 61 switch (entry.phase()) {
61 case NetLog::PHASE_BEGIN: 62 case NetLogEventPhase::BEGIN:
62 TRACE_EVENT_NESTABLE_ASYNC_BEGIN2( 63 TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(
63 kNetLogTracingCategory, NetLog::EventTypeToString(entry.type()), 64 kNetLogTracingCategory, NetLog::EventTypeToString(entry.type()),
64 entry.source().id, "source_type", 65 entry.source().id, "source_type",
65 NetLog::SourceTypeToString(entry.source().type), "params", 66 NetLog::SourceTypeToString(entry.source().type), "params",
66 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>( 67 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>(
67 new TracedValue(std::move(params)))); 68 new TracedValue(std::move(params))));
68 break; 69 break;
69 case NetLog::PHASE_END: 70 case NetLogEventPhase::END:
70 TRACE_EVENT_NESTABLE_ASYNC_END2( 71 TRACE_EVENT_NESTABLE_ASYNC_END2(
71 kNetLogTracingCategory, NetLog::EventTypeToString(entry.type()), 72 kNetLogTracingCategory, NetLog::EventTypeToString(entry.type()),
72 entry.source().id, "source_type", 73 entry.source().id, "source_type",
73 NetLog::SourceTypeToString(entry.source().type), "params", 74 NetLog::SourceTypeToString(entry.source().type), "params",
74 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>( 75 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>(
75 new TracedValue(std::move(params)))); 76 new TracedValue(std::move(params))));
76 break; 77 break;
77 case NetLog::PHASE_NONE: 78 case NetLogEventPhase::NONE:
78 TRACE_EVENT_NESTABLE_ASYNC_INSTANT2( 79 TRACE_EVENT_NESTABLE_ASYNC_INSTANT2(
79 kNetLogTracingCategory, NetLog::EventTypeToString(entry.type()), 80 kNetLogTracingCategory, NetLog::EventTypeToString(entry.type()),
80 entry.source().id, "source_type", 81 entry.source().id, "source_type",
81 NetLog::SourceTypeToString(entry.source().type), "params", 82 NetLog::SourceTypeToString(entry.source().type), "params",
82 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>( 83 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>(
83 new TracedValue(std::move(params)))); 84 new TracedValue(std::move(params))));
84 break; 85 break;
85 } 86 }
86 } 87 }
87 88
(...skipping 16 matching lines...) Expand all
104 void TraceNetLogObserver::OnTraceLogEnabled() { 105 void TraceNetLogObserver::OnTraceLogEnabled() {
105 net_log_to_watch_->DeprecatedAddObserver(this, NetLogCaptureMode::Default()); 106 net_log_to_watch_->DeprecatedAddObserver(this, NetLogCaptureMode::Default());
106 } 107 }
107 108
108 void TraceNetLogObserver::OnTraceLogDisabled() { 109 void TraceNetLogObserver::OnTraceLogDisabled() {
109 if (net_log()) 110 if (net_log())
110 net_log()->DeprecatedRemoveObserver(this); 111 net_log()->DeprecatedRemoveObserver(this);
111 } 112 }
112 113
113 } // namespace net 114 } // namespace net
OLDNEW
« no previous file with comments | « net/log/test_net_log_util.cc ('k') | net/log/trace_net_log_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698