Remove obsolete for_web_contents parameter in FontRenderParamsQuery.
[chromium-blink-merge.git] / media / formats / common / offset_byte_queue.h
blob0996f073463fbfee22267fe581e650284d9f9190
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_FORMATS_COMMON_OFFSET_BYTE_QUEUE_H_
6 #define MEDIA_FORMATS_COMMON_OFFSET_BYTE_QUEUE_H_
8 #include "base/basictypes.h"
9 #include "media/base/byte_queue.h"
10 #include "media/base/media_export.h"
12 namespace media {
14 // A wrapper around a ByteQueue which maintains a notion of a
15 // monotonically-increasing offset. All buffer access is done by passing these
16 // offsets into this class, going some way towards preventing the proliferation
17 // of many different meanings of "offset", "head", etc.
18 class MEDIA_EXPORT OffsetByteQueue {
19 public:
20 OffsetByteQueue();
21 ~OffsetByteQueue();
23 // These work like their underlying ByteQueue counterparts.
24 void Reset();
25 void Push(const uint8* buf, int size);
26 void Peek(const uint8** buf, int* size);
27 void Pop(int count);
29 // Sets |buf| to point at the first buffered byte corresponding to |offset|,
30 // and |size| to the number of bytes available starting from that offset.
32 // It is an error if the offset is before the current head. It's not an error
33 // if the current offset is beyond tail(), but you will of course get back
34 // a null |buf| and a |size| of zero.
35 void PeekAt(int64 offset, const uint8** buf, int* size);
37 // Marks the bytes up to (but not including) |max_offset| as ready for
38 // deletion. This is relatively inexpensive, but will not necessarily reduce
39 // the resident buffer size right away (or ever).
41 // Returns true if the full range of bytes were successfully trimmed,
42 // including the case where |max_offset| is less than the current head.
43 // Returns false if |max_offset| > tail() (although all bytes currently
44 // buffered are still cleared).
45 bool Trim(int64 max_offset);
47 // The head and tail positions, in terms of the file's absolute offsets.
48 // tail() is an exclusive bound.
49 int64 head() { return head_; }
50 int64 tail() { return head_ + size_; }
52 private:
53 // Synchronize |buf_| and |size_| with |queue_|.
54 void Sync();
56 ByteQueue queue_;
57 const uint8* buf_;
58 int size_;
59 int64 head_;
61 DISALLOW_COPY_AND_ASSIGN(OffsetByteQueue);
64 } // namespace media
66 #endif // MEDIA_FORMATS_COMMON_OFFSET_BYTE_QUEUE_H_