| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "media/mojo/services/mojo_media_application.h" | 5 #include "media/mojo/services/media_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "media/base/media_log.h" | 9 #include "media/base/media_log.h" |
| 10 #include "media/mojo/services/mojo_media_client.h" | 10 #include "media/mojo/services/mojo_media_client.h" |
| 11 #include "media/mojo/services/service_factory_impl.h" | 11 #include "media/mojo/services/service_factory_impl.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" | 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 13 #include "services/service_manager/public/cpp/connection.h" | 13 #include "services/service_manager/public/cpp/connection.h" |
| 14 #include "services/service_manager/public/cpp/connector.h" | 14 #include "services/service_manager/public/cpp/connector.h" |
| 15 | 15 |
| 16 namespace media { | 16 namespace media { |
| 17 | 17 |
| 18 // TODO(xhwang): Hook up MediaLog when possible. | 18 // TODO(xhwang): Hook up MediaLog when possible. |
| 19 MojoMediaApplication::MojoMediaApplication( | 19 MediaService::MediaService(std::unique_ptr<MojoMediaClient> mojo_media_client, |
| 20 std::unique_ptr<MojoMediaClient> mojo_media_client, | 20 const base::Closure& quit_closure) |
| 21 const base::Closure& quit_closure) | |
| 22 : mojo_media_client_(std::move(mojo_media_client)), | 21 : mojo_media_client_(std::move(mojo_media_client)), |
| 23 media_log_(new MediaLog()), | 22 media_log_(new MediaLog()), |
| 24 ref_factory_(quit_closure) { | 23 ref_factory_(quit_closure) { |
| 25 DCHECK(mojo_media_client_); | 24 DCHECK(mojo_media_client_); |
| 26 } | 25 } |
| 27 | 26 |
| 28 MojoMediaApplication::~MojoMediaApplication() {} | 27 MediaService::~MediaService() {} |
| 29 | 28 |
| 30 void MojoMediaApplication::OnStart(const service_manager::Identity& identity) { | 29 void MediaService::OnStart(const service_manager::Identity& identity) { |
| 31 mojo_media_client_->Initialize(); | 30 mojo_media_client_->Initialize(); |
| 32 } | 31 } |
| 33 | 32 |
| 34 bool MojoMediaApplication::OnConnect( | 33 bool MediaService::OnConnect(const service_manager::Identity& remote_identity, |
| 35 const service_manager::Identity& remote_identity, | 34 service_manager::InterfaceRegistry* registry) { |
| 36 service_manager::InterfaceRegistry* registry) { | |
| 37 registry->AddInterface<mojom::MediaService>(this); | 35 registry->AddInterface<mojom::MediaService>(this); |
| 38 return true; | 36 return true; |
| 39 } | 37 } |
| 40 | 38 |
| 41 bool MojoMediaApplication::OnStop() { | 39 bool MediaService::OnStop() { |
| 42 mojo_media_client_.reset(); | 40 mojo_media_client_.reset(); |
| 43 return true; | 41 return true; |
| 44 } | 42 } |
| 45 | 43 |
| 46 void MojoMediaApplication::Create( | 44 void MediaService::Create(const service_manager::Identity& remote_identity, |
| 47 const service_manager::Identity& remote_identity, | 45 mojom::MediaServiceRequest request) { |
| 48 mojom::MediaServiceRequest request) { | |
| 49 bindings_.AddBinding(this, std::move(request)); | 46 bindings_.AddBinding(this, std::move(request)); |
| 50 } | 47 } |
| 51 | 48 |
| 52 void MojoMediaApplication::CreateServiceFactory( | 49 void MediaService::CreateServiceFactory( |
| 53 mojom::ServiceFactoryRequest request, | 50 mojom::ServiceFactoryRequest request, |
| 54 service_manager::mojom::InterfaceProviderPtr remote_interfaces) { | 51 service_manager::mojom::InterfaceProviderPtr remote_interfaces) { |
| 55 // Ignore request if service has already stopped. | 52 // Ignore request if service has already stopped. |
| 56 if (!mojo_media_client_) | 53 if (!mojo_media_client_) |
| 57 return; | 54 return; |
| 58 | 55 |
| 59 mojo::MakeStrongBinding( | 56 mojo::MakeStrongBinding( |
| 60 base::MakeUnique<ServiceFactoryImpl>(std::move(remote_interfaces), | 57 base::MakeUnique<ServiceFactoryImpl>(std::move(remote_interfaces), |
| 61 media_log_, ref_factory_.CreateRef(), | 58 media_log_, ref_factory_.CreateRef(), |
| 62 mojo_media_client_.get()), | 59 mojo_media_client_.get()), |
| 63 std::move(request)); | 60 std::move(request)); |
| 64 } | 61 } |
| 65 | 62 |
| 66 } // namespace media | 63 } // namespace media |
| OLD | NEW |