OLD | NEW |
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 #ifndef WEBKIT_MEDIA_BUFFERED_RESOURCE_LOADER_H_ | 5 #ifndef WEBKIT_MEDIA_BUFFERED_RESOURCE_LOADER_H_ |
6 #define WEBKIT_MEDIA_BUFFERED_RESOURCE_LOADER_H_ | 6 #define WEBKIT_MEDIA_BUFFERED_RESOURCE_LOADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 int64* last_byte_position, int64* instance_size); | 206 int64* last_byte_position, int64* instance_size); |
207 | 207 |
208 private: | 208 private: |
209 friend class BufferedDataSourceTest; | 209 friend class BufferedDataSourceTest; |
210 friend class BufferedResourceLoaderTest; | 210 friend class BufferedResourceLoaderTest; |
211 friend class MockBufferedDataSource; | 211 friend class MockBufferedDataSource; |
212 | 212 |
213 // Updates the |buffer_|'s forward and backward capacities. | 213 // Updates the |buffer_|'s forward and backward capacities. |
214 void UpdateBufferWindow(); | 214 void UpdateBufferWindow(); |
215 | 215 |
216 // Returns true if we should defer resource loading based on the current | |
217 // buffering scheme. | |
218 bool ShouldEnableDefer() const; | |
219 | |
220 // Returns true if we should enable resource loading based on the current | |
221 // buffering scheme. | |
222 bool ShouldDisableDefer() const; | |
223 | |
224 // Updates deferring behavior based on current buffering scheme. | 216 // Updates deferring behavior based on current buffering scheme. |
225 void UpdateDeferBehavior(); | 217 void UpdateDeferBehavior(); |
226 | 218 |
227 // Set defer state to |deferred| and cease/continue downloading data | 219 // Sets |active_loader_|'s defer state and fires |loading_cb_| if the state |
228 // accordingly. | 220 // changed. |
229 void SetDeferred(bool deferred); | 221 void SetDeferred(bool deferred); |
230 | 222 |
| 223 // Returns true if we should defer resource loading based on the current |
| 224 // buffering scheme. |
| 225 bool ShouldDefer() const; |
| 226 |
231 // Returns true if the current read request can be fulfilled by what is in | 227 // Returns true if the current read request can be fulfilled by what is in |
232 // the buffer. | 228 // the buffer. |
233 bool CanFulfillRead() const; | 229 bool CanFulfillRead() const; |
234 | 230 |
235 // Returns true if the current read request will be fulfilled in the future. | 231 // Returns true if the current read request will be fulfilled in the future. |
236 bool WillFulfillRead() const; | 232 bool WillFulfillRead() const; |
237 | 233 |
238 // Method that does the actual read and calls the |read_cb_|, assuming the | 234 // Method that does the actual read and calls the |read_cb_|, assuming the |
239 // request range is in |buffer_|. | 235 // request range is in |buffer_|. |
240 void ReadInternal(); | 236 void ReadInternal(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 float playback_rate_; | 326 float playback_rate_; |
331 | 327 |
332 scoped_refptr<media::MediaLog> media_log_; | 328 scoped_refptr<media::MediaLog> media_log_; |
333 | 329 |
334 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader); | 330 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader); |
335 }; | 331 }; |
336 | 332 |
337 } // namespace webkit_media | 333 } // namespace webkit_media |
338 | 334 |
339 #endif // WEBKIT_MEDIA_BUFFERED_RESOURCE_LOADER_H_ | 335 #endif // WEBKIT_MEDIA_BUFFERED_RESOURCE_LOADER_H_ |
OLD | NEW |