| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 class HTMLDocumentParser; | 38 class HTMLDocumentParser; |
| 39 class WebTaskRunner; | 39 class WebTaskRunner; |
| 40 | 40 |
| 41 class ActiveParserSession : public NestingLevelIncrementer { | 41 class ActiveParserSession : public NestingLevelIncrementer { |
| 42 STACK_ALLOCATED(); | 42 STACK_ALLOCATED(); |
| 43 public: | 43 public: |
| 44 ActiveParserSession(unsigned& nestingLevel, Document*); | 44 ActiveParserSession(unsigned& nestingLevel, Document*); |
| 45 ~ActiveParserSession(); | 45 ~ActiveParserSession(); |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 RefPtrWillBeMember<Document> m_document; | 48 Member<Document> m_document; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 class PumpSession : public ActiveParserSession { | 51 class PumpSession : public ActiveParserSession { |
| 52 STACK_ALLOCATED(); | 52 STACK_ALLOCATED(); |
| 53 public: | 53 public: |
| 54 PumpSession(unsigned& nestingLevel, Document*); | 54 PumpSession(unsigned& nestingLevel, Document*); |
| 55 ~PumpSession(); | 55 ~PumpSession(); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class SpeculationsPumpSession : public ActiveParserSession { | 58 class SpeculationsPumpSession : public ActiveParserSession { |
| 59 STACK_ALLOCATED(); | 59 STACK_ALLOCATED(); |
| 60 public: | 60 public: |
| 61 SpeculationsPumpSession(unsigned& nestingLevel, Document*); | 61 SpeculationsPumpSession(unsigned& nestingLevel, Document*); |
| 62 ~SpeculationsPumpSession(); | 62 ~SpeculationsPumpSession(); |
| 63 | 63 |
| 64 double elapsedTime() const; | 64 double elapsedTime() const; |
| 65 void addedElementTokens(size_t count); | 65 void addedElementTokens(size_t count); |
| 66 size_t processedElementTokens() const { return m_processedElementTokens; } | 66 size_t processedElementTokens() const { return m_processedElementTokens; } |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 double m_startTime; | 69 double m_startTime; |
| 70 size_t m_processedElementTokens; | 70 size_t m_processedElementTokens; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 class HTMLParserScheduler final : public NoBaseWillBeGarbageCollectedFinalized<H
TMLParserScheduler> { | 73 class HTMLParserScheduler final : public GarbageCollectedFinalized<HTMLParserSch
eduler> { |
| 74 WTF_MAKE_NONCOPYABLE(HTMLParserScheduler); | 74 WTF_MAKE_NONCOPYABLE(HTMLParserScheduler); |
| 75 USING_FAST_MALLOC_WILL_BE_REMOVED(HTMLParserScheduler); | |
| 76 public: | 75 public: |
| 77 static PassOwnPtrWillBeRawPtr<HTMLParserScheduler> create(HTMLDocumentParser
* parser, WebTaskRunner* loadingTaskRunner) | 76 static RawPtr<HTMLParserScheduler> create(HTMLDocumentParser* parser, WebTas
kRunner* loadingTaskRunner) |
| 78 { | 77 { |
| 79 return adoptPtrWillBeNoop(new HTMLParserScheduler(parser, loadingTaskRun
ner)); | 78 return (new HTMLParserScheduler(parser, loadingTaskRunner)); |
| 80 } | 79 } |
| 81 ~HTMLParserScheduler(); | 80 ~HTMLParserScheduler(); |
| 82 | 81 |
| 83 bool isScheduledForResume() const { return m_isSuspendedWithActiveTimer || m
_cancellableContinueParse->isPending(); } | 82 bool isScheduledForResume() const { return m_isSuspendedWithActiveTimer || m
_cancellableContinueParse->isPending(); } |
| 84 | 83 |
| 85 void scheduleForResume(); | 84 void scheduleForResume(); |
| 86 bool yieldIfNeeded(const SpeculationsPumpSession&, bool startingScript); | 85 bool yieldIfNeeded(const SpeculationsPumpSession&, bool startingScript); |
| 87 | 86 |
| 88 /** | 87 /** |
| 89 * Can only be called if this scheduler is suspended. If this is called, | 88 * Can only be called if this scheduler is suspended. If this is called, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 100 void detach(); // Clear active tasks if any. | 99 void detach(); // Clear active tasks if any. |
| 101 | 100 |
| 102 DECLARE_TRACE(); | 101 DECLARE_TRACE(); |
| 103 | 102 |
| 104 private: | 103 private: |
| 105 HTMLParserScheduler(HTMLDocumentParser*, WebTaskRunner*); | 104 HTMLParserScheduler(HTMLDocumentParser*, WebTaskRunner*); |
| 106 | 105 |
| 107 bool shouldYield(const SpeculationsPumpSession&, bool startingScript) const; | 106 bool shouldYield(const SpeculationsPumpSession&, bool startingScript) const; |
| 108 void continueParsing(); | 107 void continueParsing(); |
| 109 | 108 |
| 110 RawPtrWillBeMember<HTMLDocumentParser> m_parser; | 109 Member<HTMLDocumentParser> m_parser; |
| 111 OwnPtr<WebTaskRunner> m_loadingTaskRunner; | 110 OwnPtr<WebTaskRunner> m_loadingTaskRunner; |
| 112 | 111 |
| 113 OwnPtr<CancellableTaskFactory> m_cancellableContinueParse; | 112 OwnPtr<CancellableTaskFactory> m_cancellableContinueParse; |
| 114 bool m_isSuspendedWithActiveTimer; | 113 bool m_isSuspendedWithActiveTimer; |
| 115 }; | 114 }; |
| 116 | 115 |
| 117 } // namespace blink | 116 } // namespace blink |
| 118 | 117 |
| 119 #endif | 118 #endif |
| OLD | NEW |