Chromium Code Reviews

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.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « net/base/net_log.h ('k') | net/base/net_log_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 (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...)
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 net_log_.BeginEvent(event_type, params);
204 }
205
206 ScopedNetLogEvent::~ScopedNetLogEvent() {
207 net_log_.EndEvent(event_type_, end_event_params_);
208 }
209
210 void ScopedNetLogEvent::SetEndEventParameters(
211 const scoped_refptr<NetLog::EventParameters>& end_event_params) {
212 DCHECK(!end_event_params_.get());
213 end_event_params_ = end_event_params;
214 }
215
216 const BoundNetLog& ScopedNetLogEvent::net_log() const {
217 return net_log_;
218 }
219
197 } // namespace net 220 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_log.h ('k') | net/base/net_log_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine