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

Side by Side Diff: net/base/capturing_net_log.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/capturing_net_log.h" 5 #include "net/base/capturing_net_log.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 10
11 namespace net { 11 namespace net {
12 12
13 CapturingNetLog::CapturedEntry::CapturedEntry( 13 CapturingNetLog::CapturedEntry::CapturedEntry(
14 EventType type, 14 EventType type,
15 const base::TimeTicks& time, 15 const base::TimeTicks& time,
16 Source source, 16 Source source,
17 EventPhase phase, 17 EventPhase phase,
18 scoped_ptr<base::DictionaryValue> params) 18 scoped_ptr<base::DictionaryValue> params)
19 : type(type), 19 : type(type),
20 time(time), 20 time(time),
21 source(source), 21 source(source),
22 phase(phase), 22 phase(phase),
23 params(params.Pass()) { 23 params(params.Pass()) {
24 } 24 }
25 25
26 CapturingNetLog::CapturedEntry::CapturedEntry(const CapturedEntry& entry) { 26 CapturingNetLog::CapturedEntry::CapturedEntry(const CapturedEntry& entry) {
27 *this = entry; 27 *this = entry;
28 } 28 }
29 29
30 CapturingNetLog::CapturedEntry::~CapturedEntry() {} 30 CapturingNetLog::CapturedEntry::~CapturedEntry() {
31 }
31 32
32 CapturingNetLog::CapturedEntry& 33 CapturingNetLog::CapturedEntry& CapturingNetLog::CapturedEntry::operator=(
33 CapturingNetLog::CapturedEntry::operator=(const CapturedEntry& entry) { 34 const CapturedEntry& entry) {
34 type = entry.type; 35 type = entry.type;
35 time = entry.time; 36 time = entry.time;
36 source = entry.source; 37 source = entry.source;
37 phase = entry.phase; 38 phase = entry.phase;
38 params.reset(entry.params ? entry.params->DeepCopy() : NULL); 39 params.reset(entry.params ? entry.params->DeepCopy() : NULL);
39 return *this; 40 return *this;
40 } 41 }
41 42
42 bool CapturingNetLog::CapturedEntry::GetStringValue( 43 bool CapturingNetLog::CapturedEntry::GetStringValue(const std::string& name,
43 const std::string& name, 44 std::string* value) const {
44 std::string* value) const {
45 if (!params) 45 if (!params)
46 return false; 46 return false;
47 return params->GetString(name, value); 47 return params->GetString(name, value);
48 } 48 }
49 49
50 bool CapturingNetLog::CapturedEntry::GetIntegerValue( 50 bool CapturingNetLog::CapturedEntry::GetIntegerValue(const std::string& name,
51 const std::string& name, 51 int* value) const {
52 int* value) const {
53 if (!params) 52 if (!params)
54 return false; 53 return false;
55 return params->GetInteger(name, value); 54 return params->GetInteger(name, value);
56 } 55 }
57 56
58 bool CapturingNetLog::CapturedEntry::GetListValue( 57 bool CapturingNetLog::CapturedEntry::GetListValue(
59 const std::string& name, 58 const std::string& name,
60 base::ListValue** value) const { 59 base::ListValue** value) const {
61 if (!params) 60 if (!params)
62 return false; 61 return false;
63 return params->GetList(name, value); 62 return params->GetList(name, value);
64 } 63 }
65 64
66 bool CapturingNetLog::CapturedEntry::GetNetErrorCode(int* value) const { 65 bool CapturingNetLog::CapturedEntry::GetNetErrorCode(int* value) const {
67 return GetIntegerValue("net_error", value); 66 return GetIntegerValue("net_error", value);
68 } 67 }
69 68
70 std::string CapturingNetLog::CapturedEntry::GetParamsJson() const { 69 std::string CapturingNetLog::CapturedEntry::GetParamsJson() const {
71 if (!params) 70 if (!params)
72 return std::string(); 71 return std::string();
73 std::string json; 72 std::string json;
74 base::JSONWriter::Write(params.get(), &json); 73 base::JSONWriter::Write(params.get(), &json);
75 return json; 74 return json;
76 } 75 }
77 76
78 CapturingNetLog::Observer::Observer() {} 77 CapturingNetLog::Observer::Observer() {
78 }
79 79
80 CapturingNetLog::Observer::~Observer() {} 80 CapturingNetLog::Observer::~Observer() {
81 }
81 82
82 void CapturingNetLog::Observer::GetEntries( 83 void CapturingNetLog::Observer::GetEntries(
83 CapturedEntryList* entry_list) const { 84 CapturedEntryList* entry_list) const {
84 base::AutoLock lock(lock_); 85 base::AutoLock lock(lock_);
85 *entry_list = captured_entries_; 86 *entry_list = captured_entries_;
86 } 87 }
87 88
88 void CapturingNetLog::Observer::GetEntriesForSource( 89 void CapturingNetLog::Observer::GetEntriesForSource(
89 NetLog::Source source, 90 NetLog::Source source,
90 CapturedEntryList* entry_list) const { 91 CapturedEntryList* entry_list) const {
91 base::AutoLock lock(lock_); 92 base::AutoLock lock(lock_);
92 entry_list->clear(); 93 entry_list->clear();
93 for (CapturedEntryList::const_iterator entry = captured_entries_.begin(); 94 for (CapturedEntryList::const_iterator entry = captured_entries_.begin();
94 entry != captured_entries_.end(); ++entry) { 95 entry != captured_entries_.end();
96 ++entry) {
95 if (entry->source.id == source.id) 97 if (entry->source.id == source.id)
96 entry_list->push_back(*entry); 98 entry_list->push_back(*entry);
97 } 99 }
98 } 100 }
99 101
100 size_t CapturingNetLog::Observer::GetSize() const { 102 size_t CapturingNetLog::Observer::GetSize() const {
101 base::AutoLock lock(lock_); 103 base::AutoLock lock(lock_);
102 return captured_entries_.size(); 104 return captured_entries_.size();
103 } 105 }
104 106
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 140
139 void CapturingNetLog::SetLogLevel(NetLog::LogLevel log_level) { 141 void CapturingNetLog::SetLogLevel(NetLog::LogLevel log_level) {
140 SetObserverLogLevel(&capturing_net_log_observer_, log_level); 142 SetObserverLogLevel(&capturing_net_log_observer_, log_level);
141 } 143 }
142 144
143 void CapturingNetLog::GetEntries( 145 void CapturingNetLog::GetEntries(
144 CapturingNetLog::CapturedEntryList* entry_list) const { 146 CapturingNetLog::CapturedEntryList* entry_list) const {
145 capturing_net_log_observer_.GetEntries(entry_list); 147 capturing_net_log_observer_.GetEntries(entry_list);
146 } 148 }
147 149
148 void CapturingNetLog::GetEntriesForSource( 150 void CapturingNetLog::GetEntriesForSource(NetLog::Source source,
149 NetLog::Source source, 151 CapturedEntryList* entry_list) const {
150 CapturedEntryList* entry_list) const {
151 capturing_net_log_observer_.GetEntriesForSource(source, entry_list); 152 capturing_net_log_observer_.GetEntriesForSource(source, entry_list);
152 } 153 }
153 154
154 size_t CapturingNetLog::GetSize() const { 155 size_t CapturingNetLog::GetSize() const {
155 return capturing_net_log_observer_.GetSize(); 156 return capturing_net_log_observer_.GetSize();
156 } 157 }
157 158
158 void CapturingNetLog::Clear() { 159 void CapturingNetLog::Clear() {
159 capturing_net_log_observer_.Clear(); 160 capturing_net_log_observer_.Clear();
160 } 161 }
161 162
162 CapturingBoundNetLog::CapturingBoundNetLog() 163 CapturingBoundNetLog::CapturingBoundNetLog()
163 : net_log_(BoundNetLog::Make(&capturing_net_log_, 164 : net_log_(
164 net::NetLog::SOURCE_NONE)) { 165 BoundNetLog::Make(&capturing_net_log_, net::NetLog::SOURCE_NONE)) {
165 } 166 }
166 167
167 CapturingBoundNetLog::~CapturingBoundNetLog() {} 168 CapturingBoundNetLog::~CapturingBoundNetLog() {
169 }
168 170
169 void CapturingBoundNetLog::GetEntries( 171 void CapturingBoundNetLog::GetEntries(
170 CapturingNetLog::CapturedEntryList* entry_list) const { 172 CapturingNetLog::CapturedEntryList* entry_list) const {
171 capturing_net_log_.GetEntries(entry_list); 173 capturing_net_log_.GetEntries(entry_list);
172 } 174 }
173 175
174 void CapturingBoundNetLog::GetEntriesForSource( 176 void CapturingBoundNetLog::GetEntriesForSource(
175 NetLog::Source source, 177 NetLog::Source source,
176 CapturingNetLog::CapturedEntryList* entry_list) const { 178 CapturingNetLog::CapturedEntryList* entry_list) const {
177 capturing_net_log_.GetEntriesForSource(source, entry_list); 179 capturing_net_log_.GetEntriesForSource(source, entry_list);
178 } 180 }
179 181
180 size_t CapturingBoundNetLog::GetSize() const { 182 size_t CapturingBoundNetLog::GetSize() const {
181 return capturing_net_log_.GetSize(); 183 return capturing_net_log_.GetSize();
182 } 184 }
183 185
184 void CapturingBoundNetLog::Clear() { 186 void CapturingBoundNetLog::Clear() {
185 capturing_net_log_.Clear(); 187 capturing_net_log_.Clear();
186 } 188 }
187 189
188 void CapturingBoundNetLog::SetLogLevel(NetLog::LogLevel log_level) { 190 void CapturingBoundNetLog::SetLogLevel(NetLog::LogLevel log_level) {
189 capturing_net_log_.SetLogLevel(log_level); 191 capturing_net_log_.SetLogLevel(log_level);
190 } 192 }
191 193
192 } // namespace net 194 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698