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

Side by Side Diff: mash/example/views_examples/views_examples.cc

Issue 2476063002: Service Manager: Rework Service and ServiceContext lifetime (Closed)
Patch Set: . Created 4 years, 1 month 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
OLDNEW
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 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "mash/public/interfaces/launchable.mojom.h" 9 #include "mash/public/interfaces/launchable.mojom.h"
10 #include "mojo/public/cpp/bindings/binding_set.h" 10 #include "mojo/public/cpp/bindings/binding_set.h"
11 #include "services/service_manager/public/c/main.h" 11 #include "services/service_manager/public/c/main.h"
12 #include "services/service_manager/public/cpp/connection.h" 12 #include "services/service_manager/public/cpp/connection.h"
13 #include "services/service_manager/public/cpp/connector.h" 13 #include "services/service_manager/public/cpp/connector.h"
14 #include "services/service_manager/public/cpp/interface_factory.h"
15 #include "services/service_manager/public/cpp/interface_registry.h"
14 #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"
15 #include "services/service_manager/public/cpp/service_runner.h" 18 #include "services/service_manager/public/cpp/service_runner.h"
16 #include "services/tracing/public/cpp/provider.h" 19 #include "services/tracing/public/cpp/provider.h"
17 #include "ui/views/examples/example_base.h" 20 #include "ui/views/examples/example_base.h"
18 #include "ui/views/examples/examples_window.h" 21 #include "ui/views/examples/examples_window.h"
19 #include "ui/views/mus/aura_init.h" 22 #include "ui/views/mus/aura_init.h"
20 #include "ui/views/mus/window_manager_connection.h" 23 #include "ui/views/mus/window_manager_connection.h"
21 24
22 namespace views { 25 namespace views {
23 class AuraInit; 26 class AuraInit;
24 class WindowManagerConnection; 27 class WindowManagerConnection;
25 } 28 }
26 29
27 class ViewsExamples 30 class ViewsExamples
28 : public service_manager::Service, 31 : public service_manager::Service,
29 public mash::mojom::Launchable, 32 public mash::mojom::Launchable,
30 public service_manager::InterfaceFactory<mash::mojom::Launchable> { 33 public service_manager::InterfaceFactory<mash::mojom::Launchable> {
31 public: 34 public:
32 ViewsExamples() {} 35 ViewsExamples() {}
33 ~ViewsExamples() override {} 36 ~ViewsExamples() override {}
34 37
35 private: 38 private:
36 // service_manager::Service: 39 // service_manager::Service:
37 void OnStart(const service_manager::ServiceInfo& info) override { 40 void OnStart(service_manager::ServiceContext* context) override {
38 tracing_.Initialize(connector(), info.identity.name()); 41 tracing_.Initialize(context->connector(), context->identity().name());
39 aura_init_ = base::MakeUnique<views::AuraInit>(connector(), info.identity, 42 aura_init_ = base::MakeUnique<views::AuraInit>(
40 "views_mus_resources.pak"); 43 context->connector(), context->identity(), "views_mus_resources.pak");
41 window_manager_connection_ = 44 window_manager_connection_ = views::WindowManagerConnection::Create(
42 views::WindowManagerConnection::Create(connector(), info.identity); 45 context->connector(), context->identity());
43 } 46 }
44 bool OnConnect(const service_manager::ServiceInfo& remote_info, 47 bool OnConnect(const service_manager::ServiceInfo& remote_info,
45 service_manager::InterfaceRegistry* registry) override { 48 service_manager::InterfaceRegistry* registry) override {
46 registry->AddInterface<mash::mojom::Launchable>(this); 49 registry->AddInterface<mash::mojom::Launchable>(this);
47 return true; 50 return true;
48 } 51 }
49 52
50 // mash::mojom::Launchable: 53 // mash::mojom::Launchable:
51 void Launch(uint32_t what, mash::mojom::LaunchMode how) override { 54 void Launch(uint32_t what, mash::mojom::LaunchMode how) override {
52 views::examples::ShowExamplesWindow(views::examples::QUIT_ON_CLOSE, 55 views::examples::ShowExamplesWindow(views::examples::QUIT_ON_CLOSE,
(...skipping 12 matching lines...) Expand all
65 std::unique_ptr<views::AuraInit> aura_init_; 68 std::unique_ptr<views::AuraInit> aura_init_;
66 std::unique_ptr<views::WindowManagerConnection> window_manager_connection_; 69 std::unique_ptr<views::WindowManagerConnection> window_manager_connection_;
67 70
68 DISALLOW_COPY_AND_ASSIGN(ViewsExamples); 71 DISALLOW_COPY_AND_ASSIGN(ViewsExamples);
69 }; 72 };
70 73
71 MojoResult ServiceMain(MojoHandle service_request_handle) { 74 MojoResult ServiceMain(MojoHandle service_request_handle) {
72 return service_manager::ServiceRunner(new ViewsExamples) 75 return service_manager::ServiceRunner(new ViewsExamples)
73 .Run(service_request_handle); 76 .Run(service_request_handle);
74 } 77 }
OLDNEW
« no previous file with comments | « mash/catalog_viewer/catalog_viewer.cc ('k') | mash/example/window_type_launcher/window_type_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698