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

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

Issue 555443002: [Fetch API] Put body members directly on Response/Request (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: incorporated yhirano's comment Created 6 years, 3 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
(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 FetchBodyStream_h
6 #define FetchBodyStream_h
7
8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptWrappable.h"
11 #include "core/dom/ActiveDOMObject.h"
12 #include "core/fileapi/FileReaderLoader.h"
13 #include "core/fileapi/FileReaderLoaderClient.h"
14 #include "platform/blob/BlobData.h"
15 #include "platform/heap/Handle.h"
16 #include "wtf/RefPtr.h"
17
18 namespace blink {
19
20 class ScriptState;
21
22 class FetchBodyStream FINAL
23 : public GarbageCollectedFinalized<FetchBodyStream>
24 , public ScriptWrappable
25 , public ActiveDOMObject
26 , public FileReaderLoaderClient {
27 DEFINE_WRAPPERTYPEINFO();
28 public:
29 enum ResponseType {
30 ResponseAsArrayBuffer,
31 ResponseAsBlob,
32 ResponseAsFormData,
33 ResponseAsJSON,
34 ResponseAsText
35 };
36
37 static FetchBodyStream* create(ExecutionContext*, PassRefPtr<BlobDataHandle> );
38
39 ScriptPromise asArrayBuffer(ScriptState*);
40 ScriptPromise asBlob(ScriptState*);
41 ScriptPromise asFormData(ScriptState*);
42 ScriptPromise asJSON(ScriptState*);
43 ScriptPromise asText(ScriptState*);
44
45 // ActiveDOMObject override.
46 virtual void stop() OVERRIDE;
47 virtual bool hasPendingActivity() const OVERRIDE;
48
49 void trace(Visitor*) { }
50
51 private:
52 FetchBodyStream(ExecutionContext*, PassRefPtr<BlobDataHandle>);
53 ScriptPromise readAsync(ScriptState*, ResponseType);
54 void resolveJSON();
55
56 // FileReaderLoaderClient functions.
57 virtual void didStartLoading() OVERRIDE;
58 virtual void didReceiveData() OVERRIDE;
59 virtual void didFinishLoading() OVERRIDE;
60 virtual void didFail(FileError::ErrorCode) OVERRIDE;
61
62 RefPtr<BlobDataHandle> m_blobDataHandle;
63 OwnPtr<FileReaderLoader> m_loader;
64 bool m_hasRead;
65 ResponseType m_responseType;
66 RefPtr<ScriptPromiseResolver> m_resolver;
67 };
68
69 } // namespace blink
70
71 #endif // FetchBodyStream_h
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/Body.idl ('k') | Source/modules/serviceworkers/FetchBodyStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698