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

Unified Diff: Source/modules/serviceworkers/Body.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/modules.gypi ('k') | Source/modules/serviceworkers/Body.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/Body.h
diff --git a/Source/modules/serviceworkers/FetchBodyStream.h b/Source/modules/serviceworkers/Body.h
similarity index 70%
rename from Source/modules/serviceworkers/FetchBodyStream.h
rename to Source/modules/serviceworkers/Body.h
index 37afa229a21ddd67aa464b14397e4ab269294259..99072c95adf9ae6f24953bfd9bc6b91dfb492bb4 100644
--- a/Source/modules/serviceworkers/FetchBodyStream.h
+++ b/Source/modules/serviceworkers/Body.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef FetchBodyStream_h
-#define FetchBodyStream_h
+#ifndef Body_h
+#define Body_h
#include "bindings/core/v8/ScriptPromise.h"
#include "bindings/core/v8/ScriptPromiseResolver.h"
@@ -19,13 +19,15 @@ namespace blink {
class ScriptState;
-class FetchBodyStream FINAL
- : public GarbageCollectedFinalized<FetchBodyStream>
+class Body
+ : public GarbageCollectedFinalized<Body>
, public ScriptWrappable
, public ActiveDOMObject
, public FileReaderLoaderClient {
DEFINE_WRAPPERTYPEINFO();
public:
+ explicit Body(ExecutionContext*);
+ virtual ~Body() { }
enum ResponseType {
ResponseAsArrayBuffer,
ResponseAsBlob,
@@ -34,22 +36,21 @@ public:
ResponseAsText
};
- static FetchBodyStream* create(ExecutionContext*, PassRefPtr<BlobDataHandle>);
+ ScriptPromise arrayBuffer(ScriptState*);
+ ScriptPromise blob(ScriptState*);
+ ScriptPromise formData(ScriptState*);
+ ScriptPromise json(ScriptState*);
+ ScriptPromise text(ScriptState*);
- ScriptPromise asArrayBuffer(ScriptState*);
- ScriptPromise asBlob(ScriptState*);
- ScriptPromise asFormData(ScriptState*);
- ScriptPromise asJSON(ScriptState*);
- ScriptPromise asText(ScriptState*);
+ bool bodyUsed() const;
// ActiveDOMObject override.
virtual void stop() OVERRIDE;
virtual bool hasPendingActivity() const OVERRIDE;
- void trace(Visitor*) { }
+ virtual void trace(Visitor*) { }
private:
- FetchBodyStream(ExecutionContext*, PassRefPtr<BlobDataHandle>);
ScriptPromise readAsync(ScriptState*, ResponseType);
void resolveJSON();
@@ -59,13 +60,14 @@ private:
virtual void didFinishLoading() OVERRIDE;
virtual void didFail(FileError::ErrorCode) OVERRIDE;
- RefPtr<BlobDataHandle> m_blobDataHandle;
+ virtual PassRefPtr<BlobDataHandle> blobDataHandle() = 0;
+
OwnPtr<FileReaderLoader> m_loader;
- bool m_hasRead;
+ bool m_bodyUsed;
ResponseType m_responseType;
RefPtr<ScriptPromiseResolver> m_resolver;
};
} // namespace blink
-#endif // FetchBodyStream_h
+#endif // Body_h
« no previous file with comments | « Source/modules/modules.gypi ('k') | Source/modules/serviceworkers/Body.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698