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

Side by Side Diff: net/base/net_log_logger.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/net_log_logger.h" 5 #include "net/base/net_log_logger.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 net_log()->RemoveThreadSafeObserver(this); 53 net_log()->RemoveThreadSafeObserver(this);
54 } 54 }
55 55
56 void NetLogLogger::OnAddEntry(const net::NetLog::Entry& entry) { 56 void NetLogLogger::OnAddEntry(const net::NetLog::Entry& entry) {
57 // Add a comma and newline for every event but the first. Newlines are needed 57 // Add a comma and newline for every event but the first. Newlines are needed
58 // so can load partial log files by just ignoring the last line. For this to 58 // so can load partial log files by just ignoring the last line. For this to
59 // work, lines cannot be pretty printed. 59 // work, lines cannot be pretty printed.
60 scoped_ptr<base::Value> value(entry.ToValue()); 60 scoped_ptr<base::Value> value(entry.ToValue());
61 std::string json; 61 std::string json;
62 base::JSONWriter::Write(value.get(), &json); 62 base::JSONWriter::Write(value.get(), &json);
63 fprintf(file_.get(), "%s%s", 63 fprintf(file_.get(), "%s%s", (added_events_ ? ",\n" : ""), json.c_str());
64 (added_events_ ? ",\n" : ""),
65 json.c_str());
66 added_events_ = true; 64 added_events_ = true;
67 } 65 }
68 66
69 base::DictionaryValue* NetLogLogger::GetConstants() { 67 base::DictionaryValue* NetLogLogger::GetConstants() {
70 base::DictionaryValue* constants_dict = new base::DictionaryValue(); 68 base::DictionaryValue* constants_dict = new base::DictionaryValue();
71 69
72 // Version of the file format. 70 // Version of the file format.
73 constants_dict->SetInteger("logFormatVersion", kLogFormatVersion); 71 constants_dict->SetInteger("logFormatVersion", kLogFormatVersion);
74 72
75 // Add a dictionary with information on the relationship between event type 73 // Add a dictionary with information on the relationship between event type
76 // enums and their symbolic names. 74 // enums and their symbolic names.
77 constants_dict->Set("logEventTypes", net::NetLog::GetEventTypesAsValue()); 75 constants_dict->Set("logEventTypes", net::NetLog::GetEventTypesAsValue());
78 76
79 // Add a dictionary with information about the relationship between load flag 77 // Add a dictionary with information about the relationship between load flag
80 // enums and their symbolic names. 78 // enums and their symbolic names.
81 { 79 {
82 base::DictionaryValue* dict = new base::DictionaryValue(); 80 base::DictionaryValue* dict = new base::DictionaryValue();
83 81
84 #define LOAD_FLAG(label, value) \ 82 #define LOAD_FLAG(label, value) \
85 dict->SetInteger(# label, static_cast<int>(value)); 83 dict->SetInteger(#label, static_cast<int>(value));
86 #include "net/base/load_flags_list.h" 84 #include "net/base/load_flags_list.h"
87 #undef LOAD_FLAG 85 #undef LOAD_FLAG
88 86
89 constants_dict->Set("loadFlag", dict); 87 constants_dict->Set("loadFlag", dict);
90 } 88 }
91 89
92 // Add a dictionary with information about the relationship between load state 90 // Add a dictionary with information about the relationship between load state
93 // enums and their symbolic names. 91 // enums and their symbolic names.
94 { 92 {
95 base::DictionaryValue* dict = new base::DictionaryValue(); 93 base::DictionaryValue* dict = new base::DictionaryValue();
96 94
97 #define LOAD_STATE(label) \ 95 #define LOAD_STATE(label) dict->SetInteger(#label, net::LOAD_STATE_##label);
98 dict->SetInteger(# label, net::LOAD_STATE_ ## label);
99 #include "net/base/load_states_list.h" 96 #include "net/base/load_states_list.h"
100 #undef LOAD_STATE 97 #undef LOAD_STATE
101 98
102 constants_dict->Set("loadState", dict); 99 constants_dict->Set("loadState", dict);
103 } 100 }
104 101
105 // Add information on the relationship between net error codes and their 102 // Add information on the relationship between net error codes and their
106 // symbolic names. 103 // symbolic names.
107 { 104 {
108 base::DictionaryValue* dict = new base::DictionaryValue(); 105 base::DictionaryValue* dict = new base::DictionaryValue();
109 106
110 #define NET_ERROR(label, value) \ 107 #define NET_ERROR(label, value) \
111 dict->SetInteger(# label, static_cast<int>(value)); 108 dict->SetInteger(#label, static_cast<int>(value));
112 #include "net/base/net_error_list.h" 109 #include "net/base/net_error_list.h"
113 #undef NET_ERROR 110 #undef NET_ERROR
114 111
115 constants_dict->Set("netError", dict); 112 constants_dict->Set("netError", dict);
116 } 113 }
117 114
118 // Add information on the relationship between QUIC error codes and their 115 // Add information on the relationship between QUIC error codes and their
119 // symbolic names. 116 // symbolic names.
120 { 117 {
121 base::DictionaryValue* dict = new base::DictionaryValue(); 118 base::DictionaryValue* dict = new base::DictionaryValue();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 constants_dict->Set("logLevelType", dict); 171 constants_dict->Set("logLevelType", dict);
175 } 172 }
176 173
177 // Information about the relationship between address family enums and 174 // Information about the relationship between address family enums and
178 // their symbolic names. 175 // their symbolic names.
179 { 176 {
180 base::DictionaryValue* dict = new base::DictionaryValue(); 177 base::DictionaryValue* dict = new base::DictionaryValue();
181 178
182 dict->SetInteger("ADDRESS_FAMILY_UNSPECIFIED", 179 dict->SetInteger("ADDRESS_FAMILY_UNSPECIFIED",
183 net::ADDRESS_FAMILY_UNSPECIFIED); 180 net::ADDRESS_FAMILY_UNSPECIFIED);
184 dict->SetInteger("ADDRESS_FAMILY_IPV4", 181 dict->SetInteger("ADDRESS_FAMILY_IPV4", net::ADDRESS_FAMILY_IPV4);
185 net::ADDRESS_FAMILY_IPV4); 182 dict->SetInteger("ADDRESS_FAMILY_IPV6", net::ADDRESS_FAMILY_IPV6);
186 dict->SetInteger("ADDRESS_FAMILY_IPV6",
187 net::ADDRESS_FAMILY_IPV6);
188 183
189 constants_dict->Set("addressFamily", dict); 184 constants_dict->Set("addressFamily", dict);
190 } 185 }
191 186
192 // Information about how the "time ticks" values we have given it relate to 187 // Information about how the "time ticks" values we have given it relate to
193 // actual system times. (We used time ticks throughout since they are stable 188 // actual system times. (We used time ticks throughout since they are stable
194 // across system clock changes). 189 // across system clock changes).
195 { 190 {
196 int64 cur_time_ms = (base::Time::Now() - base::Time()).InMilliseconds(); 191 int64 cur_time_ms = (base::Time::Now() - base::Time()).InMilliseconds();
197 192
(...skipping 16 matching lines...) Expand all
214 } 209 }
215 210
216 // "clientInfo" key is required for some NetLogLogger log readers. 211 // "clientInfo" key is required for some NetLogLogger log readers.
217 // Provide a default empty value for compatibility. 212 // Provide a default empty value for compatibility.
218 constants_dict->Set("clientInfo", new base::DictionaryValue()); 213 constants_dict->Set("clientInfo", new base::DictionaryValue());
219 214
220 return constants_dict; 215 return constants_dict;
221 } 216 }
222 217
223 } // namespace net 218 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698