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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « chromecast/browser/media/cast_mojo_media_application.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chromecast/browser/media/cast_mojo_media_application.h"
6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "chromecast/browser/media/cast_mojo_media_client.h"
10 #include "media/base/media_log.h"
11 #include "media/mojo/services/service_factory_impl.h"
12 #include "mojo/shell/public/cpp/connection.h"
13
14 namespace {
15 void CreateServiceFactory(
16 mojo::InterfaceRequest<media::interfaces::ServiceFactory> request,
17 mojo::shell::mojom::InterfaceProvider* interfaces,
18 scoped_refptr<media::MediaLog> media_log,
19 scoped_ptr<mojo::MessageLoopRef> app_refcount,
20 media::MojoMediaClient* mojo_media_client) {
21 new ::media::ServiceFactoryImpl(std::move(request), interfaces,
22 std::move(media_log), std::move(app_refcount),
23 mojo_media_client);
24 }
25 } // namespace
26
27 namespace chromecast {
28 namespace media {
29
30 CastMojoMediaApplication::CastMojoMediaApplication(
31 scoped_ptr<CastMojoMediaClient> mojo_media_client,
32 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner)
33 : mojo_media_client_(std::move(mojo_media_client)),
34 media_task_runner_(media_task_runner),
35 media_log_(new ::media::MediaLog()) {
36 DCHECK(mojo_media_client_);
37 DCHECK(media_task_runner_);
38 }
39
40 CastMojoMediaApplication::~CastMojoMediaApplication() {}
41
42 void CastMojoMediaApplication::Initialize(mojo::Connector* connector,
43 const mojo::Identity& identity,
44 uint32_t /* id */) {}
45
46 bool CastMojoMediaApplication::AcceptConnection(mojo::Connection* connection) {
47 connection->AddInterface<::media::interfaces::ServiceFactory>(this);
48 return true;
49 }
50
51 void CastMojoMediaApplication::Create(
52 mojo::Connection* connection,
53 mojo::InterfaceRequest<::media::interfaces::ServiceFactory> request) {
54 // Create the app refcount here on the application task runner so that
55 // 1. It is bound to the application task runner, which in turn will
56 // stop the app message loop when destroyed on the app task runner.
57 // 2. It will prevent CastMojoMediaApplication from getting destroyed until
58 // the task posted to the media thread is run.
59 scoped_ptr<mojo::MessageLoopRef> app_refcount = ref_factory_.CreateRef();
60 media_task_runner_->PostTask(
61 FROM_HERE,
62 base::Bind(&CreateServiceFactory, base::Passed(&request),
63 connection->GetRemoteInterfaces(), media_log_,
64 base::Passed(&app_refcount), mojo_media_client_.get()));
65 }
66
67 } // namespace media
68 } // namespace chromecast
OLDNEW
« 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