blob: 6f9c67db862f078fe7d085632ee81f9ce3f55b45 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
// Copyright 2018 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 "content/renderer/resource_timing_info_conversions.h"
#include <string>
#include <vector>
#include "content/common/resource_timing_info.h"
#include "third_party/WebKit/public/platform/WebResourceTimingInfo.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebVector.h"
namespace content {
ResourceTimingInfo WebResourceTimingInfoToResourceTimingInfo(
const blink::WebResourceTimingInfo& info) {
// TODO(dcheng): This is sad. Move this to Mojo.
ResourceTimingInfo resource_timing;
resource_timing.name = info.name.Utf8();
resource_timing.start_time = info.start_time;
resource_timing.alpn_negotiated_protocol =
info.alpn_negotiated_protocol.Utf8();
resource_timing.connection_info = info.connection_info.Utf8();
if (!info.timing.IsNull()) {
resource_timing.timing.emplace();
resource_timing.timing->request_time = info.timing.RequestTime();
resource_timing.timing->proxy_start = info.timing.ProxyStart();
resource_timing.timing->proxy_end = info.timing.ProxyEnd();
resource_timing.timing->dns_start = info.timing.DnsStart();
resource_timing.timing->dns_end = info.timing.DnsEnd();
resource_timing.timing->connect_start = info.timing.ConnectStart();
resource_timing.timing->connect_end = info.timing.ConnectEnd();
resource_timing.timing->worker_start = info.timing.WorkerStart();
resource_timing.timing->worker_ready = info.timing.WorkerReady();
resource_timing.timing->send_start = info.timing.SendStart();
resource_timing.timing->send_end = info.timing.SendEnd();
resource_timing.timing->receive_headers_end =
info.timing.ReceiveHeadersEnd();
resource_timing.timing->ssl_start = info.timing.SslStart();
resource_timing.timing->ssl_end = info.timing.SslEnd();
resource_timing.timing->push_start = info.timing.PushStart();
resource_timing.timing->push_end = info.timing.PushEnd();
}
resource_timing.last_redirect_end_time = info.last_redirect_end_time;
resource_timing.finish_time = info.finish_time;
resource_timing.transfer_size = info.transfer_size;
resource_timing.encoded_body_size = info.encoded_body_size;
resource_timing.decoded_body_size = info.decoded_body_size;
resource_timing.did_reuse_connection = info.did_reuse_connection;
resource_timing.allow_timing_details = info.allow_timing_details;
resource_timing.allow_redirect_details = info.allow_redirect_details;
resource_timing.allow_negative_values = info.allow_negative_values;
for (const auto& entry : info.server_timing) {
resource_timing.server_timing.emplace_back();
auto& new_entry = resource_timing.server_timing.back();
new_entry.name = entry.name.Utf8();
new_entry.duration = entry.duration;
new_entry.description = entry.description.Utf8();
}
return resource_timing;
}
blink::WebResourceTimingInfo ResourceTimingInfoToWebResourceTimingInfo(
const ResourceTimingInfo& resource_timing) {
// TODO(dcheng): This is sad. Move this to Mojo.
blink::WebResourceTimingInfo info;
info.name = blink::WebString::FromUTF8(resource_timing.name);
info.start_time = resource_timing.start_time;
info.alpn_negotiated_protocol =
blink::WebString::FromUTF8(resource_timing.alpn_negotiated_protocol);
info.connection_info =
blink::WebString::FromUTF8(resource_timing.connection_info);
if (resource_timing.timing) {
info.timing.Initialize();
info.timing.SetRequestTime(resource_timing.timing->request_time);
info.timing.SetProxyStart(resource_timing.timing->proxy_start);
info.timing.SetProxyEnd(resource_timing.timing->proxy_end);
info.timing.SetDNSStart(resource_timing.timing->dns_start);
info.timing.SetDNSEnd(resource_timing.timing->dns_end);
info.timing.SetConnectStart(resource_timing.timing->connect_start);
info.timing.SetConnectEnd(resource_timing.timing->connect_end);
info.timing.SetWorkerStart(resource_timing.timing->worker_start);
info.timing.SetWorkerReady(resource_timing.timing->worker_ready);
info.timing.SetSendStart(resource_timing.timing->send_start);
info.timing.SetSendEnd(resource_timing.timing->send_end);
info.timing.SetReceiveHeadersEnd(
resource_timing.timing->receive_headers_end);
info.timing.SetSSLStart(resource_timing.timing->ssl_start);
info.timing.SetSSLEnd(resource_timing.timing->ssl_end);
info.timing.SetPushStart(resource_timing.timing->push_start);
info.timing.SetPushEnd(resource_timing.timing->push_end);
}
info.last_redirect_end_time = resource_timing.last_redirect_end_time;
info.finish_time = resource_timing.finish_time;
info.transfer_size = resource_timing.transfer_size;
info.encoded_body_size = resource_timing.encoded_body_size;
info.decoded_body_size = resource_timing.decoded_body_size;
info.did_reuse_connection = resource_timing.did_reuse_connection;
info.allow_timing_details = resource_timing.allow_timing_details;
info.allow_redirect_details = resource_timing.allow_redirect_details;
info.allow_negative_values = resource_timing.allow_negative_values;
info.server_timing.reserve(resource_timing.server_timing.size());
for (const auto& server_timing : resource_timing.server_timing) {
info.server_timing.emplace_back(
blink::WebString::FromUTF8(server_timing.name), server_timing.duration,
blink::WebString::FromUTF8(server_timing.description));
}
return info;
}
} // namespace content
|