OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/html/parser/ParsedChunkQueue.h" | 5 #include "core/html/parser/ParsedChunkQueue.h" |
6 | 6 |
7 #include <memory> | |
8 | |
9 namespace blink { | 7 namespace blink { |
10 | 8 |
11 ParsedChunkQueue::ParsedChunkQueue() | 9 ParsedChunkQueue::ParsedChunkQueue() |
12 { | 10 { |
13 } | 11 } |
14 | 12 |
15 ParsedChunkQueue::~ParsedChunkQueue() | 13 ParsedChunkQueue::~ParsedChunkQueue() |
16 { | 14 { |
17 } | 15 } |
18 | 16 |
19 bool ParsedChunkQueue::enqueue(std::unique_ptr<HTMLDocumentParser::ParsedChunk>
chunk) | 17 bool ParsedChunkQueue::enqueue(PassOwnPtr<HTMLDocumentParser::ParsedChunk> chunk
) |
20 { | 18 { |
21 MutexLocker locker(m_mutex); | 19 MutexLocker locker(m_mutex); |
22 | 20 |
23 bool wasEmpty = m_pendingChunks.isEmpty(); | 21 bool wasEmpty = m_pendingChunks.isEmpty(); |
24 m_pendingChunks.append(std::move(chunk)); | 22 m_pendingChunks.append(std::move(chunk)); |
25 return wasEmpty; | 23 return wasEmpty; |
26 } | 24 } |
27 | 25 |
28 void ParsedChunkQueue::clear() | 26 void ParsedChunkQueue::clear() |
29 { | 27 { |
30 MutexLocker locker(m_mutex); | 28 MutexLocker locker(m_mutex); |
31 | 29 |
32 m_pendingChunks.clear(); | 30 m_pendingChunks.clear(); |
33 } | 31 } |
34 | 32 |
35 void ParsedChunkQueue::takeAll(Vector<std::unique_ptr<HTMLDocumentParser::Parsed
Chunk>>& vector) | 33 void ParsedChunkQueue::takeAll(Vector<OwnPtr<HTMLDocumentParser::ParsedChunk>>&
vector) |
36 { | 34 { |
37 MutexLocker locker(m_mutex); | 35 MutexLocker locker(m_mutex); |
38 | 36 |
39 ASSERT(vector.isEmpty()); | 37 ASSERT(vector.isEmpty()); |
40 m_pendingChunks.swap(vector); | 38 m_pendingChunks.swap(vector); |
41 } | 39 } |
42 | 40 |
43 } // namespace blink | 41 } // namespace blink |
OLD | NEW |