| 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 22 matching lines...) Expand all Loading... |
| 33 Value* EventParametersCallback( | 33 Value* EventParametersCallback( |
| 34 const scoped_refptr<NetLog::EventParameters>& params, | 34 const scoped_refptr<NetLog::EventParameters>& params, |
| 35 NetLog::LogLevel /* log_level */) { | 35 NetLog::LogLevel /* log_level */) { |
| 36 if (!params.get()) | 36 if (!params.get()) |
| 37 return NULL; | 37 return NULL; |
| 38 return params->ToValue(); | 38 return params->ToValue(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 Value* SourceEventParametersCallback(const NetLog::Source source, | 41 Value* SourceEventParametersCallback(const NetLog::Source source, |
| 42 NetLog::LogLevel /* log_level */) { | 42 NetLog::LogLevel /* log_level */) { |
| 43 if (!source.is_valid()) |
| 44 return NULL; |
| 43 DictionaryValue* event_params = new DictionaryValue(); | 45 DictionaryValue* event_params = new DictionaryValue(); |
| 44 source.AddToEventParameters(event_params); | 46 source.AddToEventParameters(event_params); |
| 45 return event_params; | 47 return event_params; |
| 46 } | 48 } |
| 47 | 49 |
| 48 Value* NetLogIntegerCallback(const char* name, | 50 Value* NetLogIntegerCallback(const char* name, |
| 49 int value, | 51 int value, |
| 50 NetLog::LogLevel /* log_level */) { | 52 NetLog::LogLevel /* log_level */) { |
| 51 DictionaryValue* event_params = new DictionaryValue(); | 53 DictionaryValue* event_params = new DictionaryValue(); |
| 52 event_params->SetInteger(name, value); | 54 event_params->SetInteger(name, value); |
| 53 return event_params; | 55 return event_params; |
| 54 } | 56 } |
| 55 | 57 |
| 56 Value* NetLogStringCallback(const char* name, | 58 Value* NetLogStringCallback(const char* name, |
| 57 const std::string* value, | 59 const std::string* value, |
| 58 NetLog::LogLevel /* log_level */) { | 60 NetLog::LogLevel /* log_level */) { |
| 59 DictionaryValue* event_params = new DictionaryValue(); | 61 DictionaryValue* event_params = new DictionaryValue(); |
| 60 event_params->SetString(name, *value); | 62 event_params->SetString(name, *value); |
| 61 return event_params; | 63 return event_params; |
| 62 } | 64 } |
| 63 | 65 |
| 66 Value* NetLogString16Callback(const char* name, |
| 67 const string16* value, |
| 68 NetLog::LogLevel /* log_level */) { |
| 69 DictionaryValue* event_params = new DictionaryValue(); |
| 70 event_params->SetString(name, *value); |
| 71 return event_params; |
| 72 } |
| 73 |
| 64 } // namespace | 74 } // namespace |
| 65 | 75 |
| 66 Value* NetLog::Source::ToValue() const { | 76 Value* NetLog::Source::ToValue() const { |
| 67 DictionaryValue* dict = new DictionaryValue(); | 77 DictionaryValue* dict = new DictionaryValue(); |
| 68 dict->SetInteger("type", static_cast<int>(type)); | 78 dict->SetInteger("type", static_cast<int>(type)); |
| 69 dict->SetInteger("id", static_cast<int>(id)); | 79 dict->SetInteger("id", static_cast<int>(id)); |
| 70 return dict; | 80 return dict; |
| 71 } | 81 } |
| 72 | 82 |
| 73 void NetLog::Source::AddToEventParameters(DictionaryValue* event_params) const { | 83 void NetLog::Source::AddToEventParameters(DictionaryValue* event_params) const { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 return base::Bind(&NetLogIntegerCallback, name, value); | 282 return base::Bind(&NetLogIntegerCallback, name, value); |
| 273 } | 283 } |
| 274 | 284 |
| 275 // static | 285 // static |
| 276 NetLog::ParametersCallback NetLog::StringCallback(const char* name, | 286 NetLog::ParametersCallback NetLog::StringCallback(const char* name, |
| 277 const std::string* value) { | 287 const std::string* value) { |
| 278 DCHECK(value); | 288 DCHECK(value); |
| 279 return base::Bind(&NetLogStringCallback, name, value); | 289 return base::Bind(&NetLogStringCallback, name, value); |
| 280 } | 290 } |
| 281 | 291 |
| 292 // static |
| 293 NetLog::ParametersCallback NetLog::StringCallback(const char* name, |
| 294 const string16* value) { |
| 295 DCHECK(value); |
| 296 return base::Bind(&NetLogString16Callback, name, value); |
| 297 } |
| 298 |
| 282 void NetLog::OnAddObserver(ThreadSafeObserver* observer, LogLevel log_level) { | 299 void NetLog::OnAddObserver(ThreadSafeObserver* observer, LogLevel log_level) { |
| 283 DCHECK(!observer->net_log_); | 300 DCHECK(!observer->net_log_); |
| 284 observer->net_log_ = this; | 301 observer->net_log_ = this; |
| 285 observer->log_level_ = log_level; | 302 observer->log_level_ = log_level; |
| 286 } | 303 } |
| 287 | 304 |
| 288 void NetLog::OnSetObserverLogLevel(ThreadSafeObserver* observer, | 305 void NetLog::OnSetObserverLogLevel(ThreadSafeObserver* observer, |
| 289 LogLevel log_level) { | 306 LogLevel log_level) { |
| 290 DCHECK_EQ(this, observer->net_log_); | 307 DCHECK_EQ(this, observer->net_log_); |
| 291 observer->log_level_ = log_level; | 308 observer->log_level_ = log_level; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 } | 464 } |
| 448 | 465 |
| 449 Value* NetLogSourceParameter::ToValue() const { | 466 Value* NetLogSourceParameter::ToValue() const { |
| 450 DictionaryValue* dict = new DictionaryValue(); | 467 DictionaryValue* dict = new DictionaryValue(); |
| 451 if (value_.is_valid()) | 468 if (value_.is_valid()) |
| 452 dict->Set(name_, value_.ToValue()); | 469 dict->Set(name_, value_.ToValue()); |
| 453 return dict; | 470 return dict; |
| 454 } | 471 } |
| 455 | 472 |
| 456 } // namespace net | 473 } // namespace net |
| OLD | NEW |