| 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/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 event_params->Set("source_dependency", dict); | 94 event_params->Set("source_dependency", dict); |
| 95 } | 95 } |
| 96 | 96 |
| 97 NetLog::ParametersCallback NetLog::Source::ToEventParametersCallback() const { | 97 NetLog::ParametersCallback NetLog::Source::ToEventParametersCallback() const { |
| 98 return base::Bind(&SourceEventParametersCallback, *this); | 98 return base::Bind(&SourceEventParametersCallback, *this); |
| 99 } | 99 } |
| 100 | 100 |
| 101 // static | 101 // static |
| 102 bool NetLog::Source::FromEventParameters(base::Value* event_params, | 102 bool NetLog::Source::FromEventParameters(base::Value* event_params, |
| 103 Source* source) { | 103 Source* source) { |
| 104 base::DictionaryValue* dict; | 104 base::DictionaryValue* dict = NULL; |
| 105 base::DictionaryValue* source_dict; | 105 base::DictionaryValue* source_dict = NULL; |
| 106 int source_id; | 106 int source_id = -1; |
| 107 int source_type; | 107 int source_type = NetLog::SOURCE_COUNT; |
| 108 if (!event_params || | 108 if (!event_params || |
| 109 !event_params->GetAsDictionary(&dict) || | 109 !event_params->GetAsDictionary(&dict) || |
| 110 !dict->GetDictionary("source_dependency", &source_dict) || | 110 !dict->GetDictionary("source_dependency", &source_dict) || |
| 111 !source_dict->GetInteger("id", &source_id) || | 111 !source_dict->GetInteger("id", &source_id) || |
| 112 !source_dict->GetInteger("type", &source_type)) { | 112 !source_dict->GetInteger("type", &source_type)) { |
| 113 *source = Source(); | 113 *source = Source(); |
| 114 return false; | 114 return false; |
| 115 } | 115 } |
| 116 | 116 |
| 117 DCHECK_LE(0, source_id); | 117 DCHECK_GE(source_id, 0); |
| 118 DCHECK_LT(source_type, NetLog::SOURCE_COUNT); | 118 DCHECK_LT(source_type, NetLog::SOURCE_COUNT); |
| 119 *source = Source(static_cast<SourceType>(source_type), source_id); | 119 *source = Source(static_cast<SourceType>(source_type), source_id); |
| 120 return true; | 120 return true; |
| 121 } | 121 } |
| 122 | 122 |
| 123 base::Value* NetLog::Entry::ToValue() const { | 123 base::Value* NetLog::Entry::ToValue() const { |
| 124 base::DictionaryValue* entry_dict(new base::DictionaryValue()); | 124 base::DictionaryValue* entry_dict(new base::DictionaryValue()); |
| 125 | 125 |
| 126 entry_dict->SetString("time", TickCountToString(data_->time)); | 126 entry_dict->SetString("time", TickCountToString(data_->time)); |
| 127 | 127 |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 BoundNetLog BoundNetLog::Make(NetLog* net_log, | 498 BoundNetLog BoundNetLog::Make(NetLog* net_log, |
| 499 NetLog::SourceType source_type) { | 499 NetLog::SourceType source_type) { |
| 500 if (!net_log) | 500 if (!net_log) |
| 501 return BoundNetLog(); | 501 return BoundNetLog(); |
| 502 | 502 |
| 503 NetLog::Source source(source_type, net_log->NextID()); | 503 NetLog::Source source(source_type, net_log->NextID()); |
| 504 return BoundNetLog(source, net_log); | 504 return BoundNetLog(source, net_log); |
| 505 } | 505 } |
| 506 | 506 |
| 507 } // namespace net | 507 } // namespace net |
| OLD | NEW |