|
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 |
|
13 // This is the minimal nsAHttpTransaction implementation. A NullHttpTransaction |
|
14 // can be used to drive connection level semantics (such as SSL handshakes |
|
15 // tunnels) so that a nsHttpConnection becomes fully established in |
|
16 // anticipation of a real transaction needing to use it soon. |
|
17 |
|
18 namespace mozilla { namespace net { |
|
19 |
|
20 class nsAHttpConnection; |
|
21 class nsHttpConnectionInfo; |
|
22 class nsHttpRequestHead; |
|
23 |
|
24 class NullHttpTransaction MOZ_FINAL : public nsAHttpTransaction |
|
25 { |
|
26 public: |
|
27 NS_DECL_THREADSAFE_ISUPPORTS |
|
28 NS_DECL_NSAHTTPTRANSACTION |
|
29 |
|
30 NullHttpTransaction(nsHttpConnectionInfo *ci, |
|
31 nsIInterfaceRequestor *callbacks, |
|
32 uint32_t caps); |
|
33 ~NullHttpTransaction(); |
|
34 |
|
35 nsHttpConnectionInfo *ConnectionInfo() { return mConnectionInfo; } |
|
36 |
|
37 // Overload of nsAHttpTransaction methods |
|
38 bool IsNullTransaction() MOZ_OVERRIDE MOZ_FINAL { return true; } |
|
39 bool ResponseTimeoutEnabled() const MOZ_OVERRIDE MOZ_FINAL {return true; } |
|
40 PRIntervalTime ResponseTimeout() MOZ_OVERRIDE MOZ_FINAL |
|
41 { |
|
42 return PR_SecondsToInterval(15); |
|
43 } |
|
44 |
|
45 private: |
|
46 |
|
47 nsresult mStatus; |
|
48 uint32_t mCaps; |
|
49 // mCapsToClear holds flags that should be cleared in mCaps, e.g. unset |
|
50 // NS_HTTP_REFRESH_DNS when DNS refresh request has completed to avoid |
|
51 // redundant requests on the network. To deal with raciness, only unsetting |
|
52 // bitfields should be allowed: 'lost races' will thus err on the |
|
53 // conservative side, e.g. by going ahead with a 2nd DNS refresh. |
|
54 uint32_t mCapsToClear; |
|
55 nsRefPtr<nsAHttpConnection> mConnection; |
|
56 nsCOMPtr<nsIInterfaceRequestor> mCallbacks; |
|
57 nsRefPtr<nsHttpConnectionInfo> mConnectionInfo; |
|
58 nsHttpRequestHead *mRequestHead; |
|
59 bool mIsDone; |
|
60 }; |
|
61 |
|
62 }} // namespace mozilla::net |
|
63 |
|
64 #endif // mozilla_net_NullHttpTransaction_h |