OLD | NEW |
| (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 BodyStreamBuffer_h | |
6 #define BodyStreamBuffer_h | |
7 | |
8 #include "core/dom/DOMException.h" | |
9 #include "platform/blob/BlobData.h" | |
10 #include "platform/heap/Heap.h" | |
11 #include "wtf/Deque.h" | |
12 #include "wtf/RefPtr.h" | |
13 #include "wtf/text/WTFString.h" | |
14 | |
15 namespace blink { | |
16 | |
17 class DOMArrayBuffer; | |
18 | |
19 class BodyStreamBuffer final : public GarbageCollectedFinalized<BodyStreamBuffer
> { | |
20 public: | |
21 class Observer : public GarbageCollectedFinalized<Observer> { | |
22 public: | |
23 virtual ~Observer() { } | |
24 virtual void onWrite() = 0; | |
25 virtual void onClose() = 0; | |
26 virtual void onError() = 0; | |
27 virtual void trace(Visitor*) { } | |
28 }; | |
29 class BlobHandleCreatorClient : public GarbageCollectedFinalized<BlobHandleC
reatorClient> { | |
30 public: | |
31 virtual ~BlobHandleCreatorClient() { } | |
32 virtual void didCreateBlobHandle(PassRefPtr<BlobDataHandle>) = 0; | |
33 virtual void didFail(PassRefPtrWillBeRawPtr<DOMException>) = 0; | |
34 virtual void trace(Visitor*) { } | |
35 }; | |
36 BodyStreamBuffer(); | |
37 ~BodyStreamBuffer() { } | |
38 | |
39 PassRefPtr<DOMArrayBuffer> read(); | |
40 bool isClosed() const { return m_isClosed; } | |
41 bool hasError() const { return m_exception; } | |
42 PassRefPtrWillBeRawPtr<DOMException> exception() const { return m_exception;
} | |
43 | |
44 // Can't call after close() or error() was called. | |
45 void write(PassRefPtr<DOMArrayBuffer>); | |
46 // Can't call after close() or error() was called. | |
47 void close(); | |
48 // Can't call after close() or error() was called. | |
49 void error(PassRefPtrWillBeRawPtr<DOMException>); | |
50 | |
51 // This function registers an observer so it fails and returns false when an | |
52 // observer was already registered | |
53 bool readAllAndCreateBlobHandle(const String& contentType, BlobHandleCreator
Client*); | |
54 | |
55 // When an observer was registered this function fails and returns false. | |
56 bool registerObserver(Observer*); | |
57 void unregisterObserver(); | |
58 bool isObserverRegistered() const { return m_observer.get(); } | |
59 void trace(Visitor*); | |
60 | |
61 private: | |
62 Deque<RefPtr<DOMArrayBuffer> > m_queue; | |
63 bool m_isClosed; | |
64 RefPtrWillBeMember<DOMException> m_exception; | |
65 Member<Observer> m_observer; | |
66 }; | |
67 | |
68 } // namespace blink | |
69 | |
70 #endif // BodyStreamBuffer_h | |
OLD | NEW |