/src/mozilla-central/netwerk/protocol/http/NullHttpTransaction.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | |
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/. */ |
6 | | |
7 | | #ifndef mozilla_net_NullHttpTransaction_h |
8 | | #define mozilla_net_NullHttpTransaction_h |
9 | | |
10 | | #include "nsAHttpTransaction.h" |
11 | | #include "mozilla/Attributes.h" |
12 | | #include "TimingStruct.h" |
13 | | |
14 | | // This is the minimal nsAHttpTransaction implementation. A NullHttpTransaction |
15 | | // can be used to drive connection level semantics (such as SSL handshakes |
16 | | // tunnels) so that a nsHttpConnection becomes fully established in |
17 | | // anticipation of a real transaction needing to use it soon. |
18 | | |
19 | | class nsIHttpActivityObserver; |
20 | | |
21 | | namespace mozilla { namespace net { |
22 | | |
23 | | class nsAHttpConnection; |
24 | | class nsHttpConnectionInfo; |
25 | | class nsHttpRequestHead; |
26 | | |
27 | | // 6c445340-3b82-4345-8efa-4902c3b8805a |
28 | | #define NS_NULLHTTPTRANSACTION_IID \ |
29 | | { 0x6c445340, 0x3b82, 0x4345, {0x8e, 0xfa, 0x49, 0x02, 0xc3, 0xb8, 0x80, 0x5a }} |
30 | | |
31 | | class NullHttpTransaction : public nsAHttpTransaction |
32 | | { |
33 | | public: |
34 | | NS_DECLARE_STATIC_IID_ACCESSOR(NS_NULLHTTPTRANSACTION_IID) |
35 | | NS_DECL_THREADSAFE_ISUPPORTS |
36 | | NS_DECL_NSAHTTPTRANSACTION |
37 | | |
38 | | NullHttpTransaction(nsHttpConnectionInfo *ci, |
39 | | nsIInterfaceRequestor *callbacks, |
40 | | uint32_t caps); |
41 | | |
42 | | MOZ_MUST_USE bool Claim(); |
43 | | void Unclaim(); |
44 | | |
45 | | // Overload of nsAHttpTransaction methods |
46 | 0 | bool IsNullTransaction() final { return true; } |
47 | 0 | NullHttpTransaction *QueryNullTransaction() final { return this; } |
48 | 0 | bool ResponseTimeoutEnabled() const final {return true; } |
49 | | PRIntervalTime ResponseTimeout() final |
50 | 0 | { |
51 | 0 | return PR_SecondsToInterval(15); |
52 | 0 | } |
53 | | |
54 | | // We have to override this function because |mTransaction| in nsHalfOpenSocket |
55 | | // could be either nsHttpTransaction or NullHttpTransaction. |
56 | | // NullHttpTransaction will be activated on the connection immediately after |
57 | | // creation and be never put in a pending queue, so it's OK to just return 0. |
58 | 0 | uint64_t TopLevelOuterContentWindowId() override { return 0; } |
59 | | |
60 | 0 | TimingStruct Timings() { return mTimings; } |
61 | | |
62 | 0 | mozilla::TimeStamp GetTcpConnectEnd() { return mTimings.tcpConnectEnd; } |
63 | | mozilla::TimeStamp GetSecureConnectionStart() |
64 | 0 | { |
65 | 0 | return mTimings.secureConnectionStart; |
66 | 0 | } |
67 | | |
68 | | void SetFastOpenStatus(uint8_t aStatus) override |
69 | 0 | { |
70 | 0 | mFastOpenStatus = aStatus; |
71 | 0 | } |
72 | | |
73 | | protected: |
74 | | virtual ~NullHttpTransaction(); |
75 | | |
76 | | private: |
77 | | nsresult mStatus; |
78 | | protected: |
79 | | uint32_t mCaps; |
80 | | nsHttpRequestHead *mRequestHead; |
81 | | private: |
82 | | // mCapsToClear holds flags that should be cleared in mCaps, e.g. unset |
83 | | // NS_HTTP_REFRESH_DNS when DNS refresh request has completed to avoid |
84 | | // redundant requests on the network. The member itself is atomic, but |
85 | | // access to it from the networking thread may happen either before or |
86 | | // after the main thread modifies it. To deal with raciness, only unsetting |
87 | | // bitfields should be allowed: 'lost races' will thus err on the |
88 | | // conservative side, e.g. by going ahead with a 2nd DNS refresh. |
89 | | Atomic<uint32_t> mCapsToClear; |
90 | | bool mIsDone; |
91 | | bool mClaimed; |
92 | | TimingStruct mTimings; |
93 | | uint8_t mFastOpenStatus; |
94 | | |
95 | | protected: |
96 | | RefPtr<nsAHttpConnection> mConnection; |
97 | | nsCOMPtr<nsIInterfaceRequestor> mCallbacks; |
98 | | RefPtr<nsHttpConnectionInfo> mConnectionInfo; |
99 | | nsCOMPtr<nsIHttpActivityObserver> mActivityDistributor; |
100 | | }; |
101 | | |
102 | | NS_DEFINE_STATIC_IID_ACCESSOR(NullHttpTransaction, NS_NULLHTTPTRANSACTION_IID) |
103 | | |
104 | | } // namespace net |
105 | | } // namespace mozilla |
106 | | |
107 | | #endif // mozilla_net_NullHttpTransaction_h |