Bug 1526591 - Remove devtools.inspector.shapesHighlighter.enabled pref. r=rcaliman
[gecko.git] / netwerk / base / TCPFastOpenLayer.h
blob9b80ba339a1e0c43b7486eae09cc232fdf9db99c
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef TCPFastOpenLayer_h__
8 #define TCPFastOpenLayer_h__
10 #include "prerror.h"
12 namespace mozilla {
13 namespace net {
15 /**
16 * This layer must be placed just above PR-tcp socket, i.e. it must be under
17 * nss layer.
18 * At the beginning of TCPFastOpenLayer.cpp there is explanation what this
19 * layer do.
20 **/
22 typedef enum {
23 TFO_NOT_SET, // This is only as a control.
24 // A connection not using TFO will have the TFO state set upon
25 // connection creation (in nsHalfOpenSocket::SetupConn).
26 // A connection using TFO will have the TFO state set after
27 // the connection is established or canceled.
28 TFO_UNKNOWN, // This is before the primary socket is built, i.e. before
29 // TCPFastOpenFinish is called.
30 TFO_DISABLED, // tfo is disabled because of a tfo error on a previous
31 // connection to the host (i.e. !mEnt->mUseFastOpen).
32 // If TFO is not supported by the OS, it is disabled by
33 // the pref or too many consecutive errors occurred, this value
34 // is not reported. This is set before StartFastOpen is called.
35 TFO_DISABLED_CONNECT, // Connection is using CONNECT. This is set before
36 // StartFastOpen is called.
37 // The following 3 are set just after TCPFastOpenFinish.
38 TFO_NOT_TRIED, // For some reason TCPFastOpenLayer does not have any data to
39 // send with the syn packet. This should never happen.
40 TFO_TRIED, // TCP has sent a TFO cookie request.
41 TFO_DATA_SENT, // On Linux, TCP has send data as well. (On Linux we do not
42 // know whether data has been accepted).
43 // On Windows, TCP has send data or only a TFO cookie request
44 // and the data or TFO cookie has been accepted by the server.
45 // The following value is only used on windows and is set after
46 // PR_ConnectContinue. That is the point when we know if TFO data was been
47 // accepted.
48 TFO_DATA_COOKIE_NOT_ACCEPTED, // This is only on Windows. TFO data or TFO
49 // cookie request has not been accepted.
50 // The following 3 are set during socket error recover
51 // (nsSocketTransport::RecoverFromError).
52 TFO_FAILED_CONNECTION_REFUSED,
53 TFO_FAILED_NET_TIMEOUT,
54 TFO_FAILED_UNKNOW_ERROR,
55 // The following 4 are set when backup connection finishes before the primary
56 // connection.
57 TFO_FAILED_BACKUP_CONNECTION_TFO_NOT_TRIED,
58 TFO_FAILED_BACKUP_CONNECTION_TFO_TRIED,
59 TFO_FAILED_BACKUP_CONNECTION_TFO_DATA_SENT,
60 TFO_FAILED_BACKUP_CONNECTION_TFO_DATA_COOKIE_NOT_ACCEPTED,
61 // The following 4 are set when the recovery connection fails as well.
62 TFO_FAILED_CONNECTION_REFUSED_NO_TFO_FAILED_TOO,
63 TFO_FAILED_NET_TIMEOUT_NO_TFO_FAILED_TOO,
64 TFO_FAILED_UNKNOW_ERROR_NO_TFO_FAILED_TOO,
65 TFO_FAILED_BACKUP_CONNECTION_NO_TFO_FAILED_TOO,
66 TFO_BACKUP_CONN, // This is a backup conn, for a halfOpenSock that was used
67 // TFO.
68 TFO_INIT_FAILED, // nsHalfOpenSocket::SetupConn failed.
69 TFO_UNKNOWN_RESOLVING, // There is a high number of TFO_UNKNOWN state
70 // reported. Let's split them depending on the socket
71 // transport state: TFO_UNKNOWN_RESOLVING,
72 // TFO_UNKNOWN_RESOLVED, TFO_UNKNOWN_CONNECTING and
73 // TFO_UNKNOWN_CONNECTED..
74 TFO_UNKNOWN_RESOLVED,
75 TFO_UNKNOWN_CONNECTING,
76 TFO_UNKNOWN_CONNECTED,
77 TFO_FAILED,
78 TFO_HTTP // TFO is disabled for non-secure connections.
79 } TFOResult;
81 nsresult AttachTCPFastOpenIOLayer(PRFileDesc *fd);
83 // Get the result of TCP Fast Open.
84 void TCPFastOpenFinish(PRFileDesc *fd, PRErrorCode &err,
85 bool &fastOpenNotSupported, uint8_t &tfoStatus);
87 int32_t TCPFastOpenGetBufferSizeLeft(PRFileDesc *fd);
89 bool TCPFastOpenGetCurrentBufferSize(PRFileDesc *fd);
90 bool TCPFastOpenFlushBuffer(PRFileDesc *fd);
91 } // namespace net
92 } // namespace mozilla
94 #endif // TCPFastOpenLayer_h__