Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/net_log.h" | 5 #include "net/base/net_log.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 Value* SingleIntegerCallback(const char* name, | 48 Value* SingleIntegerCallback(const char* name, |
| 49 int value, | 49 int value, |
| 50 NetLog::LogLevel /* log_level */) { | 50 NetLog::LogLevel /* log_level */) { |
| 51 if (!value) | 51 if (!value) |
| 52 return NULL; | 52 return NULL; |
| 53 DictionaryValue* event_params = new DictionaryValue(); | 53 DictionaryValue* event_params = new DictionaryValue(); |
| 54 event_params->SetInteger(name, value); | 54 event_params->SetInteger(name, value); |
| 55 return event_params; | 55 return event_params; |
| 56 } | 56 } |
| 57 | 57 |
| 58 Value* SingleStringCallback(const char* name, | |
| 59 const std::string* value, | |
| 60 NetLog::LogLevel /* log_level */) { | |
| 61 if (!value) | |
|
eroman
2012/06/11 23:42:25
Is it necessary to allow this? Seems like passing
mmenke
2012/06/12 00:42:19
You're right, done. Also, noticed other related b
| |
| 62 return NULL; | |
| 63 DictionaryValue* event_params = new DictionaryValue(); | |
| 64 event_params->SetString(name, *value); | |
| 65 return event_params; | |
| 66 } | |
| 67 | |
| 58 } // namespace | 68 } // namespace |
| 59 | 69 |
| 60 Value* NetLog::Source::ToValue() const { | 70 Value* NetLog::Source::ToValue() const { |
| 61 DictionaryValue* dict = new DictionaryValue(); | 71 DictionaryValue* dict = new DictionaryValue(); |
| 62 dict->SetInteger("type", static_cast<int>(type)); | 72 dict->SetInteger("type", static_cast<int>(type)); |
| 63 dict->SetInteger("id", static_cast<int>(id)); | 73 dict->SetInteger("id", static_cast<int>(id)); |
| 64 return dict; | 74 return dict; |
| 65 } | 75 } |
| 66 | 76 |
| 67 void NetLog::Source::AddToEventParameters(DictionaryValue* event_params) const { | 77 void NetLog::Source::AddToEventParameters(DictionaryValue* event_params) const { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 bool NetLog::IsLoggingAllEvents(LogLevel log_level) { | 269 bool NetLog::IsLoggingAllEvents(LogLevel log_level) { |
| 260 return log_level <= NetLog::LOG_ALL_BUT_BYTES; | 270 return log_level <= NetLog::LOG_ALL_BUT_BYTES; |
| 261 } | 271 } |
| 262 | 272 |
| 263 // static | 273 // static |
| 264 NetLog::ParametersCallback NetLog::IntegerCallback(const char* name, | 274 NetLog::ParametersCallback NetLog::IntegerCallback(const char* name, |
| 265 int value) { | 275 int value) { |
| 266 return base::Bind(&SingleIntegerCallback, name, value); | 276 return base::Bind(&SingleIntegerCallback, name, value); |
| 267 } | 277 } |
| 268 | 278 |
| 279 // static | |
| 280 NetLog::ParametersCallback NetLog::StringCallback(const char* name, | |
| 281 const std::string* value) { | |
| 282 return base::Bind(&SingleStringCallback, name, value); | |
| 283 } | |
| 284 | |
| 269 void NetLog::OnAddObserver(ThreadSafeObserver* observer, LogLevel log_level) { | 285 void NetLog::OnAddObserver(ThreadSafeObserver* observer, LogLevel log_level) { |
| 270 DCHECK(!observer->net_log_); | 286 DCHECK(!observer->net_log_); |
| 271 observer->net_log_ = this; | 287 observer->net_log_ = this; |
| 272 observer->log_level_ = log_level; | 288 observer->log_level_ = log_level; |
| 273 } | 289 } |
| 274 | 290 |
| 275 void NetLog::OnSetObserverLogLevel(ThreadSafeObserver* observer, | 291 void NetLog::OnSetObserverLogLevel(ThreadSafeObserver* observer, |
| 276 LogLevel log_level) { | 292 LogLevel log_level) { |
| 277 DCHECK_EQ(this, observer->net_log_); | 293 DCHECK_EQ(this, observer->net_log_); |
| 278 observer->log_level_ = log_level; | 294 observer->log_level_ = log_level; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 } | 446 } |
| 431 | 447 |
| 432 Value* NetLogSourceParameter::ToValue() const { | 448 Value* NetLogSourceParameter::ToValue() const { |
| 433 DictionaryValue* dict = new DictionaryValue(); | 449 DictionaryValue* dict = new DictionaryValue(); |
| 434 if (value_.is_valid()) | 450 if (value_.is_valid()) |
| 435 dict->Set(name_, value_.ToValue()); | 451 dict->Set(name_, value_.ToValue()); |
| 436 return dict; | 452 return dict; |
| 437 } | 453 } |
| 438 | 454 |
| 439 } // namespace net | 455 } // namespace net |
| OLD | NEW |