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

Side by Side Diff: Source/modules/serviceworkers/Body.h

Issue 786893004: [ServiceWorker] Use BodyStreamBuffer as the body data of the Response object. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | Source/modules/serviceworkers/Body.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptWrappable.h" 10 #include "bindings/core/v8/ScriptWrappable.h"
11 #include "core/dom/ActiveDOMObject.h" 11 #include "core/dom/ActiveDOMObject.h"
12 #include "core/fileapi/FileReaderLoader.h" 12 #include "core/fileapi/FileReaderLoader.h"
13 #include "core/fileapi/FileReaderLoaderClient.h" 13 #include "core/fileapi/FileReaderLoaderClient.h"
14 #include "core/streams/ReadableStreamImpl.h" 14 #include "core/streams/ReadableStreamImpl.h"
15 #include "platform/blob/BlobData.h" 15 #include "platform/blob/BlobData.h"
16 #include "platform/heap/Handle.h" 16 #include "platform/heap/Handle.h"
17 #include "wtf/RefPtr.h" 17 #include "wtf/RefPtr.h"
18 18
19 namespace blink { 19 namespace blink {
20 20
21 class BodyStreamBuffer;
21 class ScriptState; 22 class ScriptState;
22 23
23 class Body 24 class Body
24 : public GarbageCollectedFinalized<Body> 25 : public GarbageCollectedFinalized<Body>
25 , public ScriptWrappable 26 , public ScriptWrappable
26 , public ActiveDOMObject 27 , public ActiveDOMObject
27 , public FileReaderLoaderClient { 28 , public FileReaderLoaderClient {
28 DEFINE_WRAPPERTYPEINFO(); 29 DEFINE_WRAPPERTYPEINFO();
29 public: 30 public:
30 explicit Body(ExecutionContext*); 31 explicit Body(ExecutionContext*);
(...skipping 12 matching lines...) Expand all
43 ScriptPromise formData(ScriptState*); 44 ScriptPromise formData(ScriptState*);
44 ScriptPromise json(ScriptState*); 45 ScriptPromise json(ScriptState*);
45 ScriptPromise text(ScriptState*); 46 ScriptPromise text(ScriptState*);
46 ReadableStream* body(); 47 ReadableStream* body();
47 48
48 // Sets the bodyUsed flag to true. This signifies that the contents of the 49 // Sets the bodyUsed flag to true. This signifies that the contents of the
49 // body have been consumed and cannot be accessed again. 50 // body have been consumed and cannot be accessed again.
50 void setBodyUsed(); 51 void setBodyUsed();
51 bool bodyUsed() const; 52 bool bodyUsed() const;
52 53
54 bool streamAccessed() const;
55
53 // ActiveDOMObject override. 56 // ActiveDOMObject override.
54 virtual void stop() override; 57 virtual void stop() override;
55 virtual bool hasPendingActivity() const override; 58 virtual bool hasPendingActivity() const override;
56 59
57 virtual void trace(Visitor*); 60 virtual void trace(Visitor*);
58 61
59 protected: 62 protected:
60 // Copy constructor for clone() implementations 63 // Copy constructor for clone() implementations
61 explicit Body(const Body&); 64 explicit Body(const Body&);
62 65
63 private: 66 private:
64 class ReadableStreamSource; 67 class ReadableStreamSource;
68 class BlobHandleResolver;
69
65 void pullSource(); 70 void pullSource();
66 void readAllFromStream(ScriptState*); 71 void readAllFromStream(ScriptState*);
67 ScriptPromise readAsync(ScriptState*, ResponseType); 72 ScriptPromise readAsync(ScriptState*, ResponseType);
73 void readAsyncFromBlob(PassRefPtr<BlobDataHandle>);
68 void resolveJSON(const String&); 74 void resolveJSON(const String&);
69 75
70 // FileReaderLoaderClient functions. 76 // FileReaderLoaderClient functions.
71 virtual void didStartLoading() override; 77 virtual void didStartLoading() override;
72 virtual void didReceiveData() override; 78 virtual void didReceiveData() override;
73 virtual void didFinishLoading() override; 79 virtual void didFinishLoading() override;
74 virtual void didFail(FileError::ErrorCode) override; 80 virtual void didFail(FileError::ErrorCode) override;
75 81
76 virtual PassRefPtr<BlobDataHandle> blobDataHandle() = 0; 82 void didBlobHandleResolveError(PassRefPtrWillBeRawPtr<DOMException>);
83
84 virtual PassRefPtr<BlobDataHandle> blobDataHandle(bool /* internal */) const = 0;
yhirano 2014/12/11 03:55:47 What does internal mean?
horo 2014/12/11 05:43:08 I wanted to use this flag to access the internal r
85 virtual BodyStreamBuffer* buffer(bool /* internal */) const = 0;
yhirano 2014/12/11 03:55:47 ditto
77 86
78 void didFinishLoadingViaStream(DOMArrayBuffer*); 87 void didFinishLoadingViaStream(DOMArrayBuffer*);
79 88
80 OwnPtr<FileReaderLoader> m_loader; 89 OwnPtr<FileReaderLoader> m_loader;
81 bool m_bodyUsed; 90 bool m_bodyUsed;
82 bool m_streamAccessed; 91 bool m_streamAccessed;
83 ResponseType m_responseType; 92 ResponseType m_responseType;
84 RefPtr<ScriptPromiseResolver> m_resolver; 93 RefPtr<ScriptPromiseResolver> m_resolver;
85 Member<ReadableStreamSource> m_streamSource; 94 Member<ReadableStreamSource> m_streamSource;
86 Member<ReadableStreamImpl<ReadableStreamChunkTypeTraits<DOMArrayBuffer>>> m_ stream; 95 Member<ReadableStreamImpl<ReadableStreamChunkTypeTraits<DOMArrayBuffer>>> m_ stream;
87 }; 96 };
88 97
89 } // namespace blink 98 } // namespace blink
90 99
91 #endif // Body_h 100 #endif // Body_h
OLDNEW
« no previous file with comments | « no previous file | Source/modules/serviceworkers/Body.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698