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

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

Issue 2272163002: Delete now deprecated BufferedDataSource and friends. (Closed)
Patch Set: Delete BufferedResourceLoader too. Created 4 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
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 MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_ 5 #ifndef MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_
6 #define MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_ 6 #define MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/linked_ptr.h" 16 #include "base/memory/linked_ptr.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
19 #include "media/base/data_source.h" 19 #include "media/base/data_source.h"
20 #include "media/base/ranges.h" 20 #include "media/base/ranges.h"
21 #include "media/blink/buffered_data_source.h"
22 #include "media/blink/media_blink_export.h" 21 #include "media/blink/media_blink_export.h"
23 #include "media/blink/url_index.h" 22 #include "media/blink/url_index.h"
24 #include "url/gurl.h" 23 #include "url/gurl.h"
25 24
26 namespace base { 25 namespace base {
27 class SingleThreadTaskRunner; 26 class SingleThreadTaskRunner;
28 } 27 }
29 28
30 namespace media { 29 namespace media {
30 class BufferedDataSourceHost;
31 class MediaLog; 31 class MediaLog;
32 class MultiBufferReader; 32 class MultiBufferReader;
33 33
34 // A data source capable of loading URLs and buffering the data using an 34 // A data source capable of loading URLs and buffering the data using an
35 // in-memory sliding window. 35 // in-memory sliding window.
36 // 36 //
37 // MultibufferDataSource must be created and destroyed on the thread associated 37 // MultibufferDataSource must be created and destroyed on the thread associated
38 // with the |task_runner| passed in the constructor. 38 // with the |task_runner| passed in the constructor.
39 class MEDIA_BLINK_EXPORT MultibufferDataSource 39 class MEDIA_BLINK_EXPORT MultibufferDataSource : public DataSource {
40 : NON_EXPORTED_BASE(public BufferedDataSourceInterface) {
41 public: 40 public:
42 typedef base::Callback<void(bool)> DownloadingCB; 41 typedef base::Callback<void(bool)> DownloadingCB;
43 42
43 // Used to specify video preload states. They are "hints" to the browser about
44 // how aggressively the browser should load and buffer data.
45 // Please see the HTML5 spec for the descriptions of these values:
46 // http://www.w3.org/TR/html5/video.html#attr-media-preload
47 //
48 // Enum values must match the values in blink::WebMediaPlayer::Preload and
49 // there will be assertions at compile time if they do not match.
50 enum Preload {
51 NONE,
52 METADATA,
53 AUTO,
54 };
55
56 // Enum values must match the values in
57 // blink::WebMediaPlayer::BufferingStrategy and there will be assertions at
58 // compile time if they do not match.
59 enum BufferingStrategy {
60 BUFFERING_STRATEGY_NORMAL,
61 BUFFERING_STRATEGY_AGGRESSIVE,
62 };
63
44 // |url| and |cors_mode| are passed to the object. Buffered byte range changes 64 // |url| and |cors_mode| are passed to the object. Buffered byte range changes
45 // will be reported to |host|. |downloading_cb| will be called whenever the 65 // will be reported to |host|. |downloading_cb| will be called whenever the
46 // downloading/paused state of the source changes. 66 // downloading/paused state of the source changes.
47 MultibufferDataSource( 67 MultibufferDataSource(
48 const GURL& url, 68 const GURL& url,
49 UrlData::CORSMode cors_mode, 69 UrlData::CORSMode cors_mode,
50 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 70 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
51 linked_ptr<UrlIndex> url_index, 71 linked_ptr<UrlIndex> url_index,
52 blink::WebFrame* frame, 72 blink::WebFrame* frame,
53 MediaLog* media_log, 73 MediaLog* media_log,
54 BufferedDataSourceHost* host, 74 BufferedDataSourceHost* host,
55 const DownloadingCB& downloading_cb); 75 const DownloadingCB& downloading_cb);
56 ~MultibufferDataSource() override; 76 ~MultibufferDataSource() override;
57 77
58 // Executes |init_cb| with the result of initialization when it has completed. 78 // Executes |init_cb| with the result of initialization when it has completed.
59 // 79 //
60 // Method called on the render thread. 80 // Method called on the render thread.
61 void Initialize(const InitializeCB& init_cb) override; 81 typedef base::Callback<void(bool)> InitializeCB;
82 void Initialize(const InitializeCB& init_cb);
62 83
63 // Adjusts the buffering algorithm based on the given preload value. 84 // Adjusts the buffering algorithm based on the given preload value.
64 void SetPreload(Preload preload) override; 85 void SetPreload(Preload preload);
65 86
66 // Adjusts the buffering algorithm based on the given buffering strategy 87 // Adjusts the buffering algorithm based on the given buffering strategy
67 // value. 88 // value.
68 void SetBufferingStrategy(BufferingStrategy buffering_strategy) override; 89 void SetBufferingStrategy(BufferingStrategy buffering_strategy);
69 90
70 // Returns true if the media resource has a single origin, false otherwise. 91 // Returns true if the media resource has a single origin, false otherwise.
71 // Only valid to call after Initialize() has completed. 92 // Only valid to call after Initialize() has completed.
72 // 93 //
73 // Method called on the render thread. 94 // Method called on the render thread.
74 bool HasSingleOrigin() override; 95 bool HasSingleOrigin();
75 96
76 // Returns true if the media resource passed a CORS access control check. 97 // Returns true if the media resource passed a CORS access control check.
77 bool DidPassCORSAccessCheck() const override; 98 bool DidPassCORSAccessCheck() const;
78 99
79 // Cancels initialization, any pending loaders, and any pending read calls 100 // Cancels initialization, any pending loaders, and any pending read calls
80 // from the demuxer. The caller is expected to release its reference to this 101 // from the demuxer. The caller is expected to release its reference to this
81 // object and never call it again. 102 // object and never call it again.
82 // 103 //
83 // Method called on the render thread. 104 // Method called on the render thread.
84 void Abort() override; 105 void Abort();
85 106
86 // Notifies changes in playback state for controlling media buffering 107 // Notifies changes in playback state for controlling media buffering
87 // behavior. 108 // behavior.
88 void MediaPlaybackRateChanged(double playback_rate) override; 109 void MediaPlaybackRateChanged(double playback_rate);
89 void MediaIsPlaying() override; 110 void MediaIsPlaying();
90 bool media_has_played() const override; 111 bool media_has_played() const;
91 112
92 // Returns true if the resource is local. 113 // Returns true if the resource is local.
93 bool assume_fully_buffered() override; 114 bool assume_fully_buffered();
94 115
95 // Cancels any open network connections once reaching the deferred state. If 116 // Cancels any open network connections once reaching the deferred state. If
96 // |always_cancel| is false this is done only for preload=metadata, non- 117 // |always_cancel| is false this is done only for preload=metadata, non-
97 // streaming resources that have not started playback. If |always_cancel| is 118 // streaming resources that have not started playback. If |always_cancel| is
98 // true, all resource types will have their connections canceled. If already 119 // true, all resource types will have their connections canceled. If already
99 // deferred, connections will be immediately closed. 120 // deferred, connections will be immediately closed.
100 void OnBufferingHaveEnough(bool always_cancel) override; 121 void OnBufferingHaveEnough(bool always_cancel);
101 122
102 int64_t GetMemoryUsage() const override; 123 int64_t GetMemoryUsage() const;
103 124
104 GURL GetUrlAfterRedirects() const override; 125 GURL GetUrlAfterRedirects() const;
105 126
106 // DataSource implementation. 127 // DataSource implementation.
107 // Called from demuxer thread. 128 // Called from demuxer thread.
108 void Stop() override; 129 void Stop() override;
109 130
110 void Read(int64_t position, 131 void Read(int64_t position,
111 int size, 132 int size,
112 uint8_t* data, 133 uint8_t* data,
113 const DataSource::ReadCB& read_cb) override; 134 const DataSource::ReadCB& read_cb) override;
114 bool GetSize(int64_t* size_out) override; 135 bool GetSize(int64_t* size_out) override;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // reaching into this class from multiple threads to attain a WeakPtr. 265 // reaching into this class from multiple threads to attain a WeakPtr.
245 base::WeakPtr<MultibufferDataSource> weak_ptr_; 266 base::WeakPtr<MultibufferDataSource> weak_ptr_;
246 base::WeakPtrFactory<MultibufferDataSource> weak_factory_; 267 base::WeakPtrFactory<MultibufferDataSource> weak_factory_;
247 268
248 DISALLOW_COPY_AND_ASSIGN(MultibufferDataSource); 269 DISALLOW_COPY_AND_ASSIGN(MultibufferDataSource);
249 }; 270 };
250 271
251 } // namespace media 272 } // namespace media
252 273
253 #endif // MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_ 274 #endif // MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_
OLDNEW
« no previous file with comments | « media/blink/buffered_resource_loader_unittest.cc ('k') | media/blink/multibuffer_data_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698