Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 ResponseAsJSON, | 36 ResponseAsJSON, |
| 37 ResponseAsText | 37 ResponseAsText |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 ScriptPromise arrayBuffer(ScriptState*); | 40 ScriptPromise arrayBuffer(ScriptState*); |
| 41 ScriptPromise blob(ScriptState*); | 41 ScriptPromise blob(ScriptState*); |
| 42 ScriptPromise formData(ScriptState*); | 42 ScriptPromise formData(ScriptState*); |
| 43 ScriptPromise json(ScriptState*); | 43 ScriptPromise json(ScriptState*); |
| 44 ScriptPromise text(ScriptState*); | 44 ScriptPromise text(ScriptState*); |
| 45 | 45 |
| 46 // Sets the bodyUsed flag to true. This signifies that the contents of the | |
| 47 // body have been consumed and cannot be accessed again. | |
| 48 void setBodyUsed(); | |
|
gavinp
2014/11/13 19:35:02
Should we put this after bodyUsed() so the order m
jsbell
2014/11/13 21:16:05
Inlined, to minimize diff.
| |
| 46 bool bodyUsed() const; | 49 bool bodyUsed() const; |
| 47 | 50 |
| 48 // ActiveDOMObject override. | 51 // ActiveDOMObject override. |
| 49 virtual void stop() override; | 52 virtual void stop() override; |
| 50 virtual bool hasPendingActivity() const override; | 53 virtual bool hasPendingActivity() const override; |
| 51 | 54 |
| 52 virtual void trace(Visitor*) { } | 55 virtual void trace(Visitor*) { } |
| 53 | 56 |
| 54 protected: | 57 protected: |
| 55 // Copy constructor for clone() implementations | 58 // Copy constructor for clone() implementations |
| 56 explicit Body(const Body&); | 59 explicit Body(const Body&); |
| 57 | 60 |
| 58 // Sets the bodyUsed flag to true. This signifies that the contents of the | |
| 59 // body have been consumed and cannot be accessed again. | |
| 60 void setBodyUsed(); | |
| 61 | |
| 62 private: | 61 private: |
| 63 ScriptPromise readAsync(ScriptState*, ResponseType); | 62 ScriptPromise readAsync(ScriptState*, ResponseType); |
| 64 void resolveJSON(); | 63 void resolveJSON(); |
| 65 | 64 |
| 66 // FileReaderLoaderClient functions. | 65 // FileReaderLoaderClient functions. |
| 67 virtual void didStartLoading() override; | 66 virtual void didStartLoading() override; |
| 68 virtual void didReceiveData() override; | 67 virtual void didReceiveData() override; |
| 69 virtual void didFinishLoading() override; | 68 virtual void didFinishLoading() override; |
| 70 virtual void didFail(FileError::ErrorCode) override; | 69 virtual void didFail(FileError::ErrorCode) override; |
| 71 | 70 |
| 72 virtual PassRefPtr<BlobDataHandle> blobDataHandle() = 0; | 71 virtual PassRefPtr<BlobDataHandle> blobDataHandle() = 0; |
| 73 | 72 |
| 74 OwnPtr<FileReaderLoader> m_loader; | 73 OwnPtr<FileReaderLoader> m_loader; |
| 75 bool m_bodyUsed; | 74 bool m_bodyUsed; |
| 76 ResponseType m_responseType; | 75 ResponseType m_responseType; |
| 77 RefPtr<ScriptPromiseResolver> m_resolver; | 76 RefPtr<ScriptPromiseResolver> m_resolver; |
| 78 }; | 77 }; |
| 79 | 78 |
| 80 } // namespace blink | 79 } // namespace blink |
| 81 | 80 |
| 82 #endif // Body_h | 81 #endif // Body_h |
| OLD | NEW |