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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 dict->SetInteger("type", static_cast<int>(type)); | 92 dict->SetInteger("type", static_cast<int>(type)); |
93 dict->SetInteger("id", static_cast<int>(id)); | 93 dict->SetInteger("id", static_cast<int>(id)); |
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(Value* event_params, Source* source) { | 102 bool NetLog::Source::FromEventParameters(base::Value* event_params, |
| 103 Source* source) { |
103 base::DictionaryValue* dict; | 104 base::DictionaryValue* dict; |
104 base::DictionaryValue* source_dict; | 105 base::DictionaryValue* source_dict; |
105 int source_id; | 106 int source_id; |
106 int source_type; | 107 int source_type; |
107 if (!event_params || | 108 if (!event_params || |
108 !event_params->GetAsDictionary(&dict) || | 109 !event_params->GetAsDictionary(&dict) || |
109 !dict->GetDictionary("source_dependency", &source_dict) || | 110 !dict->GetDictionary("source_dependency", &source_dict) || |
110 !source_dict->GetInteger("id", &source_id) || | 111 !source_dict->GetInteger("id", &source_id) || |
111 !source_dict->GetInteger("type", &source_type)) { | 112 !source_dict->GetInteger("type", &source_type)) { |
112 *source = Source(); | 113 *source = Source(); |
(...skipping 16 matching lines...) Expand all Loading... |
129 source_dict->SetInteger("id", source_.id); | 130 source_dict->SetInteger("id", source_.id); |
130 source_dict->SetInteger("type", static_cast<int>(source_.type)); | 131 source_dict->SetInteger("type", static_cast<int>(source_.type)); |
131 entry_dict->Set("source", source_dict); | 132 entry_dict->Set("source", source_dict); |
132 | 133 |
133 // Set the event info. | 134 // Set the event info. |
134 entry_dict->SetInteger("type", static_cast<int>(type_)); | 135 entry_dict->SetInteger("type", static_cast<int>(type_)); |
135 entry_dict->SetInteger("phase", static_cast<int>(phase_)); | 136 entry_dict->SetInteger("phase", static_cast<int>(phase_)); |
136 | 137 |
137 // Set the event-specific parameters. | 138 // Set the event-specific parameters. |
138 if (parameters_callback_) { | 139 if (parameters_callback_) { |
139 Value* value = parameters_callback_->Run(log_level_); | 140 base::Value* value = parameters_callback_->Run(log_level_); |
140 if (value) | 141 if (value) |
141 entry_dict->Set("params", value); | 142 entry_dict->Set("params", value); |
142 } | 143 } |
143 | 144 |
144 return entry_dict; | 145 return entry_dict; |
145 } | 146 } |
146 | 147 |
147 base::Value* NetLog::Entry::ParametersToValue() const { | 148 base::Value* NetLog::Entry::ParametersToValue() const { |
148 if (parameters_callback_) | 149 if (parameters_callback_) |
149 return parameters_callback_->Run(log_level_); | 150 return parameters_callback_->Run(log_level_); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 BoundNetLog BoundNetLog::Make(NetLog* net_log, | 484 BoundNetLog BoundNetLog::Make(NetLog* net_log, |
484 NetLog::SourceType source_type) { | 485 NetLog::SourceType source_type) { |
485 if (!net_log) | 486 if (!net_log) |
486 return BoundNetLog(); | 487 return BoundNetLog(); |
487 | 488 |
488 NetLog::Source source(source_type, net_log->NextID()); | 489 NetLog::Source source(source_type, net_log->NextID()); |
489 return BoundNetLog(source, net_log); | 490 return BoundNetLog(source, net_log); |
490 } | 491 } |
491 | 492 |
492 } // namespace net | 493 } // namespace net |
OLD | NEW |