OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_GLUE_MEDIA_BUFFERED_RESOURCE_LOADER_H_ | 5 #ifndef WEBKIT_GLUE_MEDIA_BUFFERED_RESOURCE_LOADER_H_ |
6 #define WEBKIT_GLUE_MEDIA_BUFFERED_RESOURCE_LOADER_H_ | 6 #define WEBKIT_GLUE_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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 kNeverDefer, | 47 kNeverDefer, |
48 kReadThenDefer, | 48 kReadThenDefer, |
49 kThresholdDefer, | 49 kThresholdDefer, |
50 }; | 50 }; |
51 | 51 |
52 // |url| - URL for the resource to be loaded. | 52 // |url| - URL for the resource to be loaded. |
53 // |first_byte_position| - First byte to start loading from, | 53 // |first_byte_position| - First byte to start loading from, |
54 // |kPositionNotSpecified| for not specified. | 54 // |kPositionNotSpecified| for not specified. |
55 // |last_byte_position| - Last byte to be loaded, | 55 // |last_byte_position| - Last byte to be loaded, |
56 // |kPositionNotSpecified| for not specified. | 56 // |kPositionNotSpecified| for not specified. |
| 57 // |strategy| is the initial loading strategy to use. |
| 58 // |bitrate| is the bitrate of the media, 0 if unknown. |
| 59 // |playback_rate| is the current playback rate of the media. |
57 BufferedResourceLoader(const GURL& url, | 60 BufferedResourceLoader(const GURL& url, |
58 int64 first_byte_position, | 61 int64 first_byte_position, |
59 int64 last_byte_position, | 62 int64 last_byte_position, |
| 63 DeferStrategy strategy, |
| 64 int bitrate, |
| 65 float playback_rate, |
60 media::MediaLog* media_log); | 66 media::MediaLog* media_log); |
61 | 67 |
62 // Start the resource loading with the specified URL and range. | 68 // Start the resource loading with the specified URL and range. |
63 // This method operates in asynchronous mode. Once there's a response from the | 69 // This method operates in asynchronous mode. Once there's a response from the |
64 // server, success or fail |callback| is called with the result. | 70 // server, success or fail |callback| is called with the result. |
65 // |callback| is called with the following values: | 71 // |callback| is called with the following values: |
66 // - net::OK | 72 // - net::OK |
67 // The request has started successfully. | 73 // The request has started successfully. |
68 // - net::ERR_FAILED | 74 // - net::ERR_FAILED |
69 // The request has failed because of an error with the network. | 75 // The request has failed because of an error with the network. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 166 |
161 // Sets the bitrate to the given value and updates buffer window | 167 // Sets the bitrate to the given value and updates buffer window |
162 // accordingly. | 168 // accordingly. |
163 void SetBitrate(int bitrate); | 169 void SetBitrate(int bitrate); |
164 | 170 |
165 protected: | 171 protected: |
166 friend class base::RefCountedThreadSafe<BufferedResourceLoader>; | 172 friend class base::RefCountedThreadSafe<BufferedResourceLoader>; |
167 virtual ~BufferedResourceLoader(); | 173 virtual ~BufferedResourceLoader(); |
168 | 174 |
169 private: | 175 private: |
| 176 friend class BufferedDataSourceTest2; |
170 friend class BufferedResourceLoaderTest; | 177 friend class BufferedResourceLoaderTest; |
171 | 178 |
172 // Updates the |buffer_|'s forward and backward capacities. | 179 // Updates the |buffer_|'s forward and backward capacities. |
173 void UpdateBufferWindow(); | 180 void UpdateBufferWindow(); |
174 | 181 |
175 // Toggles whether the resource loading is deferred or not. | 182 // Toggles whether the resource loading is deferred or not. |
176 // Returns true if a network event was fired. | 183 // Returns true if a network event was fired. |
177 bool ToggleDeferring(); | 184 bool ToggleDeferring(); |
178 | 185 |
179 // Returns true if we should defer resource loading, based | 186 // Returns true if we should defer resource loading, based |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 float playback_rate_; | 295 float playback_rate_; |
289 | 296 |
290 scoped_refptr<media::MediaLog> media_log_; | 297 scoped_refptr<media::MediaLog> media_log_; |
291 | 298 |
292 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader); | 299 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader); |
293 }; | 300 }; |
294 | 301 |
295 } // namespace webkit_glue | 302 } // namespace webkit_glue |
296 | 303 |
297 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_RESOURCE_LOADER_H_ | 304 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_RESOURCE_LOADER_H_ |
OLD | NEW |