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

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

Issue 1399603003: Tie multibuffers to URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@media_cache
Patch Set: added MEDIA_BLINK_EXPORT Created 5 years, 2 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 // 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_H_ 5 #ifndef MEDIA_BLINK_MULTIBUFFER_H_
6 #define MEDIA_BLINK_MULTIBUFFER_H_ 6 #define MEDIA_BLINK_MULTIBUFFER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // Uninitialized MultiBufferBlockIds will have a url equal to 49 // Uninitialized MultiBufferBlockIds will have a url equal to
50 // kUnknownUrlData. We also use kUnknownUrlData together with 50 // kUnknownUrlData. We also use kUnknownUrlData together with
51 // a block id of maxint/minint to represent the maximum and 51 // a block id of maxint/minint to represent the maximum and
52 // minimum possible MultiBufferBlockId. Examples, in sorted 52 // minimum possible MultiBufferBlockId. Examples, in sorted
53 // order: 53 // order:
54 // { url=kUnknownUrlData, block_num=-maxint } // minimum possible value 54 // { url=kUnknownUrlData, block_num=-maxint } // minimum possible value
55 // { url=kUnknownUrlData, block_num=0 } // uninitialized 55 // { url=kUnknownUrlData, block_num=0 } // uninitialized
56 // { url=valid, block_num=1 } // valid value 56 // { url=valid, block_num=1 } // valid value
57 // { url=valid, block_num=10 } // valid value 57 // { url=valid, block_num=10 } // valid value
58 // { url=kUnknownUrlData, block_num=maxint } // maximum possible value 58 // { url=kUnknownUrlData, block_num=maxint } // maximum possible value
59 class MEDIA_EXPORT MultiBufferBlockId { 59 class MEDIA_BLINK_EXPORT MultiBufferBlockId {
60 public: 60 public:
61 MultiBufferBlockId(); 61 MultiBufferBlockId();
62 MultiBufferBlockId(const MultiBufferBlockId& block_id); 62 MultiBufferBlockId(const MultiBufferBlockId& block_id);
63 MultiBufferBlockId(MultiBufferUrlData url_data, 63 MultiBufferBlockId(MultiBufferUrlData url_data,
64 MultiBufferBlockNum block_num); 64 MultiBufferBlockNum block_num);
65 ~MultiBufferBlockId(); 65 ~MultiBufferBlockId();
66 bool SameUrl(const MultiBufferBlockId& other) const { 66 bool SameUrl(const MultiBufferBlockId& other) const {
67 return url_data_ == other.url_data_; 67 return url_data_ == other.url_data_;
68 } 68 }
69 bool operator<(const MultiBufferBlockId& other) const { 69 bool operator<(const MultiBufferBlockId& other) const {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return std::numeric_limits<uint64_t>::max(); 132 return std::numeric_limits<uint64_t>::max();
133 return 0; 133 return 0;
134 } 134 }
135 MultiBufferUrlData url_data_; 135 MultiBufferUrlData url_data_;
136 MultiBufferBlockNum block_num_; 136 MultiBufferBlockNum block_num_;
137 }; 137 };
138 138
139 } // namespace media 139 } // namespace media
140 140
141 namespace std { 141 namespace std {
142 MEDIA_EXPORT ostream& operator<<( 142 MEDIA_BLINK_EXPORT ostream& operator<<(ostream& o,
143 ostream& o, const media::MultiBufferBlockId& id); 143 const media::MultiBufferBlockId& id);
144 144
145 template<> 145 template<>
146 class numeric_limits<media::MultiBufferBlockId> { 146 class numeric_limits<media::MultiBufferBlockId> {
147 public: 147 public:
148 static media::MultiBufferBlockId min() { 148 static media::MultiBufferBlockId min() {
149 return media::MultiBufferBlockId( 149 return media::MultiBufferBlockId(
150 kUnknownUrlData, 150 kUnknownUrlData,
151 numeric_limits<media::MultiBufferBlockNum>::min()); 151 numeric_limits<media::MultiBufferBlockNum>::min());
152 } 152 }
153 153
154 static media::MultiBufferBlockId max() { 154 static media::MultiBufferBlockId max() {
155 return media::MultiBufferBlockId( 155 return media::MultiBufferBlockId(
156 kUnknownUrlData, 156 kUnknownUrlData,
157 numeric_limits<media::MultiBufferBlockNum>::max()); 157 numeric_limits<media::MultiBufferBlockNum>::max());
158 } 158 }
159 }; 159 };
160 160
161 } // namespace std 161 } // namespace std
162 162
163 namespace media { 163 namespace media {
164 164
165 // MultiBuffers are multi-reader multi-writer cache/buffers with 165 // MultiBuffers are multi-reader multi-writer cache/buffers with
166 // prefetching and pinning. Data is stored internally in ref-counted 166 // prefetching and pinning. Data is stored internally in ref-counted
167 // blocks of identical size. |block_size_shift| is log2 of the block 167 // blocks of identical size. |block_size_shift| is log2 of the block
168 // size. 168 // size.
169 // 169 //
170 // Users should inherit this class and implement CreateWriter(). 170 // Users should inherit this class and implement CreateWriter().
171 // TODO(hubbe): Make the multibuffer respond to memory pressure. 171 // TODO(hubbe): Make the multibuffer respond to memory pressure.
172 class MEDIA_EXPORT MultiBuffer { 172 class MEDIA_BLINK_EXPORT MultiBuffer {
173 public: 173 public:
174 174
175 // Interface for clients wishing to read data out of this cache. 175 // Interface for clients wishing to read data out of this cache.
176 class Reader { 176 class Reader {
177 public: 177 public:
178 Reader() {} 178 Reader() {}
179 virtual ~Reader() {} 179 virtual ~Reader() {}
180 // Tell the reader that we have a new UrlData. There may be several 180 // Tell the reader that we have a new UrlData. There may be several
181 // reasons for this: 181 // reasons for this:
182 // o We encountered a redirect. 182 // o We encountered a redirect.
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 368
369 // present_[block] should be 1 for all blocks that are present 369 // present_[block] should be 1 for all blocks that are present
370 // and 0 for all blocks that are not. Used to quickly figure out 370 // and 0 for all blocks that are not. Used to quickly figure out
371 // ranges of available blocks without iterating. 371 // ranges of available blocks without iterating.
372 RangeMap<BlockId, int32_t> present_; 372 RangeMap<BlockId, int32_t> present_;
373 }; 373 };
374 374
375 } // namespace media 375 } // namespace media
376 376
377 #endif // MEDIA_BLINK_MULTIBUFFER_H_ 377 #endif // MEDIA_BLINK_MULTIBUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698