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

Side by Side Diff: media/blink/multibuffer_reader.h

Issue 1754893006: Fix multibuffer crashing bug (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK -> CHECK Created 4 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
« no previous file with comments | « media/blink/multibuffer_data_source_unittest.cc ('k') | media/blink/multibuffer_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef MEDIA_BLINK_MULTIBUFFER_READER_H_ 5 #ifndef MEDIA_BLINK_MULTIBUFFER_READER_H_
6 #define MEDIA_BLINK_MULTIBUFFER_READER_H_ 6 #define MEDIA_BLINK_MULTIBUFFER_READER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // Returns the block for a particular byte position. 94 // Returns the block for a particular byte position.
95 MultiBufferBlockId block(int64_t byte_pos) const { 95 MultiBufferBlockId block(int64_t byte_pos) const {
96 return byte_pos >> multibuffer_->block_size_shift(); 96 return byte_pos >> multibuffer_->block_size_shift();
97 } 97 }
98 98
99 // Returns the block for a particular byte position, rounding up. 99 // Returns the block for a particular byte position, rounding up.
100 MultiBufferBlockId block_ceil(int64_t byte_pos) const { 100 MultiBufferBlockId block_ceil(int64_t byte_pos) const {
101 return block(byte_pos + (1LL << multibuffer_->block_size_shift()) - 1); 101 return block(byte_pos + (1LL << multibuffer_->block_size_shift()) - 1);
102 } 102 }
103 103
104 // Unpin previous range, then pin the new range.
105 void PinRange(MultiBuffer::BlockId begin, MultiBuffer::BlockId end);
106
104 // Check if wait operation can complete now. 107 // Check if wait operation can complete now.
105 void CheckWait(); 108 void CheckWait();
106 109
107 // Recalculate preload_pos_ and update our entry in the multibuffer 110 // Recalculate preload_pos_ and update our entry in the multibuffer
108 // reader index. Also call CheckWait(). This function is basically 111 // reader index. Also call CheckWait(). This function is basically
109 // called anything changes, like when we get more data or seek to 112 // called anything changes, like when we get more data or seek to
110 // a new position. 113 // a new position.
111 void UpdateInternalState(); 114 void UpdateInternalState();
112 115
113 // Update end_ if p-1 contains an end-of-stream block. 116 // Update end_ if p-1 contains an end-of-stream block.
(...skipping 12 matching lines...) Expand all
126 129
127 // Defer reading once we have this much data. 130 // Defer reading once we have this much data.
128 int64_t preload_high_; 131 int64_t preload_high_;
129 // Stop deferring once we have this much data. 132 // Stop deferring once we have this much data.
130 int64_t preload_low_; 133 int64_t preload_low_;
131 134
132 // Pin this much data in the cache from the current position. 135 // Pin this much data in the cache from the current position.
133 int64_t max_buffer_forward_; 136 int64_t max_buffer_forward_;
134 int64_t max_buffer_backward_; 137 int64_t max_buffer_backward_;
135 138
139 // Currently pinned range.
140 Interval<MultiBuffer::BlockId> pinned_range_;
141
136 // Current position in bytes. 142 // Current position in bytes.
137 int64_t pos_; 143 int64_t pos_;
138 144
139 // [block(pos_)..preload_pos_) are known to be in the cache. 145 // [block(pos_)..preload_pos_) are known to be in the cache.
140 // preload_pos_ is only allowed to point to a filled 146 // preload_pos_ is only allowed to point to a filled
141 // cache position if it is equal to end_ or pos_+preload_. 147 // cache position if it is equal to end_ or pos_+preload_.
142 // This is a pointer to a slot in the cache, so the unit is 148 // This is a pointer to a slot in the cache, so the unit is
143 // blocks. 149 // blocks.
144 MultiBufferBlockId preload_pos_; 150 MultiBufferBlockId preload_pos_;
145 151
146 // True if we've requested data from the cache by calling WaitFor(). 152 // True if we've requested data from the cache by calling WaitFor().
147 bool loading_; 153 bool loading_;
148 154
149 // When Available() > current_wait_size_ we call cb_. 155 // When Available() > current_wait_size_ we call cb_.
150 int64_t current_wait_size_; 156 int64_t current_wait_size_;
151 base::Closure cb_; 157 base::Closure cb_;
152 158
153 // Progress callback. 159 // Progress callback.
154 base::Callback<void(int64_t, int64_t)> progress_callback_; 160 base::Callback<void(int64_t, int64_t)> progress_callback_;
155 161
156 base::WeakPtrFactory<MultiBufferReader> weak_factory_; 162 base::WeakPtrFactory<MultiBufferReader> weak_factory_;
157 }; 163 };
158 164
159 } // namespace media 165 } // namespace media
160 166
161 #endif // MEDIA_BLINK_MULTIBUFFER_READER_H_ 167 #endif // MEDIA_BLINK_MULTIBUFFER_READER_H_
OLDNEW
« no previous file with comments | « media/blink/multibuffer_data_source_unittest.cc ('k') | media/blink/multibuffer_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698