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

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

Issue 2550373005: Make WebTaskRunner ThreadSafeRefCounted (Closed)
Patch Set: +DISALLOW_COPY_AND_ASSIGN for win build fix Created 3 years, 11 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 double m_startTime; 60 double m_startTime;
61 size_t m_processedElementTokens; 61 size_t m_processedElementTokens;
62 }; 62 };
63 63
64 class HTMLParserScheduler final 64 class HTMLParserScheduler final
65 : public GarbageCollectedFinalized<HTMLParserScheduler> { 65 : public GarbageCollectedFinalized<HTMLParserScheduler> {
66 WTF_MAKE_NONCOPYABLE(HTMLParserScheduler); 66 WTF_MAKE_NONCOPYABLE(HTMLParserScheduler);
67 67
68 public: 68 public:
69 static HTMLParserScheduler* create(HTMLDocumentParser* parser, 69 static HTMLParserScheduler* create(HTMLDocumentParser* parser,
70 WebTaskRunner* loadingTaskRunner) { 70 RefPtr<WebTaskRunner> loadingTaskRunner) {
71 return new HTMLParserScheduler(parser, loadingTaskRunner); 71 return new HTMLParserScheduler(parser, std::move(loadingTaskRunner));
72 } 72 }
73 ~HTMLParserScheduler(); 73 ~HTMLParserScheduler();
74 74
75 bool isScheduledForResume() const; 75 bool isScheduledForResume() const;
76 void scheduleForResume(); 76 void scheduleForResume();
77 bool yieldIfNeeded(const SpeculationsPumpSession&, bool startingScript); 77 bool yieldIfNeeded(const SpeculationsPumpSession&, bool startingScript);
78 78
79 /** 79 /**
80 * Can only be called if this scheduler is suspended. If this is called, 80 * Can only be called if this scheduler is suspended. If this is called,
81 * then after the scheduler is resumed by calling resume(), this call 81 * then after the scheduler is resumed by calling resume(), this call
82 * ensures that HTMLDocumentParser::resumeAfterYield will be called. Used to 82 * ensures that HTMLDocumentParser::resumeAfterYield will be called. Used to
83 * signal this scheduler that the background html parser sent chunks to 83 * signal this scheduler that the background html parser sent chunks to
84 * HTMLDocumentParser while it was suspended. 84 * HTMLDocumentParser while it was suspended.
85 */ 85 */
86 void forceResumeAfterYield(); 86 void forceResumeAfterYield();
87 87
88 void suspend(); 88 void suspend();
89 void resume(); 89 void resume();
90 90
91 void detach(); // Clear active tasks if any. 91 void detach(); // Clear active tasks if any.
92 92
93 DECLARE_TRACE(); 93 DECLARE_TRACE();
94 94
95 private: 95 private:
96 HTMLParserScheduler(HTMLDocumentParser*, WebTaskRunner*); 96 HTMLParserScheduler(HTMLDocumentParser*, RefPtr<WebTaskRunner>);
97 97
98 bool shouldYield(const SpeculationsPumpSession&, bool startingScript) const; 98 bool shouldYield(const SpeculationsPumpSession&, bool startingScript) const;
99 void continueParsing(); 99 void continueParsing();
100 100
101 Member<HTMLDocumentParser> m_parser; 101 Member<HTMLDocumentParser> m_parser;
102 std::unique_ptr<WebTaskRunner> m_loadingTaskRunner; 102 RefPtr<WebTaskRunner> m_loadingTaskRunner;
103 103
104 TaskHandle m_cancellableContinueParseTaskHandle; 104 TaskHandle m_cancellableContinueParseTaskHandle;
105 bool m_isSuspendedWithActiveTimer; 105 bool m_isSuspendedWithActiveTimer;
106 }; 106 };
107 107
108 } // namespace blink 108 } // namespace blink
109 109
110 #endif 110 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698