Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: third_party/WebKit/Source/core/streams/Stream.h

Issue 1808533003: Revert of Reduce ActiveDOMObjects from core/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef Stream_h 31 #ifndef Stream_h
32 #define Stream_h 32 #define Stream_h
33 33
34 #include "bindings/core/v8/ScriptWrappable.h" 34 #include "bindings/core/v8/ScriptWrappable.h"
35 #include "core/CoreExport.h" 35 #include "core/CoreExport.h"
36 #include "core/dom/ContextLifecycleObserver.h" 36 #include "core/dom/ActiveDOMObject.h"
37 #include "platform/heap/Handle.h" 37 #include "platform/heap/Handle.h"
38 #include "platform/weborigin/KURL.h" 38 #include "platform/weborigin/KURL.h"
39 #include "wtf/text/WTFString.h" 39 #include "wtf/text/WTFString.h"
40 40
41 namespace blink { 41 namespace blink {
42 42
43 class ExecutionContext; 43 class ExecutionContext;
44 44
45 class CORE_EXPORT Stream final : public GarbageCollectedFinalized<Stream>, publi c ScriptWrappable, public ContextLifecycleObserver { 45 class CORE_EXPORT Stream final : public GarbageCollectedFinalized<Stream>, publi c ScriptWrappable, public ActiveDOMObject {
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 return new Stream(context, mediaType); 51 Stream* stream = new Stream(context, mediaType);
52 stream->suspendIfNeeded();
53 return stream;
52 } 54 }
53 55
54 #if ENABLE(OILPAN)
55 ~Stream();
56 #else
57 ~Stream() override; 56 ~Stream() override;
58 #endif
59 57
60 // Returns the internal URL referring to this stream. 58 // Returns the internal URL referring to this stream.
61 const KURL& url() const { return m_internalURL; } 59 const KURL& url() const { return m_internalURL; }
62 // Returns the media type of this stream. 60 // Returns the media type of this stream.
63 const String& type() const { return m_mediaType; } 61 const String& type() const { return m_mediaType; }
64 62
65 // Appends data to this stream. 63 // Appends data to this stream.
66 void addData(const char* data, size_t len); 64 void addData(const char* data, size_t len);
67 // Flushes contents buffered in the stream. 65 // Flushes contents buffered in the stream.
68 void flush(); 66 void flush();
69 // 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
70 // of EOF. 68 // of EOF.
71 void finalize(); 69 void finalize();
72 // 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
73 // stream is notified of EOF due to the error. 71 // stream is notified of EOF due to the error.
74 void abort(); 72 void abort();
75 73
76 // 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
77 // won't load the corresponding stream again. All stream objects are 75 // won't load the corresponding stream again. All stream objects are
78 // read-once for now. 76 // read-once for now.
79 void neuter() { m_isNeutered = true; } 77 void neuter() { m_isNeutered = true; }
80 bool isNeutered() const { return m_isNeutered; } 78 bool isNeutered() const { return m_isNeutered; }
81 79
82 // TODO(yhirano): Implement suspend()/resume() if necessary. 80 // Implementation of ActiveDOMObject.
83 void contextDestroyed() override; 81 //
82 // FIXME: Implement suspend() and resume() when necessary.
83 void suspend() override;
84 void resume() override;
85 void stop() override;
84 86
85 DECLARE_VIRTUAL_TRACE(); 87 DECLARE_VIRTUAL_TRACE();
86 88
87 protected: 89 protected:
88 Stream(ExecutionContext*, const String& mediaType); 90 Stream(ExecutionContext*, const String& mediaType);
89 91
90 // 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
91 // 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
92 // 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.
93 KURL m_internalURL; 95 KURL m_internalURL;
94 96
95 String m_mediaType; 97 String m_mediaType;
96 98
97 bool m_isNeutered; 99 bool m_isNeutered;
98 }; 100 };
99 101
100 } // namespace blink 102 } // namespace blink
101 103
102 #endif // Stream_h 104 #endif // Stream_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/streams/ReadableStreamReader.cpp ('k') | third_party/WebKit/Source/core/streams/Stream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698