OLD | NEW |
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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 namespace blink { | 28 namespace blink { |
29 | 29 |
30 BackgroundHTMLInputStream::BackgroundHTMLInputStream() | 30 BackgroundHTMLInputStream::BackgroundHTMLInputStream() |
31 : m_firstValidCheckpointIndex(0), | 31 : m_firstValidCheckpointIndex(0), |
32 m_firstValidSegmentIndex(0), | 32 m_firstValidSegmentIndex(0), |
33 m_totalCheckpointTokenCount(0) {} | 33 m_totalCheckpointTokenCount(0) {} |
34 | 34 |
35 void BackgroundHTMLInputStream::append(const String& input) { | 35 void BackgroundHTMLInputStream::append(const String& input) { |
36 m_current.append(SegmentedString(input)); | 36 m_current.append(SegmentedString(input)); |
37 m_segments.append(input); | 37 m_segments.push_back(input); |
38 } | 38 } |
39 | 39 |
40 void BackgroundHTMLInputStream::close() { | 40 void BackgroundHTMLInputStream::close() { |
41 m_current.close(); | 41 m_current.close(); |
42 } | 42 } |
43 | 43 |
44 HTMLInputCheckpoint BackgroundHTMLInputStream::createCheckpoint( | 44 HTMLInputCheckpoint BackgroundHTMLInputStream::createCheckpoint( |
45 size_t tokensExtractedSincePreviousCheckpoint) { | 45 size_t tokensExtractedSincePreviousCheckpoint) { |
46 HTMLInputCheckpoint checkpoint = m_checkpoints.size(); | 46 HTMLInputCheckpoint checkpoint = m_checkpoints.size(); |
47 m_checkpoints.append(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 ASSERT(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; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 void BackgroundHTMLInputStream::updateTotalCheckpointTokenCount() { | 116 void BackgroundHTMLInputStream::updateTotalCheckpointTokenCount() { |
117 m_totalCheckpointTokenCount = 0; | 117 m_totalCheckpointTokenCount = 0; |
118 for (const auto& checkpoint : m_checkpoints) { | 118 for (const auto& checkpoint : m_checkpoints) { |
119 m_totalCheckpointTokenCount += | 119 m_totalCheckpointTokenCount += |
120 checkpoint.tokensExtractedSincePreviousCheckpoint; | 120 checkpoint.tokensExtractedSincePreviousCheckpoint; |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 } // namespace blink | 124 } // namespace blink |
OLD | NEW |