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

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

Issue 2078723002: Add HTML parser UMA for rewinds and chunk queue statistics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 // 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 <algorithm>
8
7 namespace blink { 9 namespace blink {
8 10
9 ParsedChunkQueue::ParsedChunkQueue() 11 ParsedChunkQueue::ParsedChunkQueue()
10 { 12 {
11 } 13 }
12 14
13 ParsedChunkQueue::~ParsedChunkQueue() 15 ParsedChunkQueue::~ParsedChunkQueue()
14 { 16 {
15 } 17 }
16 18
17 bool ParsedChunkQueue::enqueue(PassOwnPtr<HTMLDocumentParser::ParsedChunk> chunk ) 19 bool ParsedChunkQueue::enqueue(PassOwnPtr<HTMLDocumentParser::ParsedChunk> chunk )
18 { 20 {
19 MutexLocker locker(m_mutex); 21 MutexLocker locker(m_mutex);
20 22
23 m_pendingTokenCount += chunk->tokens->size();
24 m_peakPendingTokenCount = std::max(m_peakPendingTokenCount, m_pendingTokenCo unt);
25
21 bool wasEmpty = m_pendingChunks.isEmpty(); 26 bool wasEmpty = m_pendingChunks.isEmpty();
22 m_pendingChunks.append(std::move(chunk)); 27 m_pendingChunks.append(std::move(chunk));
28 m_peakPendingChunkCount = std::max(m_peakPendingChunkCount, m_pendingChunks. size());
29
23 return wasEmpty; 30 return wasEmpty;
24 } 31 }
25 32
26 void ParsedChunkQueue::clear() 33 void ParsedChunkQueue::clear()
27 { 34 {
28 MutexLocker locker(m_mutex); 35 MutexLocker locker(m_mutex);
29 36
37 m_pendingTokenCount = 0;
30 m_pendingChunks.clear(); 38 m_pendingChunks.clear();
31 } 39 }
32 40
33 void ParsedChunkQueue::takeAll(Vector<OwnPtr<HTMLDocumentParser::ParsedChunk>>& vector) 41 void ParsedChunkQueue::takeAll(Vector<OwnPtr<HTMLDocumentParser::ParsedChunk>>& vector)
34 { 42 {
35 MutexLocker locker(m_mutex); 43 MutexLocker locker(m_mutex);
36 44
37 ASSERT(vector.isEmpty()); 45 ASSERT(vector.isEmpty());
38 m_pendingChunks.swap(vector); 46 m_pendingChunks.swap(vector);
39 } 47 }
40 48
49 size_t ParsedChunkQueue::peakPendingChunkCount()
50 {
51 MutexLocker locker(m_mutex);
52 return m_peakPendingChunkCount;
53 }
54
55 size_t ParsedChunkQueue::peakPendingTokenCount()
56 {
57 MutexLocker locker(m_mutex);
58 return m_peakPendingTokenCount;
59 }
60
41 } // namespace blink 61 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698