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

Side by Side Diff: content/renderer/media/buffered_data_source.h

Issue 508293003: Change media MessageLoopProxy usage to SingleThreadTaskRunners. (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
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_DATA_SOURCE_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_BUFFERED_DATA_SOURCE_H_
6 #define CONTENT_RENDERER_MEDIA_BUFFERED_DATA_SOURCE_H_ 6 #define CONTENT_RENDERER_MEDIA_BUFFERED_DATA_SOURCE_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/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "content/renderer/media/buffered_resource_loader.h" 14 #include "content/renderer/media/buffered_resource_loader.h"
15 #include "content/renderer/media/preload.h" 15 #include "content/renderer/media/preload.h"
16 #include "media/base/data_source.h" 16 #include "media/base/data_source.h"
17 #include "media/base/ranges.h" 17 #include "media/base/ranges.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 namespace base { 20 namespace base {
21 class MessageLoopProxy; 21 class SingleThreadTaskRunner;
22 } 22 }
23 23
24 namespace media { 24 namespace media {
25 class MediaLog; 25 class MediaLog;
26 } 26 }
27 27
28 namespace content { 28 namespace content {
29 29
30 class CONTENT_EXPORT BufferedDataSourceHost { 30 class CONTENT_EXPORT BufferedDataSourceHost {
31 public: 31 public:
(...skipping 14 matching lines...) Expand all
46 // 46 //
47 // BufferedDataSource must be created and initialized on the render thread 47 // BufferedDataSource must be created and initialized on the render thread
48 // before being passed to other threads. It may be deleted on any thread. 48 // before being passed to other threads. It may be deleted on any thread.
49 class CONTENT_EXPORT BufferedDataSource : public media::DataSource { 49 class CONTENT_EXPORT BufferedDataSource : public media::DataSource {
50 public: 50 public:
51 typedef base::Callback<void(bool)> DownloadingCB; 51 typedef base::Callback<void(bool)> DownloadingCB;
52 52
53 // |url| and |cors_mode| are passed to the object. Buffered byte range changes 53 // |url| and |cors_mode| are passed to the object. Buffered byte range changes
54 // will be reported to |host|. |downloading_cb| will be called whenever the 54 // will be reported to |host|. |downloading_cb| will be called whenever the
55 // downloading/paused state of the source changes. 55 // downloading/paused state of the source changes.
56 BufferedDataSource(const GURL& url, 56 BufferedDataSource(
57 BufferedResourceLoader::CORSMode cors_mode, 57 const GURL& url,
58 const scoped_refptr<base::MessageLoopProxy>& render_loop, 58 BufferedResourceLoader::CORSMode cors_mode,
59 blink::WebFrame* frame, 59 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
60 media::MediaLog* media_log, 60 blink::WebFrame* frame,
61 BufferedDataSourceHost* host, 61 media::MediaLog* media_log,
62 const DownloadingCB& downloading_cb); 62 BufferedDataSourceHost* host,
63 const DownloadingCB& downloading_cb);
63 virtual ~BufferedDataSource(); 64 virtual ~BufferedDataSource();
64 65
65 // Executes |init_cb| with the result of initialization when it has completed. 66 // Executes |init_cb| with the result of initialization when it has completed.
66 // 67 //
67 // Method called on the render thread. 68 // Method called on the render thread.
68 typedef base::Callback<void(bool)> InitializeCB; 69 typedef base::Callback<void(bool)> InitializeCB;
69 void Initialize(const InitializeCB& init_cb); 70 void Initialize(const InitializeCB& init_cb);
70 71
71 // Adjusts the buffering algorithm based on the given preload value. 72 // Adjusts the buffering algorithm based on the given preload value.
72 void SetPreload(Preload preload); 73 void SetPreload(Preload preload);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // we don't own |read_buffer_|. But since the read operation is asynchronous, 184 // we don't own |read_buffer_|. But since the read operation is asynchronous,
184 // |read_buffer| can be destroyed at any time, so we only copy into 185 // |read_buffer| can be destroyed at any time, so we only copy into
185 // |read_buffer| in the final step when it is safe. 186 // |read_buffer| in the final step when it is safe.
186 // Memory is allocated for this member during initialization of this object 187 // Memory is allocated for this member during initialization of this object
187 // because we want buffer to be passed into BufferedResourceLoader to be 188 // because we want buffer to be passed into BufferedResourceLoader to be
188 // always non-null. And by initializing this member with a default size we can 189 // always non-null. And by initializing this member with a default size we can
189 // avoid creating zero-sized buffered if the first read has zero size. 190 // avoid creating zero-sized buffered if the first read has zero size.
190 scoped_ptr<uint8[]> intermediate_read_buffer_; 191 scoped_ptr<uint8[]> intermediate_read_buffer_;
191 int intermediate_read_buffer_size_; 192 int intermediate_read_buffer_size_;
192 193
193 // The message loop of the render thread. 194 // The task runner of the render thread.
194 const scoped_refptr<base::MessageLoopProxy> render_loop_; 195 const scoped_refptr<base::SingleThreadTaskRunner> render_task_runner_;
195 196
196 // Protects |stop_signal_received_| and |read_op_|. 197 // Protects |stop_signal_received_| and |read_op_|.
197 base::Lock lock_; 198 base::Lock lock_;
198 199
199 // Whether we've been told to stop via Abort() or Stop(). 200 // Whether we've been told to stop via Abort() or Stop().
200 bool stop_signal_received_; 201 bool stop_signal_received_;
201 202
202 // This variable is true when the user has requested the video to play at 203 // This variable is true when the user has requested the video to play at
203 // least once. 204 // least once.
204 bool media_has_played_; 205 bool media_has_played_;
(...skipping 17 matching lines...) Expand all
222 223
223 // NOTE: Weak pointers must be invalidated before all other member variables. 224 // NOTE: Weak pointers must be invalidated before all other member variables.
224 base::WeakPtrFactory<BufferedDataSource> weak_factory_; 225 base::WeakPtrFactory<BufferedDataSource> weak_factory_;
225 226
226 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource); 227 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource);
227 }; 228 };
228 229
229 } // namespace content 230 } // namespace content
230 231
231 #endif // CONTENT_RENDERER_MEDIA_BUFFERED_DATA_SOURCE_H_ 232 #endif // CONTENT_RENDERER_MEDIA_BUFFERED_DATA_SOURCE_H_
OLDNEW
« no previous file with comments | « content/renderer/media/android/webmediaplayer_android.cc ('k') | content/renderer/media/buffered_data_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698