forked from catapult-project/catapult
-
Notifications
You must be signed in to change notification settings - Fork 0
/
net_constants.js
156 lines (138 loc) · 4.49 KB
/
net_constants.js
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// Copyright (c) 2016 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.
'use strict';
// TODO(rayraymond): This is a big hack that accounts for the
// following problem in the NetLog viewer code: There are
// several constants in Chromium that the web app does not have
// initial values for until a log is loaded. Originally,
// chrome://net-internals got values for these constants from
// the browser when about:net-internals was first loaded. This
// is no longer the case in this web app. However, certain test
// files in the NetLog viewer code
// (i.e. log_view_painter_test.html and events_view_test.html)
// rely on these constants to be defined globally, rather than
// them being passed around as input to the functions that need
// them. This file defines two functions which set and unset
// initial values for the constants that are used in the test
// files. Comments are provided for what specific files within
// Chromium these constants are taken from.
function setNetLogConstantsForTest() {
// See net/log/net_log_util.cc in Chromium.
Constants = {
clientInfo: {
numericDate: ''
}
};
// See net/log/net_log.h in Chromium.
EventPhase = {
PHASE_BEGIN: 0,
PHASE_END: 1,
PHASE_NONE: 2
};
// See net/log/net_log_source_type_list.h in Chromium.
EventSourceType = {
NONE: 0,
URL_REQUEST: 1,
TRANSPORT_CONNECT_JOB: 2,
SOCKET: 3,
HOST_RESOLVER_IMPL_JOB: 4,
HTTP_STREAM_JOB: 5,
CERT_VERIFIER_JOB: 6
};
EventSourceTypeNames = makeInverseMap(EventSourceType);
// See net/log/net_log_event_type_list.h in Chromium.
EventType = {
REQUEST_ALIVE: 0,
HOST_RESOLVER_IMPL_JOB: 1,
PROXY_CONFIG_CHANGED: 2,
SOCKET_ALIVE: 3,
TCP_CONNECT: 4,
TCP_CONNECT_ATTEMPT: 5,
SOCKET_IN_USE: 6,
SSL_VERSION_FALLBACK: 7,
SOCKET_BYTES_SENT: 8,
SOCKET_BYTES_RECEIVED: 9,
UDP_BYTES_SENT: 10,
URL_REQUEST_START_JOB: 11,
HTTP_CACHE_GET_BACKEND: 12,
HTTP_CACHE_OPEN_ENTRY: 13,
HTTP_CACHE_CREATE_ENTRY: 14,
HTTP_CACHE_ADD_TO_ENTRY: 15,
HTTP_CACHE_READ_INFO: 16,
HTTP_CACHE_WRITE_INFO: 17,
HTTP_CACHE_WRITE_DATA: 18,
ENTRY_READ_DATA: 19,
ENTRY_WRITE_DATA: 20,
HTTP_STREAM_REQUEST: 21,
HTTP_STREAM_REQUEST_BOUND_TO_JOB: 22,
HTTP_TRANSACTION_SEND_REQUEST: 23,
HTTP_TRANSACTION_SEND_REQUEST_HEADERS: 24,
HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS: 25,
HTTP_TRANSACTION_READ_HEADERS: 26,
HTTP_TRANSACTION_READ_RESPONSE_HEADERS: 27,
HTTP_TRANSACTION_READ_BODY: 28,
HTTP2_SESSION_SEND_HEADERS: 29,
HTTP2_SESSION_RECV_HEADERS: 30,
HTTP2_SESSION_GOAWAY: 31,
QUIC_SESSION: 32,
QUIC_SESSION_RST_STREAM_FRAME_RECEIVED: 33,
QUIC_SESSION_CONNECTION_CLOSE_FRAME_RECEIVED: 34,
QUIC_SESSION_CRYPTO_HANDSHAKE_MESSAGE_SENT: 35,
HTTP_STREAM_PARSER_READ_HEADERS: 36,
CERT_VERIFIER_JOB: 37,
CERT_CT_COMPLIANCE_CHECKED: 38
};
EventTypeNames = makeInverseMap(EventType);
// These flags provide metadata about the type of the load request.
// See net/base/load_flags.h in Chromium.
LoadFlag = {
NORMAL: 0,
MAIN_FRAME_DEPRECATED: 1 << 12,
MAYBE_USER_GESTURE: 1 << 15,
VERIFY_EV_CERT: 1 << 8
};
// These states correspond to the lengthy periods of time that a
// resource load may be blocked and unable to make progress.
// See net/base/load_states.h in Chromium.
LoadState = {
READING_RESPONSE: 15
};
// Bitmask of status flags of a certificate, representing any
// errors, as well as other non-error status information such
// as whether the certificate is EV.
// See net/cert/cert_status_flags.h in Chromium.
CertStatusFlag = {
AUTHORITY_INVALID: 1 << 2,
COMMON_NAME_INVALID: 1 << 0
};
// See net/quic/core/quic_protocol.h in Chromium.
QuicRstStreamError = {
QUIC_BAD_APPLICATION_PAYLOAD: 0
};
// See net/quic/core/quic_protocol.h in Chromium.
QuicError = {
QUIC_NETWORK_IDLE_TIMEOUT: 25
};
// Error domain of the net module's error codes.
// See net/base/net_errors.h in Chromium.
NetError = {
ERR_FAILED: -2,
ERR_NAME_NOT_RESOLVED: -105,
ERR_SSL_PROTOCOL_ERROR: -107
};
}
function unsetNetLogConstantsForTest() {
Constants = null;
EventType = null;
EventTypeNames = null;
EventPhase = null;
EventSourceType = null;
EventSourceTypeNames = null;
NetError = null;
QuicError = null;
QuicRstStreamError = null;
LoadFlag = null;
CertStatusFlag = null;
LoadState = null;
}