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.
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"
23 : public GarbageCollectedFinalized<Body>
24 , public ScriptWrappable
25 , public ActiveDOMObject
26 , public FileReaderLoaderClient {
27 DEFINE_WRAPPERTYPEINFO();
29 explicit Body(ExecutionContext*);
33 ResponseAsArrayBuffer,
40 ScriptPromise arrayBuffer(ScriptState*);
41 ScriptPromise blob(ScriptState*);
42 ScriptPromise formData(ScriptState*);
43 ScriptPromise json(ScriptState*);
44 ScriptPromise text(ScriptState*);
46 bool bodyUsed() const;
48 // ActiveDOMObject override.
49 virtual void stop() OVERRIDE;
50 virtual bool hasPendingActivity() const OVERRIDE;
52 virtual void trace(Visitor*) { }
55 // Copy constructor for clone() implementations
56 explicit Body(const Body&);
58 // Sets the bodyUsed flag to true. This signifies that the contents of the
59 // body have been consumed and cannot be accessed again.
63 ScriptPromise readAsync(ScriptState*, ResponseType);
66 // FileReaderLoaderClient functions.
67 virtual void didStartLoading() OVERRIDE;
68 virtual void didReceiveData() OVERRIDE;
69 virtual void didFinishLoading() OVERRIDE;
70 virtual void didFail(FileError::ErrorCode) OVERRIDE;
72 virtual PassRefPtr<BlobDataHandle> blobDataHandle() = 0;
74 OwnPtr<FileReaderLoader> m_loader;
76 ResponseType m_responseType;
77 RefPtr<ScriptPromiseResolver> m_resolver;