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

Side by Side Diff: services/service_manager/tests/connect/connect_test_exe.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h"
8 #include "mojo/public/cpp/bindings/binding_set.h" 9 #include "mojo/public/cpp/bindings/binding_set.h"
9 #include "services/service_manager/public/cpp/connection.h" 10 #include "services/service_manager/public/cpp/connection.h"
10 #include "services/service_manager/public/cpp/connector.h" 11 #include "services/service_manager/public/cpp/connector.h"
11 #include "services/service_manager/public/cpp/interface_factory.h" 12 #include "services/service_manager/public/cpp/interface_factory.h"
12 #include "services/service_manager/public/cpp/interface_registry.h" 13 #include "services/service_manager/public/cpp/interface_registry.h"
13 #include "services/service_manager/public/cpp/service.h" 14 #include "services/service_manager/public/cpp/service.h"
15 #include "services/service_manager/public/cpp/service_context.h"
14 #include "services/service_manager/runner/child/test_native_main.h" 16 #include "services/service_manager/runner/child/test_native_main.h"
15 #include "services/service_manager/runner/init.h" 17 #include "services/service_manager/runner/init.h"
16 #include "services/service_manager/tests/connect/connect_test.mojom.h" 18 #include "services/service_manager/tests/connect/connect_test.mojom.h"
17 19
18 using service_manager::test::mojom::ConnectTestService; 20 using service_manager::test::mojom::ConnectTestService;
19 using service_manager::test::mojom::ConnectTestServiceRequest; 21 using service_manager::test::mojom::ConnectTestServiceRequest;
20 22
21 namespace { 23 namespace {
22 24
23 class Target : public service_manager::Service, 25 class Target : public service_manager::Service,
24 public service_manager::InterfaceFactory<ConnectTestService>, 26 public service_manager::InterfaceFactory<ConnectTestService>,
25 public ConnectTestService { 27 public ConnectTestService {
26 public: 28 public:
27 Target() {} 29 Target() {}
28 ~Target() override {} 30 ~Target() override {}
29 31
30 private: 32 private:
31 // service_manager::Service: 33 // service_manager::Service:
32 void OnStart(const service_manager::ServiceInfo& info) override { 34 void OnStart(service_manager::ServiceContext* context) override {
33 identity_ = info.identity; 35 identity_ = context->identity();
34 } 36 }
37
35 bool OnConnect(const service_manager::ServiceInfo& remote_info, 38 bool OnConnect(const service_manager::ServiceInfo& remote_info,
36 service_manager::InterfaceRegistry* registry) override { 39 service_manager::InterfaceRegistry* registry) override {
37 registry->AddInterface<ConnectTestService>(this); 40 registry->AddInterface<ConnectTestService>(this);
38 return true; 41 return true;
39 } 42 }
40 43
41 // service_manager::InterfaceFactory<ConnectTestService>: 44 // service_manager::InterfaceFactory<ConnectTestService>:
42 void Create(const service_manager::Identity& remote_identity, 45 void Create(const service_manager::Identity& remote_identity,
43 ConnectTestServiceRequest request) override { 46 ConnectTestServiceRequest request) override {
44 bindings_.AddBinding(this, std::move(request)); 47 bindings_.AddBinding(this, std::move(request));
(...skipping 13 matching lines...) Expand all
58 DISALLOW_COPY_AND_ASSIGN(Target); 61 DISALLOW_COPY_AND_ASSIGN(Target);
59 }; 62 };
60 63
61 } // namespace 64 } // namespace
62 65
63 int main(int argc, char** argv) { 66 int main(int argc, char** argv) {
64 base::AtExitManager at_exit; 67 base::AtExitManager at_exit;
65 base::CommandLine::Init(argc, argv); 68 base::CommandLine::Init(argc, argv);
66 69
67 service_manager::InitializeLogging(); 70 service_manager::InitializeLogging();
68 71 return service_manager::TestNativeMain(base::MakeUnique<Target>());
69 Target target;
70 return service_manager::TestNativeMain(&target);
71 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698