OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Stream); | 46 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Stream); |
47 DEFINE_WRAPPERTYPEINFO(); | 47 DEFINE_WRAPPERTYPEINFO(); |
48 public: | 48 public: |
49 static Stream* create(ExecutionContext* context, const String& mediaType) | 49 static Stream* create(ExecutionContext* context, const String& mediaType) |
50 { | 50 { |
51 Stream* stream = new Stream(context, mediaType); | 51 Stream* stream = new Stream(context, mediaType); |
52 stream->suspendIfNeeded(); | 52 stream->suspendIfNeeded(); |
53 return stream; | 53 return stream; |
54 } | 54 } |
55 | 55 |
56 virtual ~Stream(); | 56 ~Stream() override; |
57 | 57 |
58 // Returns the internal URL referring to this stream. | 58 // Returns the internal URL referring to this stream. |
59 const KURL& url() const { return m_internalURL; } | 59 const KURL& url() const { return m_internalURL; } |
60 // Returns the media type of this stream. | 60 // Returns the media type of this stream. |
61 const String& type() const { return m_mediaType; } | 61 const String& type() const { return m_mediaType; } |
62 | 62 |
63 // Appends data to this stream. | 63 // Appends data to this stream. |
64 void addData(const char* data, size_t len); | 64 void addData(const char* data, size_t len); |
65 // Flushes contents buffered in the stream. | 65 // Flushes contents buffered in the stream. |
66 void flush(); | 66 void flush(); |
67 // Mark this stream finalized so that a reader of this stream is notified | 67 // Mark this stream finalized so that a reader of this stream is notified |
68 // of EOF. | 68 // of EOF. |
69 void finalize(); | 69 void finalize(); |
70 // Mark this stream finalized due to an error so that a reader of this | 70 // Mark this stream finalized due to an error so that a reader of this |
71 // stream is notified of EOF due to the error. | 71 // stream is notified of EOF due to the error. |
72 void abort(); | 72 void abort(); |
73 | 73 |
74 // Allow an external reader class to mark this object neutered so that they | 74 // Allow an external reader class to mark this object neutered so that they |
75 // won't load the corresponding stream again. All stream objects are | 75 // won't load the corresponding stream again. All stream objects are |
76 // read-once for now. | 76 // read-once for now. |
77 void neuter() { m_isNeutered = true; } | 77 void neuter() { m_isNeutered = true; } |
78 bool isNeutered() const { return m_isNeutered; } | 78 bool isNeutered() const { return m_isNeutered; } |
79 | 79 |
80 // Implementation of ActiveDOMObject. | 80 // Implementation of ActiveDOMObject. |
81 // | 81 // |
82 // FIXME: Implement suspend() and resume() when necessary. | 82 // FIXME: Implement suspend() and resume() when necessary. |
83 virtual void suspend() override; | 83 void suspend() override; |
84 virtual void resume() override; | 84 void resume() override; |
85 virtual void stop() override; | 85 void stop() override; |
86 | 86 |
87 DECLARE_VIRTUAL_TRACE(); | 87 DECLARE_VIRTUAL_TRACE(); |
88 | 88 |
89 protected: | 89 protected: |
90 Stream(ExecutionContext*, const String& mediaType); | 90 Stream(ExecutionContext*, const String& mediaType); |
91 | 91 |
92 // This is an internal URL referring to the blob data associated with this o
bject. It serves | 92 // This is an internal URL referring to the blob data associated with this o
bject. It serves |
93 // as an identifier for this blob. The internal URL is never used to source
the blob's content | 93 // as an identifier for this blob. The internal URL is never used to source
the blob's content |
94 // into an HTML or for FileRead'ing, public blob URLs must be used for those
purposes. | 94 // into an HTML or for FileRead'ing, public blob URLs must be used for those
purposes. |
95 KURL m_internalURL; | 95 KURL m_internalURL; |
96 | 96 |
97 String m_mediaType; | 97 String m_mediaType; |
98 | 98 |
99 bool m_isNeutered; | 99 bool m_isNeutered; |
100 }; | 100 }; |
101 | 101 |
102 } // namespace blink | 102 } // namespace blink |
103 | 103 |
104 #endif // Stream_h | 104 #endif // Stream_h |
OLD | NEW |