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

Side by Side Diff: services/service_manager/tests/connect/connect_test_exe.cc

Issue 2500683002: Revert of Service Manager: Remove ServiceContext* arg from Service::OnStart() (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 "base/memory/ptr_util.h"
9 #include "mojo/public/cpp/bindings/binding_set.h" 9 #include "mojo/public/cpp/bindings/binding_set.h"
10 #include "services/service_manager/public/cpp/connection.h" 10 #include "services/service_manager/public/cpp/connection.h"
(...skipping 13 matching lines...) Expand all
24 24
25 class Target : public service_manager::Service, 25 class Target : public service_manager::Service,
26 public service_manager::InterfaceFactory<ConnectTestService>, 26 public service_manager::InterfaceFactory<ConnectTestService>,
27 public ConnectTestService { 27 public ConnectTestService {
28 public: 28 public:
29 Target() {} 29 Target() {}
30 ~Target() override {} 30 ~Target() override {}
31 31
32 private: 32 private:
33 // service_manager::Service: 33 // service_manager::Service:
34 void OnStart(service_manager::ServiceContext* context) override {
35 identity_ = context->identity();
36 }
37
34 bool OnConnect(const service_manager::ServiceInfo& remote_info, 38 bool OnConnect(const service_manager::ServiceInfo& remote_info,
35 service_manager::InterfaceRegistry* registry) override { 39 service_manager::InterfaceRegistry* registry) override {
36 registry->AddInterface<ConnectTestService>(this); 40 registry->AddInterface<ConnectTestService>(this);
37 return true; 41 return true;
38 } 42 }
39 43
40 // service_manager::InterfaceFactory<ConnectTestService>: 44 // service_manager::InterfaceFactory<ConnectTestService>:
41 void Create(const service_manager::Identity& remote_identity, 45 void Create(const service_manager::Identity& remote_identity,
42 ConnectTestServiceRequest request) override { 46 ConnectTestServiceRequest request) override {
43 bindings_.AddBinding(this, std::move(request)); 47 bindings_.AddBinding(this, std::move(request));
44 } 48 }
45 49
46 // ConnectTestService: 50 // ConnectTestService:
47 void GetTitle(const GetTitleCallback& callback) override { 51 void GetTitle(const GetTitleCallback& callback) override {
48 callback.Run("connect_test_exe"); 52 callback.Run("connect_test_exe");
49 } 53 }
50 void GetInstance(const GetInstanceCallback& callback) override { 54 void GetInstance(const GetInstanceCallback& callback) override {
51 callback.Run(context()->identity().instance()); 55 callback.Run(identity_.instance());
52 } 56 }
53 57
58 service_manager::Identity identity_;
54 mojo::BindingSet<ConnectTestService> bindings_; 59 mojo::BindingSet<ConnectTestService> bindings_;
55 60
56 DISALLOW_COPY_AND_ASSIGN(Target); 61 DISALLOW_COPY_AND_ASSIGN(Target);
57 }; 62 };
58 63
59 } // namespace 64 } // namespace
60 65
61 int main(int argc, char** argv) { 66 int main(int argc, char** argv) {
62 base::AtExitManager at_exit; 67 base::AtExitManager at_exit;
63 base::CommandLine::Init(argc, argv); 68 base::CommandLine::Init(argc, argv);
64 69
65 service_manager::InitializeLogging(); 70 service_manager::InitializeLogging();
66 return service_manager::TestNativeMain(base::MakeUnique<Target>()); 71 return service_manager::TestNativeMain(base::MakeUnique<Target>());
67 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698