OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef Request_h | |
6 #define Request_h | |
7 | |
8 #include "bindings/core/v8/Dictionary.h" | |
9 #include "bindings/core/v8/ScriptWrappable.h" | |
10 #include "bindings/modules/v8/UnionTypesModules.h" | |
11 #include "modules/serviceworkers/Body.h" | |
12 #include "modules/serviceworkers/FetchRequestData.h" | |
13 #include "modules/serviceworkers/Headers.h" | |
14 #include "platform/heap/Handle.h" | |
15 #include "platform/weborigin/KURL.h" | |
16 #include "public/platform/WebURLRequest.h" | |
17 #include "wtf/RefPtr.h" | |
18 #include "wtf/text/WTFString.h" | |
19 | |
20 namespace blink { | |
21 | |
22 class BodyStreamBuffer; | |
23 class RequestInit; | |
24 class WebServiceWorkerRequest; | |
25 | |
26 typedef RequestOrUSVString RequestInfo; | |
27 | |
28 class Request final : public Body { | |
29 DEFINE_WRAPPERTYPEINFO(); | |
30 public: | |
31 ~Request() override { } | |
32 | |
33 // From Request.idl: | |
34 static Request* create(ExecutionContext*, const RequestInfo&, const Dictiona
ry&, ExceptionState&); | |
35 | |
36 static Request* create(ExecutionContext*, const String&, ExceptionState&); | |
37 static Request* create(ExecutionContext*, const String&, const Dictionary&,
ExceptionState&); | |
38 static Request* create(ExecutionContext*, Request*, ExceptionState&); | |
39 static Request* create(ExecutionContext*, Request*, const Dictionary&, Excep
tionState&); | |
40 static Request* create(ExecutionContext*, FetchRequestData*); | |
41 static Request* create(ExecutionContext*, const WebServiceWorkerRequest&); | |
42 // The 'FetchRequestData' object is shared between requests, as it is | |
43 // immutable to the user after Request creation. Headers are copied. | |
44 static Request* create(const Request&); | |
45 | |
46 const FetchRequestData* request() { return m_request; } | |
47 | |
48 // From Request.idl: | |
49 String method() const; | |
50 String url() const; | |
51 Headers* headers() const { return m_headers; } | |
52 String referrer() const; | |
53 String mode() const; | |
54 String credentials() const; | |
55 | |
56 // From Request.idl: | |
57 Request* clone(ExceptionState&) const; | |
58 | |
59 void populateWebServiceWorkerRequest(WebServiceWorkerRequest&) const; | |
60 | |
61 void setBodyBlobHandle(PassRefPtr<BlobDataHandle>); | |
62 bool hasBody() const { return m_request->blobDataHandle(); } | |
63 | |
64 void trace(Visitor*) override; | |
65 | |
66 private: | |
67 explicit Request(const Request&); | |
68 Request(ExecutionContext*, FetchRequestData*); | |
69 Request(ExecutionContext*, const WebServiceWorkerRequest&); | |
70 | |
71 static Request* createRequestWithRequestOrString(ExecutionContext*, Request*
, const String&, const RequestInit&, ExceptionState&); | |
72 void clearHeaderList(); | |
73 | |
74 PassRefPtr<BlobDataHandle> blobDataHandle() const override; | |
75 BodyStreamBuffer* buffer() const override; | |
76 String contentTypeForBuffer() const override; | |
77 | |
78 const Member<FetchRequestData> m_request; | |
79 const Member<Headers> m_headers; | |
80 }; | |
81 | |
82 } // namespace blink | |
83 | |
84 #endif // Request_h | |
OLD | NEW |