Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: third_party/WebKit/Source/modules/fetch/Body.h

Issue 1805843002: [v8 gc] Introduce a base class for all objects that can have pending activity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 Body_h 5 #ifndef Body_h
6 #define Body_h 6 #define Body_h
7 7
8 #include "bindings/core/v8/ActiveScriptWrappable.h"
8 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptWrappable.h" 10 #include "bindings/core/v8/ScriptWrappable.h"
10 #include "core/dom/ActiveDOMObject.h" 11 #include "core/dom/ActiveDOMObject.h"
11 #include "modules/ModulesExport.h" 12 #include "modules/ModulesExport.h"
12 #include "platform/heap/Handle.h" 13 #include "platform/heap/Handle.h"
13 #include "wtf/text/WTFString.h" 14 #include "wtf/text/WTFString.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 class BodyStreamBuffer; 18 class BodyStreamBuffer;
18 class ExecutionContext; 19 class ExecutionContext;
19 class ReadableByteStream; 20 class ReadableByteStream;
20 class ScriptState; 21 class ScriptState;
21 22
22 // This class represents Body mix-in defined in the fetch spec 23 // This class represents Body mix-in defined in the fetch spec
23 // https://fetch.spec.whatwg.org/#body-mixin. 24 // https://fetch.spec.whatwg.org/#body-mixin.
24 // 25 //
25 // Note: This class has body stream and its predicate whereas in the current 26 // Note: This class has body stream and its predicate whereas in the current
26 // spec only Response has it and Request has a byte stream defined in the 27 // spec only Response has it and Request has a byte stream defined in the
27 // Encoding spec. The spec should be fixed shortly to be aligned with this 28 // Encoding spec. The spec should be fixed shortly to be aligned with this
28 // implementation. 29 // implementation.
29 class MODULES_EXPORT Body 30 class MODULES_EXPORT Body
30 : public GarbageCollectedFinalized<Body> 31 : public GarbageCollectedFinalized<Body>
31 , public ScriptWrappable 32 , public ScriptWrappable
33 , public ActiveScriptWrappable
32 , public ActiveDOMObject { 34 , public ActiveDOMObject {
33 WTF_MAKE_NONCOPYABLE(Body); 35 WTF_MAKE_NONCOPYABLE(Body);
34 DEFINE_WRAPPERTYPEINFO(); 36 DEFINE_WRAPPERTYPEINFO();
35 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Body); 37 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Body);
36 public: 38 public:
37 explicit Body(ExecutionContext*); 39 explicit Body(ExecutionContext*);
38 ~Body() override { } 40 ~Body() override { }
39 41
40 ScriptPromise arrayBuffer(ScriptState*); 42 ScriptPromise arrayBuffer(ScriptState*);
41 ScriptPromise blob(ScriptState*); 43 ScriptPromise blob(ScriptState*);
42 ScriptPromise formData(ScriptState*); 44 ScriptPromise formData(ScriptState*);
43 ScriptPromise json(ScriptState*); 45 ScriptPromise json(ScriptState*);
44 ScriptPromise text(ScriptState*); 46 ScriptPromise text(ScriptState*);
45 ReadableByteStream* bodyWithUseCounter(); 47 ReadableByteStream* bodyWithUseCounter();
46 virtual BodyStreamBuffer* bodyBuffer() = 0; 48 virtual BodyStreamBuffer* bodyBuffer() = 0;
47 virtual const BodyStreamBuffer* bodyBuffer() const = 0; 49 virtual const BodyStreamBuffer* bodyBuffer() const = 0;
48 50
49 virtual bool bodyUsed(); 51 virtual bool bodyUsed();
50 bool isBodyLocked(); 52 bool isBodyLocked();
51 53
52 // ActiveDOMObject override. 54 // ActiveScriptWrappable override.
53 bool hasPendingActivity() const override; 55 bool hasPendingActivity() const override;
54 56
55 DEFINE_INLINE_VIRTUAL_TRACE() 57 DEFINE_INLINE_VIRTUAL_TRACE()
56 { 58 {
57 ActiveDOMObject::trace(visitor); 59 ActiveDOMObject::trace(visitor);
58 } 60 }
59 61
60 // https://w3c.github.io/webappsec-credential-management/#monkey-patching-fe tch-2 62 // https://w3c.github.io/webappsec-credential-management/#monkey-patching-fe tch-2
61 void setOpaque() { m_opaque = true; } 63 void setOpaque() { m_opaque = true; }
62 bool opaque() const { return m_opaque; } 64 bool opaque() const { return m_opaque; }
63 65
64 private: 66 private:
65 ReadableByteStream* body(); 67 ReadableByteStream* body();
66 virtual String mimeType() const = 0; 68 virtual String mimeType() const = 0;
67 69
68 // Body consumption algorithms will reject with a TypeError in a number of 70 // Body consumption algorithms will reject with a TypeError in a number of
69 // error conditions. This method wraps those up into one call which returns 71 // error conditions. This method wraps those up into one call which returns
70 // an empty ScriptPromise if the consumption may proceed, and a 72 // an empty ScriptPromise if the consumption may proceed, and a
71 // ScriptPromise rejected with a TypeError if it ought to be blocked. 73 // ScriptPromise rejected with a TypeError if it ought to be blocked.
72 ScriptPromise rejectInvalidConsumption(ScriptState*); 74 ScriptPromise rejectInvalidConsumption(ScriptState*);
73 75
74 bool m_opaque; 76 bool m_opaque;
75 }; 77 };
76 78
77 } // namespace blink 79 } // namespace blink
78 80
79 #endif // Body_h 81 #endif // Body_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698