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

Unified Diff: Source/wtf/LinkedStack.h

Issue 17314010: RuleSet causes 600 kB of memory fragmentation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address reviewer feedback Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/RuleSet.cpp ('k') | Source/wtf/wtf.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/LinkedStack.h
diff --git a/public/web/WebInbandTextTrack.h b/Source/wtf/LinkedStack.h
similarity index 59%
copy from public/web/WebInbandTextTrack.h
copy to Source/wtf/LinkedStack.h
index cebdf20b8552aee6e4cc4977ebcf6cb7ebbc1e02..f87309eb36d7fd85e672b16984d16d3c00fc935c 100644
--- a/public/web/WebInbandTextTrack.h
+++ b/Source/wtf/LinkedStack.h
@@ -28,49 +28,80 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebInbandTextTrack_h
-#define WebInbandTextTrack_h
+#ifndef LinkedStack_h
+#define LinkedStack_h
-namespace WebKit {
+#include "wtf/OwnPtr.h"
-class WebString;
-class WebInbandTextTrackClient;
+namespace WTF {
-class WebInbandTextTrack {
+template <typename T>
+class LinkedStack {
public:
- enum Kind {
- KindSubtitles,
- KindCaptions,
- KindDescriptions,
- KindChapters,
- KindMetadata,
- KindNone
- };
+ LinkedStack() : m_size(0) { }
+
+ bool isEmpty();
+
+ void push(const T&);
+ const T& peek();
+ void pop();
+
+ size_t size();
+
+private:
+ struct Node {
+ Node(const T&, PassOwnPtr<Node> next);
- enum Mode {
- ModeDisabled,
- ModeHidden,
- ModeShowing
+ T m_data;
+ OwnPtr<Node> m_next;
};
- virtual ~WebInbandTextTrack() {}
+ OwnPtr<Node> m_head;
+ size_t m_size;
+};
- virtual void setClient(WebInbandTextTrackClient*) = 0;
- virtual WebInbandTextTrackClient* client() = 0;
+template <typename T>
+LinkedStack<T>::Node::Node(const T& data, PassOwnPtr<Node> next)
+ : m_data(data)
+ , m_next(next)
+{
+}
- virtual void setMode(Mode) = 0;
- virtual Mode mode() const = 0;
+template <typename T>
+inline bool LinkedStack<T>::isEmpty()
+{
+ return !m_head;
+}
- virtual Kind kind() const = 0;
- virtual bool isClosedCaptions() const = 0;
+template <typename T>
+inline void LinkedStack<T>::push(const T& data)
+{
+ m_head = adoptPtr(new Node(data, m_head.release()));
+ ++m_size;
+}
- virtual WebString label() const = 0;
- virtual WebString language() const = 0;
- virtual bool isDefault() const = 0;
+template <typename T>
+inline const T& LinkedStack<T>::peek()
+{
+ return m_head->m_data;
+}
- virtual int textTrackIndex() const = 0;
-};
+template <typename T>
+inline void LinkedStack<T>::pop()
+{
+ ASSERT(m_head && m_size);
+ m_head = m_head->m_next.release();
+ --m_size;
+}
+
+template <typename T>
+inline size_t LinkedStack<T>::size()
+{
+ return m_size;
+}
+
+}
-} // namespace WebKit
+using WTF::LinkedStack;
#endif
« no previous file with comments | « Source/core/css/RuleSet.cpp ('k') | Source/wtf/wtf.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698