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