Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef TCPFASTOPEN_H__
7 : #define TCPFASTOPEN_H__
8 :
9 : /**
10 : * This is an abstract class for TCP Fast Open - TFO (RFC7413).
11 : * It is not always safe to use Fast Open. It can be use for requests that
12 : * are replayable.
13 : * Middle boxes can block or reset connections that use TFO, therefore a
14 : * backup connection will be prepared with a delay.
15 : * In case of blocking such a connection tcp socket will terminate only after
16 : * a timeout, therefore a backup connection is needed. If connection is refuse
17 : * the same socketTransport will retry.
18 : *
19 : * This is implemented by nsHalfopenSocket.
20 : **/
21 :
22 : namespace mozilla {
23 : namespace net {
24 :
25 3 : class TCPFastOpen
26 : {
27 : public:
28 :
29 : // Check if we have a transaction that is safe to be used with TFO.
30 : // Connections over TLS are always safe and some http requests (e.g. GET).
31 : virtual bool FastOpenEnabled() = 0;
32 : // To use TFO we need to have a transaction prepared, e.g. also have
33 : // nsHttpConnection ready. This functions is call by nsSocketTransport to
34 : // setup a connection.
35 : virtual nsresult StartFastOpen() = 0;
36 : // Inform nsHalfopenSocket whether a connection using TFO succeeded or not.
37 : // This will cancel the backup connection and in case of a failure rewind
38 : // the transaction.
39 : virtual void SetFastOpenConnected(nsresult error, bool aWillRetry) = 0;
40 : virtual void FastOpenNotSupported() = 0;
41 : virtual void SetFastOpenStatus(uint8_t tfoStatus) = 0;
42 : };
43 :
44 : }
45 : }
46 :
47 : #endif //TCPFASTOPEN_H__
|