Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/Request.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
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_dom_Request_h
8
#define mozilla_dom_Request_h
9
10
#include "nsIContentPolicy.h"
11
#include "nsISupportsImpl.h"
12
#include "nsWrapperCache.h"
13
14
#include "mozilla/dom/Fetch.h"
15
#include "mozilla/dom/InternalRequest.h"
16
// Required here due to certain WebIDL enums/classes being declared in both
17
// files.
18
#include "mozilla/dom/RequestBinding.h"
19
20
namespace mozilla {
21
namespace dom {
22
23
class Headers;
24
class InternalHeaders;
25
class RequestOrUSVString;
26
27
class Request final : public nsISupports
28
                    , public FetchBody<Request>
29
                    , public nsWrapperCache
30
{
31
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
32
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Request)
33
34
public:
35
  Request(nsIGlobalObject* aOwner, InternalRequest* aRequest,
36
          AbortSignal* aSignal);
37
38
  JSObject*
39
  WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
40
0
  {
41
0
    return Request_Binding::Wrap(aCx, this, aGivenProto);
42
0
  }
43
44
  void
45
  GetUrl(nsAString& aUrl) const
46
0
  {
47
0
    nsAutoCString url;
48
0
    mRequest->GetURL(url);
49
0
    CopyUTF8toUTF16(url, aUrl);
50
0
  }
51
52
  void
53
  GetMethod(nsCString& aMethod) const
54
0
  {
55
0
    aMethod = mRequest->mMethod;
56
0
  }
57
58
  RequestMode
59
  Mode() const
60
0
  {
61
0
    return mRequest->mMode;
62
0
  }
63
64
  RequestCredentials
65
  Credentials() const
66
0
  {
67
0
    return mRequest->mCredentialsMode;
68
0
  }
69
70
  RequestCache
71
  Cache() const
72
0
  {
73
0
    return mRequest->GetCacheMode();
74
0
  }
75
76
  RequestRedirect
77
  Redirect() const
78
0
  {
79
0
    return mRequest->GetRedirectMode();
80
0
  }
81
82
  void
83
  GetIntegrity(nsAString& aIntegrity) const
84
0
  {
85
0
    aIntegrity = mRequest->GetIntegrity();
86
0
  }
87
88
  bool
89
  MozErrors() const
90
0
  {
91
0
    return mRequest->MozErrors();
92
0
  }
93
94
  RequestDestination
95
  Destination() const
96
0
  {
97
0
    return mRequest->Destination();
98
0
  }
99
100
  void
101
  OverrideContentPolicyType(nsContentPolicyType aContentPolicyType)
102
0
  {
103
0
    mRequest->OverrideContentPolicyType(aContentPolicyType);
104
0
  }
105
106
  bool
107
  IsContentPolicyTypeOverridden() const
108
0
  {
109
0
    return mRequest->IsContentPolicyTypeOverridden();
110
0
  }
111
112
  void
113
  GetReferrer(nsAString& aReferrer) const
114
0
  {
115
0
    mRequest->GetReferrer(aReferrer);
116
0
  }
117
118
  ReferrerPolicy
119
  ReferrerPolicy_() const
120
0
  {
121
0
    return mRequest->ReferrerPolicy_();
122
0
  }
123
124
  InternalHeaders*
125
  GetInternalHeaders() const
126
  {
127
    return mRequest->Headers();
128
  }
129
130
  Headers* Headers_();
131
132
  using FetchBody::GetBody;
133
134
  void
135
  GetBody(nsIInputStream** aStream, int64_t* aBodyLength = nullptr)
136
0
  {
137
0
    mRequest->GetBody(aStream, aBodyLength);
138
0
  }
139
140
  void
141
  SetBody(nsIInputStream* aStream, int64_t aBodyLength)
142
  {
143
    mRequest->SetBody(aStream, aBodyLength);
144
  }
145
146
  using FetchBody::BodyLocalPath;
147
148
  const nsAString&
149
  BodyLocalPath() const
150
  {
151
    return mRequest->BodyLocalPath();
152
  }
153
154
  static already_AddRefed<Request>
155
  Constructor(const GlobalObject& aGlobal, const RequestOrUSVString& aInput,
156
              const RequestInit& aInit, ErrorResult& rv);
157
158
  nsIGlobalObject* GetParentObject() const
159
0
  {
160
0
    return mOwner;
161
0
  }
162
163
  already_AddRefed<Request>
164
  Clone(ErrorResult& aRv);
165
166
  already_AddRefed<InternalRequest>
167
  GetInternalRequest();
168
169
  const UniquePtr<mozilla::ipc::PrincipalInfo>&
170
  GetPrincipalInfo() const
171
  {
172
    return mRequest->GetPrincipalInfo();
173
  }
174
175
  AbortSignal*
176
  GetOrCreateSignal();
177
178
  // This can return a null AbortSignalImpl.
179
  AbortSignalImpl*
180
  GetSignalImpl() const override;
181
182
private:
183
  ~Request();
184
185
  RefPtr<InternalRequest> mRequest;
186
187
  // Lazily created.
188
  RefPtr<Headers> mHeaders;
189
  RefPtr<AbortSignal> mSignal;
190
};
191
192
} // namespace dom
193
} // namespace mozilla
194
195
#endif // mozilla_dom_Request_h