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

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

Issue 2751483005: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in core/html/parser/ (Closed)
Patch Set: rebase Created 3 years, 9 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) 2013 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2013 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 size_t tokensExtractedSincePreviousCheckpoint) { 45 size_t tokensExtractedSincePreviousCheckpoint) {
46 HTMLInputCheckpoint checkpoint = m_checkpoints.size(); 46 HTMLInputCheckpoint checkpoint = m_checkpoints.size();
47 m_checkpoints.push_back(Checkpoint(m_current, m_segments.size(), 47 m_checkpoints.push_back(Checkpoint(m_current, m_segments.size(),
48 tokensExtractedSincePreviousCheckpoint)); 48 tokensExtractedSincePreviousCheckpoint));
49 m_totalCheckpointTokenCount += tokensExtractedSincePreviousCheckpoint; 49 m_totalCheckpointTokenCount += tokensExtractedSincePreviousCheckpoint;
50 return checkpoint; 50 return checkpoint;
51 } 51 }
52 52
53 void BackgroundHTMLInputStream::invalidateCheckpointsBefore( 53 void BackgroundHTMLInputStream::invalidateCheckpointsBefore(
54 HTMLInputCheckpoint newFirstValidCheckpointIndex) { 54 HTMLInputCheckpoint newFirstValidCheckpointIndex) {
55 ASSERT(newFirstValidCheckpointIndex < m_checkpoints.size()); 55 DCHECK_LT(newFirstValidCheckpointIndex, m_checkpoints.size());
56 // There is nothing to do for the first valid checkpoint. 56 // There is nothing to do for the first valid checkpoint.
57 if (m_firstValidCheckpointIndex == newFirstValidCheckpointIndex) 57 if (m_firstValidCheckpointIndex == newFirstValidCheckpointIndex)
58 return; 58 return;
59 59
60 ASSERT(newFirstValidCheckpointIndex > m_firstValidCheckpointIndex); 60 DCHECK_GT(newFirstValidCheckpointIndex, m_firstValidCheckpointIndex);
61 const Checkpoint& lastInvalidCheckpoint = 61 const Checkpoint& lastInvalidCheckpoint =
62 m_checkpoints[newFirstValidCheckpointIndex - 1]; 62 m_checkpoints[newFirstValidCheckpointIndex - 1];
63 63
64 ASSERT(m_firstValidSegmentIndex <= 64 DCHECK_LE(m_firstValidSegmentIndex,
65 lastInvalidCheckpoint.numberOfSegmentsAlreadyAppended); 65 lastInvalidCheckpoint.numberOfSegmentsAlreadyAppended);
66 for (size_t i = m_firstValidSegmentIndex; 66 for (size_t i = m_firstValidSegmentIndex;
67 i < lastInvalidCheckpoint.numberOfSegmentsAlreadyAppended; ++i) 67 i < lastInvalidCheckpoint.numberOfSegmentsAlreadyAppended; ++i)
68 m_segments[i] = String(); 68 m_segments[i] = String();
69 m_firstValidSegmentIndex = 69 m_firstValidSegmentIndex =
70 lastInvalidCheckpoint.numberOfSegmentsAlreadyAppended; 70 lastInvalidCheckpoint.numberOfSegmentsAlreadyAppended;
71 71
72 for (size_t i = m_firstValidCheckpointIndex; i < newFirstValidCheckpointIndex; 72 for (size_t i = m_firstValidCheckpointIndex; i < newFirstValidCheckpointIndex;
73 ++i) 73 ++i)
74 m_checkpoints[i].clear(); 74 m_checkpoints[i].clear();
75 m_firstValidCheckpointIndex = newFirstValidCheckpointIndex; 75 m_firstValidCheckpointIndex = newFirstValidCheckpointIndex;
76 76
77 updateTotalCheckpointTokenCount(); 77 updateTotalCheckpointTokenCount();
78 } 78 }
79 79
80 void BackgroundHTMLInputStream::rewindTo(HTMLInputCheckpoint checkpointIndex, 80 void BackgroundHTMLInputStream::rewindTo(HTMLInputCheckpoint checkpointIndex,
81 const String& unparsedInput) { 81 const String& unparsedInput) {
82 ASSERT(checkpointIndex < 82 DCHECK_LT(checkpointIndex,
83 m_checkpoints 83 m_checkpoints
84 .size()); // If this ASSERT fires, checkpointIndex is invalid. 84 .size()); // If this DCHECK fires, checkpointIndex is invalid.
85 const Checkpoint& checkpoint = m_checkpoints[checkpointIndex]; 85 const Checkpoint& checkpoint = m_checkpoints[checkpointIndex];
86 ASSERT(!checkpoint.isNull()); 86
87 #if DCHECK_IS_ON()
88 DCHECK(!checkpoint.isNull());
89 #endif
87 90
88 bool isClosed = m_current.isClosed(); 91 bool isClosed = m_current.isClosed();
89 92
90 m_current = checkpoint.input; 93 m_current = checkpoint.input;
91 94
92 for (size_t i = checkpoint.numberOfSegmentsAlreadyAppended; 95 for (size_t i = checkpoint.numberOfSegmentsAlreadyAppended;
93 i < m_segments.size(); ++i) { 96 i < m_segments.size(); ++i) {
94 ASSERT(!m_segments[i].isNull()); 97 DCHECK(!m_segments[i].isNull());
95 m_current.append(SegmentedString(m_segments[i])); 98 m_current.append(SegmentedString(m_segments[i]));
96 } 99 }
97 100
98 if (!unparsedInput.isEmpty()) { 101 if (!unparsedInput.isEmpty()) {
99 m_current.prepend(SegmentedString(unparsedInput), 102 m_current.prepend(SegmentedString(unparsedInput),
100 SegmentedString::PrependType::NewInput); 103 SegmentedString::PrependType::NewInput);
101 } 104 }
102 105
103 if (isClosed && !m_current.isClosed()) 106 if (isClosed && !m_current.isClosed())
104 m_current.close(); 107 m_current.close();
105 108
106 ASSERT(m_current.isClosed() == isClosed); 109 DCHECK_EQ(m_current.isClosed(), isClosed);
107 110
108 m_segments.clear(); 111 m_segments.clear();
109 m_checkpoints.clear(); 112 m_checkpoints.clear();
110 m_firstValidCheckpointIndex = 0; 113 m_firstValidCheckpointIndex = 0;
111 m_firstValidSegmentIndex = 0; 114 m_firstValidSegmentIndex = 0;
112 115
113 updateTotalCheckpointTokenCount(); 116 updateTotalCheckpointTokenCount();
114 } 117 }
115 118
116 void BackgroundHTMLInputStream::updateTotalCheckpointTokenCount() { 119 void BackgroundHTMLInputStream::updateTotalCheckpointTokenCount() {
117 m_totalCheckpointTokenCount = 0; 120 m_totalCheckpointTokenCount = 0;
118 for (const auto& checkpoint : m_checkpoints) { 121 for (const auto& checkpoint : m_checkpoints) {
119 m_totalCheckpointTokenCount += 122 m_totalCheckpointTokenCount +=
120 checkpoint.tokensExtractedSincePreviousCheckpoint; 123 checkpoint.tokensExtractedSincePreviousCheckpoint;
121 } 124 }
122 } 125 }
123 126
124 } // namespace blink 127 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698