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

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

Issue 649763002: git cl format the second third of the net/base directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "net/base/address_family.h" 14 #include "net/base/address_family.h"
15 #include "net/base/load_states.h" 15 #include "net/base/load_states.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/quic/quic_protocol.h" 17 #include "net/quic/quic_protocol.h"
18 #include "net/quic/quic_utils.h" 18 #include "net/quic/quic_utils.h"
19 19
20 namespace { 20 namespace {
21 21
22 struct StringToConstant { 22 struct StringToConstant {
23 const char* name; 23 const char* name;
24 const int constant; 24 const int constant;
25 }; 25 };
26 26
27 const StringToConstant kCertStatusFlags[] = { 27 const StringToConstant kCertStatusFlags[] = {
28 #define CERT_STATUS_FLAG(label, value) { #label, value }, 28 #define CERT_STATUS_FLAG(label, value) \
29 { #label, value } \
30 ,
29 #include "net/cert/cert_status_flags_list.h" 31 #include "net/cert/cert_status_flags_list.h"
30 #undef CERT_STATUS_FLAG 32 #undef CERT_STATUS_FLAG
31 }; 33 };
32 34
33 const StringToConstant kLoadFlags[] = { 35 const StringToConstant kLoadFlags[] = {
34 #define LOAD_FLAG(label, value) { #label, value }, 36 #define LOAD_FLAG(label, value) \
37 { #label, value } \
38 ,
35 #include "net/base/load_flags_list.h" 39 #include "net/base/load_flags_list.h"
36 #undef LOAD_FLAG 40 #undef LOAD_FLAG
37 }; 41 };
38 42
39 const StringToConstant kLoadStateTable[] = { 43 const StringToConstant kLoadStateTable[] = {
40 #define LOAD_STATE(label) { # label, net::LOAD_STATE_ ## label }, 44 #define LOAD_STATE(label) \
45 { #label, net::LOAD_STATE_##label } \
46 ,
41 #include "net/base/load_states_list.h" 47 #include "net/base/load_states_list.h"
42 #undef LOAD_STATE 48 #undef LOAD_STATE
43 }; 49 };
44 50
45 const short kNetErrors[] = { 51 const short kNetErrors[] = {
46 #define NET_ERROR(label, value) value, 52 #define NET_ERROR(label, value) value,
47 #include "net/base/net_error_list.h" 53 #include "net/base/net_error_list.h"
48 #undef NET_ERROR 54 #undef NET_ERROR
49 }; 55 };
50 56
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 net_log()->RemoveThreadSafeObserver(this); 95 net_log()->RemoveThreadSafeObserver(this);
90 } 96 }
91 97
92 void NetLogLogger::OnAddEntry(const net::NetLog::Entry& entry) { 98 void NetLogLogger::OnAddEntry(const net::NetLog::Entry& entry) {
93 // Add a comma and newline for every event but the first. Newlines are needed 99 // Add a comma and newline for every event but the first. Newlines are needed
94 // so can load partial log files by just ignoring the last line. For this to 100 // so can load partial log files by just ignoring the last line. For this to
95 // work, lines cannot be pretty printed. 101 // work, lines cannot be pretty printed.
96 scoped_ptr<base::Value> value(entry.ToValue()); 102 scoped_ptr<base::Value> value(entry.ToValue());
97 std::string json; 103 std::string json;
98 base::JSONWriter::Write(value.get(), &json); 104 base::JSONWriter::Write(value.get(), &json);
99 fprintf(file_.get(), "%s%s", 105 fprintf(file_.get(), "%s%s", (added_events_ ? ",\n" : ""), json.c_str());
100 (added_events_ ? ",\n" : ""),
101 json.c_str());
102 added_events_ = true; 106 added_events_ = true;
103 } 107 }
104 108
105 base::DictionaryValue* NetLogLogger::GetConstants() { 109 base::DictionaryValue* NetLogLogger::GetConstants() {
106 base::DictionaryValue* constants_dict = new base::DictionaryValue(); 110 base::DictionaryValue* constants_dict = new base::DictionaryValue();
107 111
108 // Version of the file format. 112 // Version of the file format.
109 constants_dict->SetInteger("logFormatVersion", kLogFormatVersion); 113 constants_dict->SetInteger("logFormatVersion", kLogFormatVersion);
110 114
111 // Add a dictionary with information on the relationship between event type 115 // Add a dictionary with information on the relationship between event type
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 constants_dict->Set("logLevelType", dict); 219 constants_dict->Set("logLevelType", dict);
216 } 220 }
217 221
218 // Information about the relationship between address family enums and 222 // Information about the relationship between address family enums and
219 // their symbolic names. 223 // their symbolic names.
220 { 224 {
221 base::DictionaryValue* dict = new base::DictionaryValue(); 225 base::DictionaryValue* dict = new base::DictionaryValue();
222 226
223 dict->SetInteger("ADDRESS_FAMILY_UNSPECIFIED", 227 dict->SetInteger("ADDRESS_FAMILY_UNSPECIFIED",
224 net::ADDRESS_FAMILY_UNSPECIFIED); 228 net::ADDRESS_FAMILY_UNSPECIFIED);
225 dict->SetInteger("ADDRESS_FAMILY_IPV4", 229 dict->SetInteger("ADDRESS_FAMILY_IPV4", net::ADDRESS_FAMILY_IPV4);
226 net::ADDRESS_FAMILY_IPV4); 230 dict->SetInteger("ADDRESS_FAMILY_IPV6", net::ADDRESS_FAMILY_IPV6);
227 dict->SetInteger("ADDRESS_FAMILY_IPV6",
228 net::ADDRESS_FAMILY_IPV6);
229 231
230 constants_dict->Set("addressFamily", dict); 232 constants_dict->Set("addressFamily", dict);
231 } 233 }
232 234
233 // Information about how the "time ticks" values we have given it relate to 235 // Information about how the "time ticks" values we have given it relate to
234 // actual system times. (We used time ticks throughout since they are stable 236 // actual system times. (We used time ticks throughout since they are stable
235 // across system clock changes). 237 // across system clock changes).
236 { 238 {
237 int64 cur_time_ms = (base::Time::Now() - base::Time()).InMilliseconds(); 239 int64 cur_time_ms = (base::Time::Now() - base::Time()).InMilliseconds();
238 240
(...skipping 16 matching lines...) Expand all
255 } 257 }
256 258
257 // "clientInfo" key is required for some NetLogLogger log readers. 259 // "clientInfo" key is required for some NetLogLogger log readers.
258 // Provide a default empty value for compatibility. 260 // Provide a default empty value for compatibility.
259 constants_dict->Set("clientInfo", new base::DictionaryValue()); 261 constants_dict->Set("clientInfo", new base::DictionaryValue());
260 262
261 return constants_dict; 263 return constants_dict;
262 } 264 }
263 265
264 } // namespace net 266 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698