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

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

Issue 5560013: A scoped NetLog event that automatically logs an end event on destruction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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.h" 5 #include "net/base/net_log.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 return dict; 187 return dict;
188 } 188 }
189 189
190 Value* NetLogSourceParameter::ToValue() const { 190 Value* NetLogSourceParameter::ToValue() const {
191 DictionaryValue* dict = new DictionaryValue(); 191 DictionaryValue* dict = new DictionaryValue();
192 192
193 dict->Set(name_, value_.ToValue()); 193 dict->Set(name_, value_.ToValue());
194 return dict; 194 return dict;
195 } 195 }
196 196
197 ScopedNetLogEvent::ScopedNetLogEvent(
198 const BoundNetLog& net_log,
199 NetLog::EventType event_type,
200 const scoped_refptr<NetLog::EventParameters>& params)
201 : net_log_(net_log),
202 event_type_(event_type),
203 end_event_parameters_(NULL) {
eroman 2010/12/09 02:00:14 nit: I have always seen this omitted in chrome cod
mmenke 2010/12/09 15:12:01 Done.
204 net_log_.BeginEvent(event_type, params);
205 }
206
207 ScopedNetLogEvent::~ScopedNetLogEvent() {
208 net_log_.EndEvent(event_type_, end_event_parameters_);
209 }
210
211 void ScopedNetLogEvent::SetEndEventParameters(
212 const scoped_refptr<NetLog::EventParameters>& end_event_parameters) {
213 DCHECK(!end_event_parameters_.get());
214 end_event_parameters_ = end_event_parameters;
215 }
216
217 const BoundNetLog& ScopedNetLogEvent::net_log() const {
218 return net_log_;
219 }
220
197 } // namespace net 221 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_log.h ('k') | net/base/net_log_unittest.cc » ('j') | net/base/net_log_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698