Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/netwerk/protocol/viewsource/nsViewSourceChannel.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 nsViewSourceChannel_h___
7
#define nsViewSourceChannel_h___
8
9
#include "nsString.h"
10
#include "nsCOMPtr.h"
11
#include "nsIViewSourceChannel.h"
12
#include "nsIURI.h"
13
#include "nsIStreamListener.h"
14
#include "nsIHttpChannel.h"
15
#include "nsIHttpChannelInternal.h"
16
#include "nsICachingChannel.h"
17
#include "nsIApplicationCacheChannel.h"
18
#include "nsIFormPOSTActionChannel.h"
19
#include "mozilla/Attributes.h"
20
21
class nsViewSourceChannel final : public nsIViewSourceChannel,
22
                                  public nsIStreamListener,
23
                                  public nsIHttpChannel,
24
                                  public nsIHttpChannelInternal,
25
                                  public nsICachingChannel,
26
                                  public nsIApplicationCacheChannel,
27
                                  public nsIFormPOSTActionChannel
28
{
29
30
public:
31
    NS_DECL_ISUPPORTS
32
    NS_DECL_NSIREQUEST
33
    NS_DECL_NSICHANNEL
34
    NS_DECL_NSIVIEWSOURCECHANNEL
35
    NS_DECL_NSISTREAMLISTENER
36
    NS_DECL_NSIREQUESTOBSERVER
37
    NS_DECL_NSIHTTPCHANNEL
38
    NS_FORWARD_SAFE_NSICACHEINFOCHANNEL(mCacheInfoChannel)
39
    NS_FORWARD_SAFE_NSICACHINGCHANNEL(mCachingChannel)
40
    NS_FORWARD_SAFE_NSIAPPLICATIONCACHECHANNEL(mApplicationCacheChannel)
41
    NS_FORWARD_SAFE_NSIAPPLICATIONCACHECONTAINER(mApplicationCacheChannel)
42
    NS_FORWARD_SAFE_NSIUPLOADCHANNEL(mUploadChannel)
43
    NS_FORWARD_SAFE_NSIFORMPOSTACTIONCHANNEL(mPostChannel)
44
    NS_FORWARD_SAFE_NSIHTTPCHANNELINTERNAL(mHttpChannelInternal)
45
46
    // nsViewSourceChannel methods:
47
    nsViewSourceChannel()
48
        : mIsDocument(false)
49
        , mOpened(false)
50
0
        , mIsSrcdocChannel(false) {}
51
52
    MOZ_MUST_USE nsresult Init(nsIURI* uri);
53
54
    MOZ_MUST_USE nsresult InitSrcdoc(nsIURI* aURI,
55
                                     nsIURI* aBaseURI,
56
                                     const nsAString &aSrcdoc,
57
                                     nsILoadInfo* aLoadInfo);
58
59
    // Updates or sets the result principal URI of the underlying channel's
60
    // loadinfo to be prefixed with the "view-source:" schema as:
61
    //
62
    // mChannel.loadInfo.resultPrincipalURI = "view-source:" +
63
    //    (mChannel.loadInfo.resultPrincipalURI | mChannel.orignalURI);
64
    nsresult UpdateLoadInfoResultPrincipalURI();
65
66
protected:
67
0
    ~nsViewSourceChannel() = default;
68
69
    // Clones aURI and prefixes it with "view-source:" schema,
70
    nsresult BuildViewSourceURI(nsIURI* aURI, nsIURI** aResult);
71
72
    nsCOMPtr<nsIChannel>        mChannel;
73
    nsCOMPtr<nsIHttpChannel>    mHttpChannel;
74
    nsCOMPtr<nsIHttpChannelInternal>    mHttpChannelInternal;
75
    nsCOMPtr<nsICachingChannel> mCachingChannel;
76
    nsCOMPtr<nsICacheInfoChannel> mCacheInfoChannel;
77
    nsCOMPtr<nsIApplicationCacheChannel> mApplicationCacheChannel;
78
    nsCOMPtr<nsIUploadChannel>  mUploadChannel;
79
    nsCOMPtr<nsIFormPOSTActionChannel> mPostChannel;
80
    nsCOMPtr<nsIStreamListener> mListener;
81
    nsCOMPtr<nsIURI>            mOriginalURI;
82
    nsCOMPtr<nsIURI>            mBaseURI;
83
    nsCString                   mContentType;
84
    bool                        mIsDocument; // keeps track of the LOAD_DOCUMENT_URI flag
85
    bool                        mOpened;
86
    bool                        mIsSrcdocChannel;
87
};
88
89
#endif /* nsViewSourceChannel_h___ */