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

Unified Diff: chromecast/browser/media/cast_mojo_media_application.cc

Issue 1854893002: [chromecast] Bind and run mojo media services on cma thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments 2 Created 4 years, 8 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
« no previous file with comments | « chromecast/browser/media/cast_mojo_media_application.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromecast/browser/media/cast_mojo_media_application.cc
diff --git a/chromecast/browser/media/cast_mojo_media_application.cc b/chromecast/browser/media/cast_mojo_media_application.cc
new file mode 100644
index 0000000000000000000000000000000000000000..342a7183880f4c3469730c87b25af4bd3ab6d040
--- /dev/null
+++ b/chromecast/browser/media/cast_mojo_media_application.cc
@@ -0,0 +1,68 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chromecast/browser/media/cast_mojo_media_application.h"
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "chromecast/browser/media/cast_mojo_media_client.h"
+#include "media/base/media_log.h"
+#include "media/mojo/services/service_factory_impl.h"
+#include "mojo/shell/public/cpp/connection.h"
+
+namespace {
+void CreateServiceFactory(
+ mojo::InterfaceRequest<media::interfaces::ServiceFactory> request,
+ mojo::shell::mojom::InterfaceProvider* interfaces,
+ scoped_refptr<media::MediaLog> media_log,
+ scoped_ptr<mojo::MessageLoopRef> app_refcount,
+ media::MojoMediaClient* mojo_media_client) {
+ new ::media::ServiceFactoryImpl(std::move(request), interfaces,
+ std::move(media_log), std::move(app_refcount),
+ mojo_media_client);
+}
+} // namespace
+
+namespace chromecast {
+namespace media {
+
+CastMojoMediaApplication::CastMojoMediaApplication(
+ scoped_ptr<CastMojoMediaClient> mojo_media_client,
+ scoped_refptr<base::SingleThreadTaskRunner> media_task_runner)
+ : mojo_media_client_(std::move(mojo_media_client)),
+ media_task_runner_(media_task_runner),
+ media_log_(new ::media::MediaLog()) {
+ DCHECK(mojo_media_client_);
+ DCHECK(media_task_runner_);
+}
+
+CastMojoMediaApplication::~CastMojoMediaApplication() {}
+
+void CastMojoMediaApplication::Initialize(mojo::Connector* connector,
+ const mojo::Identity& identity,
+ uint32_t /* id */) {}
+
+bool CastMojoMediaApplication::AcceptConnection(mojo::Connection* connection) {
+ connection->AddInterface<::media::interfaces::ServiceFactory>(this);
+ return true;
+}
+
+void CastMojoMediaApplication::Create(
+ mojo::Connection* connection,
+ mojo::InterfaceRequest<::media::interfaces::ServiceFactory> request) {
+ // Create the app refcount here on the application task runner so that
+ // 1. It is bound to the application task runner, which in turn will
+ // stop the app message loop when destroyed on the app task runner.
+ // 2. It will prevent CastMojoMediaApplication from getting destroyed until
+ // the task posted to the media thread is run.
+ scoped_ptr<mojo::MessageLoopRef> app_refcount = ref_factory_.CreateRef();
+ media_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&CreateServiceFactory, base::Passed(&request),
+ connection->GetRemoteInterfaces(), media_log_,
+ base::Passed(&app_refcount), mojo_media_client_.get()));
+}
+
+} // namespace media
+} // namespace chromecast
« no previous file with comments | « chromecast/browser/media/cast_mojo_media_application.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698