1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef mozilla_net_NullHttpChannel_h
6 #define mozilla_net_NullHttpChannel_h
7 
8 #include "nsINullChannel.h"
9 #include "nsIHttpChannel.h"
10 #include "nsITimedChannel.h"
11 #include "nsIURI.h"
12 #include "nsCOMPtr.h"
13 #include "mozilla/TimeStamp.h"
14 #include "nsString.h"
15 #include "prtime.h"
16 
17 namespace mozilla {
18 namespace net {
19 
20 class nsProxyInfo;
21 
22 class NullHttpChannel final : public nsINullChannel,
23                               public nsIHttpChannel,
24                               public nsITimedChannel {
25   NS_DECL_THREADSAFE_ISUPPORTS
26   NS_DECL_NSINULLCHANNEL
27   NS_DECL_NSIHTTPCHANNEL
28   NS_DECL_NSITIMEDCHANNEL
29   NS_DECL_NSIREQUEST
30   NS_DECL_NSICHANNEL
31 
32   NullHttpChannel();
33 
34   // Copies the URI, Principal and Timing-Allow-Origin headers from the
35   // passed channel to this object, to be used for resource timing checks
36   explicit NullHttpChannel(nsIHttpChannel *chan);
37 
38   // Same signature as nsHttpChannel::Init
39   MOZ_MUST_USE nsresult Init(nsIURI *aURI, uint32_t aCaps,
40                              nsProxyInfo *aProxyInfo,
41                              uint32_t aProxyResolveFlags, nsIURI *aProxyURI);
42 
43  private:
~NullHttpChannel()44   ~NullHttpChannel() {}
45 
46  protected:
47   nsCOMPtr<nsIURI> mURI;
48   nsCOMPtr<nsIURI> mOriginalURI;
49 
50   nsString mInitiatorType;
51   PRTime mChannelCreationTime;
52   TimeStamp mAsyncOpenTime;
53   TimeStamp mChannelCreationTimestamp;
54   nsCOMPtr<nsIPrincipal> mResourcePrincipal;
55   nsCString mTimingAllowOriginHeader;
56   bool mAllRedirectsSameOrigin;
57   bool mAllRedirectsPassTimingAllowCheck;
58 };
59 
60 }  // namespace net
61 }  // namespace mozilla
62 
63 #endif  // mozilla_net_NullHttpChannel_h
64