1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
// Copyright 2014 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 "media/mojo/services/mojo_media_application.h"
#include <utility>
#include "base/logging.h"
#include "media/base/media_log.h"
#include "media/mojo/services/mojo_media_client.h"
#include "media/mojo/services/service_factory_impl.h"
#include "mojo/shell/public/cpp/application_connection.h"
#include "mojo/shell/public/cpp/application_impl.h"
namespace media {
// static
scoped_ptr<mojo::ApplicationDelegate> MojoMediaApplication::CreateApp() {
// In all existing use cases we don't need to initialize logging when using
// CreateApp() to create the application. We can pass |enable_logging| in
// CreateApp() if this isn't the case any more in the future.
return scoped_ptr<mojo::ApplicationDelegate>(
new MojoMediaApplication(false, MojoMediaClient::Create()));
}
// TODO(xhwang): Hook up MediaLog when possible.
MojoMediaApplication::MojoMediaApplication(
bool enable_logging,
scoped_ptr<MojoMediaClient> mojo_media_client)
: enable_logging_(enable_logging),
mojo_media_client_(std::move(mojo_media_client)),
app_impl_(nullptr),
media_log_(new MediaLog()) {}
MojoMediaApplication::~MojoMediaApplication() {
}
void MojoMediaApplication::Initialize(mojo::ApplicationImpl* app) {
app_impl_ = app;
if (enable_logging_) {
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
logging::InitLogging(settings);
// Display process ID, thread ID and timestamp in logs.
logging::SetLogItems(true, true, true, false);
}
mojo_media_client_->Initialize();
}
bool MojoMediaApplication::ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) {
connection->AddService<interfaces::ServiceFactory>(this);
return true;
}
void MojoMediaApplication::Create(
mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<interfaces::ServiceFactory> request) {
// The created object is owned by the pipe.
new ServiceFactoryImpl(std::move(request), connection->GetServiceProvider(),
media_log_,
app_impl_->app_lifetime_helper()->CreateAppRefCount(),
mojo_media_client_.get());
}
} // namespace media
|