Chromium Code Reviews| 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..a13754028e2b96e28fb7e515a6173b52853fff26 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,14 @@ namespace blink { |
| class ScriptState; |
| -class FetchBodyStream FINAL |
| - : public GarbageCollectedFinalized<FetchBodyStream> |
| +class Body |
| + : public GarbageCollectedFinalized<Body> |
| , public ScriptWrappable |
| , public ActiveDOMObject |
| , public FileReaderLoaderClient { |
| DEFINE_WRAPPERTYPEINFO(); |
| public: |
| + virtual ~Body() { } |
| enum ResponseType { |
| ResponseAsArrayBuffer, |
| ResponseAsBlob, |
| @@ -34,22 +35,24 @@ 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(); |
|
yhirano
2014/09/09 09:31:49
+const
horo
2014/09/10 06:18:44
Done.
|
| // ActiveDOMObject override. |
| virtual void stop() OVERRIDE; |
| virtual bool hasPendingActivity() const OVERRIDE; |
| - void trace(Visitor*) { } |
| + virtual void trace(Visitor*) { } |
| + |
| +protected: |
| + Body(ExecutionContext*); |
|
yhirano
2014/09/09 09:31:49
You don't have to hide the constructor because we
jsbell
2014/09/09 22:04:25
single arg constructor should have 'explicit' qual
horo
2014/09/10 06:18:44
Done.
horo
2014/09/10 06:18:44
Done.
|
| private: |
| - FetchBodyStream(ExecutionContext*, PassRefPtr<BlobDataHandle>); |
| ScriptPromise readAsync(ScriptState*, ResponseType); |
| void resolveJSON(); |
| @@ -59,13 +62,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 |