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

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

Issue 1750453002: 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/ActiveDOMObject.h" 36 #include "core/dom/ContextLifecycleObserver.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 ActiveDOMObject { 45 class CORE_EXPORT Stream final : public GarbageCollectedFinalized<Stream>, publi c ScriptWrappable, public ContextLifecycleObserver {
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 return new Stream(context, mediaType);
52 stream->suspendIfNeeded();
53 return stream;
54 } 52 }
55 53
54 #if ENABLE(OILPAN)
55 ~Stream();
56 #else
56 ~Stream() override; 57 ~Stream() override;
58 #endif
57 59
58 // Returns the internal URL referring to this stream. 60 // Returns the internal URL referring to this stream.
59 const KURL& url() const { return m_internalURL; } 61 const KURL& url() const { return m_internalURL; }
60 // Returns the media type of this stream. 62 // Returns the media type of this stream.
61 const String& type() const { return m_mediaType; } 63 const String& type() const { return m_mediaType; }
62 64
63 // Appends data to this stream. 65 // Appends data to this stream.
64 void addData(const char* data, size_t len); 66 void addData(const char* data, size_t len);
65 // Flushes contents buffered in the stream. 67 // Flushes contents buffered in the stream.
66 void flush(); 68 void flush();
67 // Mark this stream finalized so that a reader of this stream is notified 69 // Mark this stream finalized so that a reader of this stream is notified
68 // of EOF. 70 // of EOF.
69 void finalize(); 71 void finalize();
70 // Mark this stream finalized due to an error so that a reader of this 72 // Mark this stream finalized due to an error so that a reader of this
71 // stream is notified of EOF due to the error. 73 // stream is notified of EOF due to the error.
72 void abort(); 74 void abort();
73 75
74 // Allow an external reader class to mark this object neutered so that they 76 // 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 77 // won't load the corresponding stream again. All stream objects are
76 // read-once for now. 78 // read-once for now.
77 void neuter() { m_isNeutered = true; } 79 void neuter() { m_isNeutered = true; }
78 bool isNeutered() const { return m_isNeutered; } 80 bool isNeutered() const { return m_isNeutered; }
79 81
80 // Implementation of ActiveDOMObject. 82 // TODO(yhirano): Implement suspend()/resume() if necessary.
81 // 83 void contextDestroyed() override;
82 // FIXME: Implement suspend() and resume() when necessary.
83 void suspend() override;
84 void resume() override;
85 void stop() override;
86 84
87 DECLARE_VIRTUAL_TRACE(); 85 DECLARE_VIRTUAL_TRACE();
88 86
89 protected: 87 protected:
90 Stream(ExecutionContext*, const String& mediaType); 88 Stream(ExecutionContext*, const String& mediaType);
91 89
92 // This is an internal URL referring to the blob data associated with this o bject. It serves 90 // 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 91 // 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. 92 // into an HTML or for FileRead'ing, public blob URLs must be used for those purposes.
95 KURL m_internalURL; 93 KURL m_internalURL;
96 94
97 String m_mediaType; 95 String m_mediaType;
98 96
99 bool m_isNeutered; 97 bool m_isNeutered;
100 }; 98 };
101 99
102 } // namespace blink 100 } // namespace blink
103 101
104 #endif // Stream_h 102 #endif // Stream_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698