| Index: third_party/WebKit/Source/core/html/parser/ParsedChunkQueue.h
|
| diff --git a/third_party/WebKit/Source/core/html/parser/ParsedChunkQueue.h b/third_party/WebKit/Source/core/html/parser/ParsedChunkQueue.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1a4427061bd90f1f650290ae58f4812796cd0fca
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/html/parser/ParsedChunkQueue.h
|
| @@ -0,0 +1,51 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef ParsedChunkQueue_h
|
| +#define ParsedChunkQueue_h
|
| +
|
| +#include "core/html/parser/HTMLDocumentParser.h"
|
| +#include "wtf/Deque.h"
|
| +#include "wtf/OwnPtr.h"
|
| +#include "wtf/PassOwnPtr.h"
|
| +#include "wtf/PassRefPtr.h"
|
| +#include "wtf/RefPtr.h"
|
| +#include "wtf/ThreadSafeRefCounted.h"
|
| +#include "wtf/ThreadingPrimitives.h"
|
| +#include "wtf/Vector.h"
|
| +
|
| +namespace blink {
|
| +
|
| +// ParsedChunkQueue is used to transfer parsed HTML token chunks
|
| +// from BackgroundHTMLParser thread to Blink main thread without
|
| +// spamming task queue.
|
| +// ParsedChunkQueue is accessed from both BackgroundHTMLParser
|
| +// thread (producer) and Blink main thread (consumer).
|
| +// Access to the backend queue vector is protected by a mutex.
|
| +// If enqueue is done against empty queue, BackgroundHTMLParser
|
| +// thread kicks a consumer task on Blink main thread.
|
| +class ParsedChunkQueue : public ThreadSafeRefCounted<ParsedChunkQueue> {
|
| +public:
|
| + static PassRefPtr<ParsedChunkQueue> create()
|
| + {
|
| + return adoptRef(new ParsedChunkQueue);
|
| + }
|
| +
|
| + ~ParsedChunkQueue();
|
| +
|
| + bool enqueue(PassOwnPtr<HTMLDocumentParser::ParsedChunk>);
|
| + void clear();
|
| +
|
| + void takeAll(Vector<OwnPtr<HTMLDocumentParser::ParsedChunk>>&);
|
| +
|
| +private:
|
| + ParsedChunkQueue();
|
| +
|
| + Mutex m_mutex;
|
| + Vector<OwnPtr<HTMLDocumentParser::ParsedChunk>> m_pendingChunks;
|
| +};
|
| +
|
| +} // namespace blink
|
| +
|
| +#endif
|
|
|