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

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

Issue 495353003: Move WebMediaPlayerImpl and its dependencies to media/blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 3 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
« no previous file with comments | « media/blink/buffered_data_source_unittest.cc ('k') | media/blink/buffered_resource_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CONTENT_RENDERER_MEDIA_BUFFERED_RESOURCE_LOADER_H_ 5 #ifndef MEDIA_BLINK_BUFFERED_RESOURCE_LOADER_H_
6 #define CONTENT_RENDERER_MEDIA_BUFFERED_RESOURCE_LOADER_H_ 6 #define MEDIA_BLINK_BUFFERED_RESOURCE_LOADER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "content/common/content_export.h" 13 #include "media/base/media_export.h"
14 #include "content/renderer/media/active_loader.h"
15 #include "media/base/seekable_buffer.h" 14 #include "media/base/seekable_buffer.h"
15 #include "media/blink/active_loader.h"
16 #include "third_party/WebKit/public/platform/WebURLLoader.h" 16 #include "third_party/WebKit/public/platform/WebURLLoader.h"
17 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 17 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
18 #include "third_party/WebKit/public/platform/WebURLRequest.h" 18 #include "third_party/WebKit/public/platform/WebURLRequest.h"
19 #include "third_party/WebKit/public/web/WebFrame.h" 19 #include "third_party/WebKit/public/web/WebFrame.h"
20 #include "url/gurl.h" 20 #include "url/gurl.h"
21 21
22 namespace media { 22 namespace media {
23 class MediaLog; 23 class MediaLog;
24 class SeekableBuffer; 24 class SeekableBuffer;
25 }
26
27 namespace content {
28 25
29 const int64 kPositionNotSpecified = -1; 26 const int64 kPositionNotSpecified = -1;
30 27
31 // BufferedResourceLoader is single threaded and must be accessed on the 28 // BufferedResourceLoader is single threaded and must be accessed on the
32 // render thread. It wraps a WebURLLoader and does in-memory buffering, 29 // render thread. It wraps a WebURLLoader and does in-memory buffering,
33 // pausing resource loading when the in-memory buffer is full and resuming 30 // pausing resource loading when the in-memory buffer is full and resuming
34 // resource loading when there is available capacity. 31 // resource loading when there is available capacity.
35 class CONTENT_EXPORT BufferedResourceLoader 32 class MEDIA_EXPORT BufferedResourceLoader
36 : NON_EXPORTED_BASE(public blink::WebURLLoaderClient) { 33 : NON_EXPORTED_BASE(public blink::WebURLLoaderClient) {
37 public: 34 public:
38 // kNeverDefer - Aggresively buffer; never defer loading while paused. 35 // kNeverDefer - Aggresively buffer; never defer loading while paused.
39 // kReadThenDefer - Request only enough data to fulfill read requests. 36 // kReadThenDefer - Request only enough data to fulfill read requests.
40 // kCapacityDefer - Try to keep amount of buffered data at capacity. 37 // kCapacityDefer - Try to keep amount of buffered data at capacity.
41 enum DeferStrategy { 38 enum DeferStrategy {
42 kNeverDefer, 39 kNeverDefer,
43 kReadThenDefer, 40 kReadThenDefer,
44 kCapacityDefer, 41 kCapacityDefer,
45 }; 42 };
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // |bitrate| is the bitrate of the media, 0 if unknown. 80 // |bitrate| is the bitrate of the media, 0 if unknown.
84 // |playback_rate| is the current playback rate of the media. 81 // |playback_rate| is the current playback rate of the media.
85 BufferedResourceLoader( 82 BufferedResourceLoader(
86 const GURL& url, 83 const GURL& url,
87 CORSMode cors_mode, 84 CORSMode cors_mode,
88 int64 first_byte_position, 85 int64 first_byte_position,
89 int64 last_byte_position, 86 int64 last_byte_position,
90 DeferStrategy strategy, 87 DeferStrategy strategy,
91 int bitrate, 88 int bitrate,
92 float playback_rate, 89 float playback_rate,
93 media::MediaLog* media_log); 90 MediaLog* media_log);
94 virtual ~BufferedResourceLoader(); 91 virtual ~BufferedResourceLoader();
95 92
96 // Start the resource loading with the specified URL and range. 93 // Start the resource loading with the specified URL and range.
97 // 94 //
98 // |loading_cb| is executed when the loading state has changed. 95 // |loading_cb| is executed when the loading state has changed.
99 // |progress_cb| is executed when additional data has arrived. 96 // |progress_cb| is executed when additional data has arrived.
100 typedef base::Callback<void(Status)> StartCB; 97 typedef base::Callback<void(Status)> StartCB;
101 typedef base::Callback<void(LoadingState)> LoadingStateChangedCB; 98 typedef base::Callback<void(LoadingState)> LoadingStateChangedCB;
102 typedef base::Callback<void(int64)> ProgressCB; 99 typedef base::Callback<void(int64)> ProgressCB;
103 void Start(const StartCB& start_cb, 100 void Start(const StartCB& start_cb,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 241
245 bool HasPendingRead() { return !read_cb_.is_null(); } 242 bool HasPendingRead() { return !read_cb_.is_null(); }
246 243
247 // Helper function that returns true if a range request was specified. 244 // Helper function that returns true if a range request was specified.
248 bool IsRangeRequest() const; 245 bool IsRangeRequest() const;
249 246
250 // Log everything interesting to |media_log_|. 247 // Log everything interesting to |media_log_|.
251 void Log(); 248 void Log();
252 249
253 // A sliding window of buffer. 250 // A sliding window of buffer.
254 media::SeekableBuffer buffer_; 251 SeekableBuffer buffer_;
255 252
256 // Keeps track of an active WebURLLoader and associated state. 253 // Keeps track of an active WebURLLoader and associated state.
257 scoped_ptr<ActiveLoader> active_loader_; 254 scoped_ptr<ActiveLoader> active_loader_;
258 255
259 // Tracks if |active_loader_| failed. If so, then all calls to Read() will 256 // Tracks if |active_loader_| failed. If so, then all calls to Read() will
260 // fail. 257 // fail.
261 bool loader_failed_; 258 bool loader_failed_;
262 259
263 // Current buffering algorithm in place for resource loading. 260 // Current buffering algorithm in place for resource loading.
264 DeferStrategy defer_strategy_; 261 DeferStrategy defer_strategy_;
265 262
266 // True if the currently-reading response might be used to satisfy a future 263 // True if the currently-reading response might be used to satisfy a future
267 // request from the cache. 264 // request from the cache.
268 bool might_be_reused_from_cache_in_future_; 265 bool might_be_reused_from_cache_in_future_;
269 266
270 // True if Range header is supported. 267 // True if Range header is supported.
271 bool range_supported_; 268 bool range_supported_;
272 269
273 // Forward capacity to reset to after an extension. 270 // Forward capacity to reset to after an extension.
274 size_t saved_forward_capacity_; 271 int saved_forward_capacity_;
275 272
276 GURL url_; 273 GURL url_;
277 CORSMode cors_mode_; 274 CORSMode cors_mode_;
278 const int64 first_byte_position_; 275 const int64 first_byte_position_;
279 const int64 last_byte_position_; 276 const int64 last_byte_position_;
280 bool single_origin_; 277 bool single_origin_;
281 278
282 // Executed whenever the state of resource loading has changed. 279 // Executed whenever the state of resource loading has changed.
283 LoadingStateChangedCB loading_cb_; 280 LoadingStateChangedCB loading_cb_;
284 281
(...skipping 21 matching lines...) Expand all
306 303
307 // Injected WebURLLoader instance for testing purposes. 304 // Injected WebURLLoader instance for testing purposes.
308 scoped_ptr<blink::WebURLLoader> test_loader_; 305 scoped_ptr<blink::WebURLLoader> test_loader_;
309 306
310 // Bitrate of the media. Set to 0 if unknown. 307 // Bitrate of the media. Set to 0 if unknown.
311 int bitrate_; 308 int bitrate_;
312 309
313 // Playback rate of the media. 310 // Playback rate of the media.
314 float playback_rate_; 311 float playback_rate_;
315 312
316 scoped_refptr<media::MediaLog> media_log_; 313 scoped_refptr<MediaLog> media_log_;
317 314
318 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader); 315 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader);
319 }; 316 };
320 317
321 } // namespace content 318 } // namespace media
322 319
323 #endif // CONTENT_RENDERER_MEDIA_BUFFERED_RESOURCE_LOADER_H_ 320 #endif // MEDIA_BLINK_BUFFERED_RESOURCE_LOADER_H_
OLDNEW
« no previous file with comments | « media/blink/buffered_data_source_unittest.cc ('k') | media/blink/buffered_resource_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698