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

Unified Diff: content/renderer/media/android/stream_texture_factory.cc

Issue 2192823004: Update StreamTextureProxy to accept a base::Closure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/android/stream_texture_factory.cc
diff --git a/content/renderer/media/android/stream_texture_factory.cc b/content/renderer/media/android/stream_texture_factory.cc
index 2408fa1910bf94b8334850a9744e9a13b13b7994..df409514f4f9cdebcea8cf4a24c29b7c84a68fad 100644
--- a/content/renderer/media/android/stream_texture_factory.cc
+++ b/content/renderer/media/android/stream_texture_factory.cc
@@ -15,50 +15,47 @@
namespace content {
-StreamTextureProxy::StreamTextureProxy(StreamTextureHost* host)
- : host_(host), client_(NULL) {}
+StreamTextureProxy::StreamTextureProxy(StreamTextureHost* host) : host_(host) {}
StreamTextureProxy::~StreamTextureProxy() {}
void StreamTextureProxy::Release() {
{
- // Cannot call into |client_| anymore (from any thread) after returning
- // from here.
+ // Cannot call |received_frame_cb_| after returning from here.
base::AutoLock lock(lock_);
- client_ = NULL;
+ received_frame_cb_.Reset();
}
// Release is analogous to the destructor, so there should be no more external
// calls to this object in Release. Therefore there is no need to acquire the
- // lock to access |loop_|.
- if (!loop_.get() || loop_->BelongsToCurrentThread() ||
- !loop_->DeleteSoon(FROM_HERE, this)) {
+ // lock to access |task_runner_|.
+ if (!task_runner_.get() || task_runner_->BelongsToCurrentThread() ||
+ !task_runner_->DeleteSoon(FROM_HERE, this)) {
delete this;
}
}
-void StreamTextureProxy::BindToLoop(
+void StreamTextureProxy::BindToTaskRunner(
int32_t stream_id,
- cc::VideoFrameProvider::Client* client,
- scoped_refptr<base::SingleThreadTaskRunner> loop) {
- DCHECK(loop.get());
+ const base::Closure& received_frame_cb,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
+ DCHECK(task_runner.get());
{
base::AutoLock lock(lock_);
- DCHECK(!loop_.get() || (loop.get() == loop_.get()));
- loop_ = loop;
- client_ = client;
+ DCHECK(!task_runner_.get() || (task_runner.get() == task_runner_.get()));
+ task_runner_ = task_runner;
+ received_frame_cb_ = received_frame_cb;
}
- if (loop->BelongsToCurrentThread()) {
+ if (task_runner->BelongsToCurrentThread()) {
BindOnThread(stream_id);
return;
}
// Unretained is safe here only because the object is deleted on |loop_|
// thread.
- loop->PostTask(FROM_HERE,
- base::Bind(&StreamTextureProxy::BindOnThread,
- base::Unretained(this),
- stream_id));
+ task_runner->PostTask(FROM_HERE,
+ base::Bind(&StreamTextureProxy::BindOnThread,
+ base::Unretained(this), stream_id));
}
void StreamTextureProxy::BindOnThread(int32_t stream_id) {
@@ -67,8 +64,8 @@ void StreamTextureProxy::BindOnThread(int32_t stream_id) {
void StreamTextureProxy::OnFrameAvailable() {
base::AutoLock lock(lock_);
- if (client_)
- client_->DidReceiveFrame();
+ if (!received_frame_cb_.is_null())
+ received_frame_cb_.Run();
}
// static
« no previous file with comments | « content/renderer/media/android/stream_texture_factory.h ('k') | content/renderer/media/android/stream_texture_wrapper_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698