Chromium Code Reviews| Index: third_party/WebKit/Source/platform/instrumentation/inspector/PlatformInspectorTraceEvents.cpp |
| diff --git a/third_party/WebKit/Source/platform/instrumentation/inspector/PlatformInspectorTraceEvents.cpp b/third_party/WebKit/Source/platform/instrumentation/inspector/PlatformInspectorTraceEvents.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..33fa4fd075117dc21a1ee2ac9f15237f99320099 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/instrumentation/inspector/PlatformInspectorTraceEvents.cpp |
| @@ -0,0 +1,93 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "platform/instrumentation/inspector/PlatformInspectorTraceEvents.h" |
| + |
| +#include "platform/instrumentation/inspector/PlatformIdentifiersFactory.h" |
| +#include "platform/network/ResourceResponse.h" |
| + |
| +namespace blink { |
| + |
| +namespace { |
| +void recordTiming(const ResourceLoadTiming& timing, TracedValue* value) { |
| + value->setDouble("requestTime", timing.requestTime()); |
| + value->setDouble("proxyStart", |
| + timing.calculateMillisecondDelta(timing.proxyStart())); |
| + value->setDouble("proxyEnd", |
| + timing.calculateMillisecondDelta(timing.proxyEnd())); |
| + value->setDouble("dnsStart", |
| + timing.calculateMillisecondDelta(timing.dnsStart())); |
| + value->setDouble("dnsEnd", timing.calculateMillisecondDelta(timing.dnsEnd())); |
| + value->setDouble("connectStart", |
| + timing.calculateMillisecondDelta(timing.connectStart())); |
| + value->setDouble("connectEnd", |
| + timing.calculateMillisecondDelta(timing.connectEnd())); |
| + value->setDouble("sslStart", |
| + timing.calculateMillisecondDelta(timing.sslStart())); |
| + value->setDouble("sslEnd", timing.calculateMillisecondDelta(timing.sslEnd())); |
| + value->setDouble("workerStart", |
| + timing.calculateMillisecondDelta(timing.workerStart())); |
| + value->setDouble("workerReady", |
| + timing.calculateMillisecondDelta(timing.workerReady())); |
| + value->setDouble("sendStart", |
| + timing.calculateMillisecondDelta(timing.sendStart())); |
| + value->setDouble("sendEnd", |
| + timing.calculateMillisecondDelta(timing.sendEnd())); |
| + value->setDouble("receiveHeadersEnd", timing.calculateMillisecondDelta( |
| + timing.receiveHeadersEnd())); |
| + value->setDouble("pushStart", timing.pushStart()); |
| + value->setDouble("pushEnd", timing.pushEnd()); |
| +} |
| +} // namespace |
| + |
| +std::unique_ptr<TracedValue> InspectorReceiveResponseEvent::data( |
| + unsigned long identifier, |
| + const ResourceResponse& response) { |
| + String requestId = PlatformIdentifiersFactory::requestId(identifier); |
| + |
| + std::unique_ptr<TracedValue> value = TracedValue::create(); |
| + value->setString("requestId", requestId); |
| + value->setInteger("statusCode", response.httpStatusCode()); |
| + value->setString("mimeType", response.mimeType().getString().isolatedCopy()); |
| + value->setDouble("encodedDataLength", response.encodedDataLength()); |
| + value->setBoolean("fromCache", response.wasCached()); |
| + value->setBoolean("fromServiceWorker", response.wasFetchedViaServiceWorker()); |
| + if (response.resourceLoadTiming()) { |
| + value->beginDictionary("timing"); |
| + recordTiming(*response.resourceLoadTiming(), value.get()); |
| + value->endDictionary(); |
| + } |
| + if (response.wasFetchedViaServiceWorker()) |
| + value->setBoolean("fromServiceWorker", true); |
| + return value; |
| +} |
| + |
| +std::unique_ptr<TracedValue> InspectorReceiveDataEvent::data( |
| + unsigned long identifier, |
| + int encodedDataLength) { |
| + String requestId = PlatformIdentifiersFactory::requestId(identifier); |
| + |
| + std::unique_ptr<TracedValue> value = TracedValue::create(); |
| + value->setString("requestId", requestId); |
| + value->setInteger("encodedDataLength", encodedDataLength); |
| + return value; |
| +} |
| + |
| +std::unique_ptr<TracedValue> InspectorResourceFinishEvent::data( |
| + unsigned long identifier, |
| + double finishTime, |
| + bool didFail, |
| + int64_t encodedDataLength) { |
| + String requestId = PlatformIdentifiersFactory::requestId(identifier); |
|
caseq
2017/02/21 22:53:30
Let's avoid doing this -- perhaps use the original
alph
2017/02/22 00:31:32
Done.
|
| + |
| + std::unique_ptr<TracedValue> value = TracedValue::create(); |
| + value->setString("requestId", requestId); |
| + value->setBoolean("didFail", didFail); |
| + value->setDouble("encodedDataLength", encodedDataLength); |
| + if (finishTime) |
| + value->setDouble("finishTime", finishTime); |
| + return value; |
| +} |
| + |
| +} // namespace blink |