OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 <memory> | 5 #include <memory> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "mash/public/interfaces/launchable.mojom.h" | 10 #include "mash/public/interfaces/launchable.mojom.h" |
11 #include "mojo/public/cpp/bindings/binding_set.h" | 11 #include "mojo/public/cpp/bindings/binding_set.h" |
12 #include "services/service_manager/public/c/main.h" | 12 #include "services/service_manager/public/c/main.h" |
13 #include "services/service_manager/public/cpp/binder_registry.h" | 13 #include "services/service_manager/public/cpp/binder_registry.h" |
14 #include "services/service_manager/public/cpp/connector.h" | 14 #include "services/service_manager/public/cpp/connector.h" |
15 #include "services/service_manager/public/cpp/interface_factory.h" | 15 #include "services/service_manager/public/cpp/interface_factory.h" |
16 #include "services/service_manager/public/cpp/service.h" | 16 #include "services/service_manager/public/cpp/service.h" |
17 #include "services/service_manager/public/cpp/service_context.h" | 17 #include "services/service_manager/public/cpp/service_context.h" |
18 #include "services/service_manager/public/cpp/service_runner.h" | 18 #include "services/service_manager/public/cpp/service_runner.h" |
19 #include "services/tracing/public/cpp/provider.h" | |
20 #include "ui/views/examples/example_base.h" | 19 #include "ui/views/examples/example_base.h" |
21 #include "ui/views/examples/examples_window.h" | 20 #include "ui/views/examples/examples_window.h" |
22 #include "ui/views/mus/aura_init.h" | 21 #include "ui/views/mus/aura_init.h" |
23 | 22 |
24 class ViewsExamples | 23 class ViewsExamples |
25 : public service_manager::Service, | 24 : public service_manager::Service, |
26 public mash::mojom::Launchable, | 25 public mash::mojom::Launchable, |
27 public service_manager::InterfaceFactory<mash::mojom::Launchable> { | 26 public service_manager::InterfaceFactory<mash::mojom::Launchable> { |
28 public: | 27 public: |
29 ViewsExamples() { | 28 ViewsExamples() { |
30 registry_.AddInterface<mash::mojom::Launchable>(this); | 29 registry_.AddInterface<mash::mojom::Launchable>(this); |
31 } | 30 } |
32 ~ViewsExamples() override {} | 31 ~ViewsExamples() override {} |
33 | 32 |
34 private: | 33 private: |
35 // service_manager::Service: | 34 // service_manager::Service: |
36 void OnStart() override { | 35 void OnStart() override { |
37 tracing_.Initialize(context()->connector(), context()->identity().name()); | |
38 aura_init_ = base::MakeUnique<views::AuraInit>( | 36 aura_init_ = base::MakeUnique<views::AuraInit>( |
39 context()->connector(), context()->identity(), | 37 context()->connector(), context()->identity(), |
40 "views_mus_resources.pak", std::string(), nullptr, | 38 "views_mus_resources.pak", std::string(), nullptr, |
41 views::AuraInit::Mode::AURA_MUS); | 39 views::AuraInit::Mode::AURA_MUS); |
42 } | 40 } |
43 void OnBindInterface(const service_manager::ServiceInfo& source_info, | 41 void OnBindInterface(const service_manager::ServiceInfo& source_info, |
44 const std::string& interface_name, | 42 const std::string& interface_name, |
45 mojo::ScopedMessagePipeHandle interface_pipe) override { | 43 mojo::ScopedMessagePipeHandle interface_pipe) override { |
46 registry_.BindInterface(source_info.identity, interface_name, | 44 registry_.BindInterface(source_info.identity, interface_name, |
47 std::move(interface_pipe)); | 45 std::move(interface_pipe)); |
48 } | 46 } |
49 | 47 |
50 // mash::mojom::Launchable: | 48 // mash::mojom::Launchable: |
51 void Launch(uint32_t what, mash::mojom::LaunchMode how) override { | 49 void Launch(uint32_t what, mash::mojom::LaunchMode how) override { |
52 views::examples::ShowExamplesWindow(views::examples::QUIT_ON_CLOSE); | 50 views::examples::ShowExamplesWindow(views::examples::QUIT_ON_CLOSE); |
53 } | 51 } |
54 | 52 |
55 // service_manager::InterfaceFactory<mash::mojom::Launchable>: | 53 // service_manager::InterfaceFactory<mash::mojom::Launchable>: |
56 void Create(const service_manager::Identity& remote_identity, | 54 void Create(const service_manager::Identity& remote_identity, |
57 mash::mojom::LaunchableRequest request) override { | 55 mash::mojom::LaunchableRequest request) override { |
58 bindings_.AddBinding(this, std::move(request)); | 56 bindings_.AddBinding(this, std::move(request)); |
59 } | 57 } |
60 | 58 |
61 mojo::BindingSet<mash::mojom::Launchable> bindings_; | 59 mojo::BindingSet<mash::mojom::Launchable> bindings_; |
62 | 60 |
63 service_manager::BinderRegistry registry_; | 61 service_manager::BinderRegistry registry_; |
64 | 62 |
65 tracing::Provider tracing_; | |
66 std::unique_ptr<views::AuraInit> aura_init_; | 63 std::unique_ptr<views::AuraInit> aura_init_; |
67 | 64 |
68 DISALLOW_COPY_AND_ASSIGN(ViewsExamples); | 65 DISALLOW_COPY_AND_ASSIGN(ViewsExamples); |
69 }; | 66 }; |
70 | 67 |
71 MojoResult ServiceMain(MojoHandle service_request_handle) { | 68 MojoResult ServiceMain(MojoHandle service_request_handle) { |
72 return service_manager::ServiceRunner(new ViewsExamples) | 69 return service_manager::ServiceRunner(new ViewsExamples) |
73 .Run(service_request_handle); | 70 .Run(service_request_handle); |
74 } | 71 } |
OLD | NEW |