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

Side by Side Diff: Source/core/html/parser/HTMLParserScheduler.h

Issue 652813004: Move speculations pump scheduling logic to HTMLParserScheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: compilefix Created 6 years, 2 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) 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 10 matching lines...) Expand all
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef HTMLParserScheduler_h 26 #ifndef HTMLParserScheduler_h
27 #define HTMLParserScheduler_h 27 #define HTMLParserScheduler_h
28 28
29 #include "core/html/parser/NestingLevelIncrementer.h" 29 #include "core/html/parser/NestingLevelIncrementer.h"
30 #include "platform/Timer.h" 30 #include "platform/Timer.h"
31 #include "wtf/CurrentTime.h"
32 #include "wtf/PassOwnPtr.h" 31 #include "wtf/PassOwnPtr.h"
33 #include "wtf/RefPtr.h" 32 #include "wtf/RefPtr.h"
34 33
35 namespace blink { 34 namespace blink {
36 35
37 class Document; 36 class Document;
38 class HTMLDocumentParser; 37 class HTMLDocumentParser;
39 38
40 class ActiveParserSession { 39 class ActiveParserSession {
41 STACK_ALLOCATED(); 40 STACK_ALLOCATED();
42 public: 41 public:
43 explicit ActiveParserSession(Document*); 42 explicit ActiveParserSession(Document*);
44 ~ActiveParserSession(); 43 ~ActiveParserSession();
45 44
46 private: 45 private:
47 RefPtrWillBeMember<Document> m_document; 46 RefPtrWillBeMember<Document> m_document;
48 }; 47 };
49 48
50 class PumpSession : public NestingLevelIncrementer, public ActiveParserSession { 49 class PumpSession : public NestingLevelIncrementer, public ActiveParserSession {
51 STACK_ALLOCATED(); 50 STACK_ALLOCATED();
52 public: 51 public:
53 PumpSession(unsigned& nestingLevel, Document*); 52 PumpSession(unsigned& nestingLevel, Document*);
54 ~PumpSession(); 53 ~PumpSession();
55 }; 54 };
56 55
56 class SpeculationsPumpSession : public ActiveParserSession {
57 public:
58 SpeculationsPumpSession(Document*);
59 ~SpeculationsPumpSession();
60
61 double elapsedTime() const;
62
63 private:
64 double m_startTime;
65 };
66
57 class HTMLParserScheduler { 67 class HTMLParserScheduler {
58 WTF_MAKE_NONCOPYABLE(HTMLParserScheduler); WTF_MAKE_FAST_ALLOCATED; 68 WTF_MAKE_NONCOPYABLE(HTMLParserScheduler); WTF_MAKE_FAST_ALLOCATED;
59 public: 69 public:
60 static PassOwnPtr<HTMLParserScheduler> create(HTMLDocumentParser* parser) 70 static PassOwnPtr<HTMLParserScheduler> create(HTMLDocumentParser* parser)
61 { 71 {
62 return adoptPtr(new HTMLParserScheduler(parser)); 72 return adoptPtr(new HTMLParserScheduler(parser));
63 } 73 }
64 ~HTMLParserScheduler(); 74 ~HTMLParserScheduler();
65 75
66 void scheduleForResume();
67 bool isScheduledForResume() const { return m_isSuspendedWithActiveTimer || m _continueNextChunkTimer.isActive(); } 76 bool isScheduledForResume() const { return m_isSuspendedWithActiveTimer || m _continueNextChunkTimer.isActive(); }
68 77
78 bool yieldIfNeeded(const SpeculationsPumpSession&);
79
69 void suspend(); 80 void suspend();
70 void resume(); 81 void resume();
71 82
72 private: 83 private:
73 HTMLParserScheduler(HTMLDocumentParser*); 84 HTMLParserScheduler(HTMLDocumentParser*);
74 85
86 bool shouldYield(const SpeculationsPumpSession&);
Sami 2014/10/16 12:46:25 Looks like this could be a const method?
kouhei (in TOK) 2014/10/16 12:54:19 Done.
87 void scheduleForResume();
75 void continueNextChunkTimerFired(Timer<HTMLParserScheduler>*); 88 void continueNextChunkTimerFired(Timer<HTMLParserScheduler>*);
76 89
77 HTMLDocumentParser* m_parser; 90 HTMLDocumentParser* m_parser;
78 91
79 Timer<HTMLParserScheduler> m_continueNextChunkTimer; 92 Timer<HTMLParserScheduler> m_continueNextChunkTimer;
80 bool m_isSuspendedWithActiveTimer; 93 bool m_isSuspendedWithActiveTimer;
81 }; 94 };
82 95
83 } 96 }
84 97
85 #endif 98 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698