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

Side by Side Diff: media/mp4/offset_byte_queue.cc

Issue 10823069: Make peeking before the head of OffsetByteQueue a hard error. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/mp4/offset_byte_queue.h" 5 #include "media/mp4/offset_byte_queue.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace media { 10 namespace media {
(...skipping 19 matching lines...) Expand all
30 *size = size_; 30 *size = size_;
31 } 31 }
32 32
33 void OffsetByteQueue::Pop(int count) { 33 void OffsetByteQueue::Pop(int count) {
34 queue_.Pop(count); 34 queue_.Pop(count);
35 head_ += count; 35 head_ += count;
36 Sync(); 36 Sync();
37 } 37 }
38 38
39 void OffsetByteQueue::PeekAt(int64 offset, const uint8** buf, int* size) { 39 void OffsetByteQueue::PeekAt(int64 offset, const uint8** buf, int* size) {
40 DCHECK(offset >= head());
acolwell GONE FROM CHROMIUM 2012/07/30 20:49:04 Is this a result of a coding error, or can unexpec
strobe_ 2012/07/31 18:34:38 As of now, it can only be the result of a programm
40 if (offset < head() || offset >= tail()) { 41 if (offset < head() || offset >= tail()) {
41 *buf = NULL; 42 *buf = NULL;
42 *size = 0; 43 *size = 0;
43 return; 44 return;
44 } 45 }
45 *buf = &buf_[offset - head()]; 46 *buf = &buf_[offset - head()];
46 *size = tail() - offset; 47 *size = tail() - offset;
47 } 48 }
48 49
49 bool OffsetByteQueue::Trim(int64 max_offset) { 50 bool OffsetByteQueue::Trim(int64 max_offset) {
50 if (max_offset < head_) return true; 51 if (max_offset < head_) return true;
51 if (max_offset > tail()) { 52 if (max_offset > tail()) {
52 Pop(size_); 53 Pop(size_);
53 return false; 54 return false;
54 } 55 }
55 Pop(max_offset - head_); 56 Pop(max_offset - head_);
56 return true; 57 return true;
57 } 58 }
58 59
59 void OffsetByteQueue::Sync() { 60 void OffsetByteQueue::Sync() {
60 queue_.Peek(&buf_, &size_); 61 queue_.Peek(&buf_, &size_);
61 } 62 }
62 63
63 } // namespace media 64 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/mp4/offset_byte_queue_unittest.cc » ('j') | media/mp4/offset_byte_queue_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698