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 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 | 25 |
26 namespace webkit_media { | 26 namespace webkit_media { |
27 | 27 |
28 const int64 kPositionNotSpecified = -1; | 28 const int64 kPositionNotSpecified = -1; |
29 | 29 |
30 const char kHttpScheme[] = "http"; | 30 const char kHttpScheme[] = "http"; |
31 const char kHttpsScheme[] = "https"; | 31 const char kHttpsScheme[] = "https"; |
32 const char kDataScheme[] = "data"; | 32 const char kDataScheme[] = "data"; |
33 | 33 |
34 // Wraps a WebURLLoader to maintain an in-memory buffer of downloaded | 34 // BufferedResourceLoader is single threaded and must be accessed on the |
35 // data according to the current defer strategy. | 35 // render thread. It wraps a WebURLLoader and does in-memory buffering, |
| 36 // pausing resource loading when the in-memory buffer is full and resuming |
| 37 // resource loading when there is available capacity. |
36 class BufferedResourceLoader : public WebKit::WebURLLoaderClient { | 38 class BufferedResourceLoader : public WebKit::WebURLLoaderClient { |
37 public: | 39 public: |
38 // kNeverDefer - Aggresively buffer; never defer loading while paused. | 40 // kNeverDefer - Aggresively buffer; never defer loading while paused. |
39 // kReadThenDefer - Request only enough data to fulfill read requests. | 41 // kReadThenDefer - Request only enough data to fulfill read requests. |
40 // kCapacityDefer - Try to keep amount of buffered data at capacity. | 42 // kCapacityDefer - Try to keep amount of buffered data at capacity. |
41 enum DeferStrategy { | 43 enum DeferStrategy { |
42 kNeverDefer, | 44 kNeverDefer, |
43 kReadThenDefer, | 45 kReadThenDefer, |
44 kCapacityDefer, | 46 kCapacityDefer, |
45 }; | 47 }; |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 float playback_rate_; | 330 float playback_rate_; |
329 | 331 |
330 scoped_refptr<media::MediaLog> media_log_; | 332 scoped_refptr<media::MediaLog> media_log_; |
331 | 333 |
332 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader); | 334 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader); |
333 }; | 335 }; |
334 | 336 |
335 } // namespace webkit_media | 337 } // namespace webkit_media |
336 | 338 |
337 #endif // WEBKIT_MEDIA_BUFFERED_RESOURCE_LOADER_H_ | 339 #endif // WEBKIT_MEDIA_BUFFERED_RESOURCE_LOADER_H_ |
OLD | NEW |