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

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

Issue 1422233002: Revert of BackgroundHTMLParser: Introduce ParsedChunkQueue to pass ParsedChunks to main thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ParsedChunkQueue_h
6 #define ParsedChunkQueue_h
7
8 #include "core/html/parser/HTMLDocumentParser.h"
9 #include "wtf/Deque.h"
10 #include "wtf/OwnPtr.h"
11 #include "wtf/PassOwnPtr.h"
12 #include "wtf/ThreadingPrimitives.h"
13 #include "wtf/Vector.h"
14
15 namespace blink {
16
17 // ParsedChunkQueue is used to transfer parsed HTML token chunks
18 // from BackgroundHTMLParser thread to Blink main thread without
19 // spamming task queue.
20 // ParsedChunkQueue is accessed from both BackgroundHTMLParser
21 // thread (producer) and Blink main thread (consumer).
22 // Access to the backend queue vector is protected by a mutex.
23 // If enqueue is done against empty queue, BackgroundHTMLParser
24 // thread kicks a consumer task on Blink main thread.
25 class ParsedChunkQueue {
26 public:
27 static PassOwnPtr<ParsedChunkQueue> create()
28 {
29 return adoptPtr(new ParsedChunkQueue);
30 }
31
32 bool enqueue(PassOwnPtr<HTMLDocumentParser::ParsedChunk>);
33 void clear();
34
35 void takeAll(Vector<OwnPtr<HTMLDocumentParser::ParsedChunk>>&);
36
37 private:
38 ParsedChunkQueue();
39
40 Mutex m_mutex;
41 Vector<OwnPtr<HTMLDocumentParser::ParsedChunk>> m_pendingChunks;
42 };
43
44 } // namespace blink
45
46 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698