OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "core/timing/PerformanceServerTiming.h" | 5 #include "core/timing/PerformanceServerTiming.h" |
6 | |
7 #include "bindings/core/v8/V8ObjectBuilder.h" | 6 #include "bindings/core/v8/V8ObjectBuilder.h" |
8 #include "core/timing/PerformanceBase.h" | |
9 #include "platform/wtf/text/WTFString.h" | 7 #include "platform/wtf/text/WTFString.h" |
10 | 8 |
11 namespace blink { | 9 namespace blink { |
12 | 10 |
13 PerformanceServerTiming::PerformanceServerTiming(const String& name, | 11 PerformanceServerTiming::PerformanceServerTiming(const String& metric, |
14 const String& metric, | 12 double value, |
15 double duration, | 13 const String& description, |
16 const String& description) | 14 bool allow_timing_details) |
17 : PerformanceEntry(name, "server", 0.0, duration), | 15 : metric_(metric), |
18 metric_(metric), | 16 value_(value), |
19 description_(description) {} | 17 description_(description), |
| 18 allow_timing_details_(allow_timing_details) {} |
20 | 19 |
21 PerformanceServerTiming::~PerformanceServerTiming() {} | 20 PerformanceServerTiming::~PerformanceServerTiming() {} |
22 | 21 |
23 String PerformanceServerTiming::metric() const { | 22 String PerformanceServerTiming::metric() const { |
24 return metric_; | 23 return metric_; |
25 } | 24 } |
26 | 25 |
| 26 double PerformanceServerTiming::value() const { |
| 27 return allow_timing_details_ ? value_ : 0.0; |
| 28 } |
| 29 |
27 String PerformanceServerTiming::description() const { | 30 String PerformanceServerTiming::description() const { |
28 return description_; | 31 return allow_timing_details_ ? description_ : ""; |
29 } | 32 } |
30 | 33 |
31 void PerformanceServerTiming::BuildJSONValue(V8ObjectBuilder& builder) const { | 34 void PerformanceServerTiming::BuildJSONValue(V8ObjectBuilder& builder) const { |
32 PerformanceEntry::BuildJSONValue(builder); | |
33 builder.AddString("metric", metric()); | 35 builder.AddString("metric", metric()); |
| 36 builder.AddNumber("value", value()); |
34 builder.AddString("description", description()); | 37 builder.AddString("description", description()); |
35 } | 38 } |
36 | 39 |
37 } // namespace blink | 40 } // namespace blink |
OLD | NEW |