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

Side by Side Diff: services/service_manager/tests/lifecycle/app_client.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 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 "services/service_manager/tests/lifecycle/app_client.h" 5 #include "services/service_manager/tests/lifecycle/app_client.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "services/service_manager/public/cpp/interface_registry.h" 8 #include "services/service_manager/public/cpp/interface_registry.h"
9 #include "services/service_manager/public/cpp/service_context.h" 9 #include "services/service_manager/public/cpp/service_context.h"
10 10
11 namespace service_manager { 11 namespace service_manager {
12 namespace test { 12 namespace test {
13 13
14 AppClient::AppClient() {} 14 AppClient::AppClient() {}
15 15
16 AppClient::~AppClient() {} 16 AppClient::~AppClient() {}
17 17
18 void AppClient::OnStart(ServiceContext* context) {
19 context_ = context;
20 }
21
18 bool AppClient::OnConnect(const ServiceInfo& remote_info, 22 bool AppClient::OnConnect(const ServiceInfo& remote_info,
19 InterfaceRegistry* registry) { 23 InterfaceRegistry* registry) {
20 registry->AddInterface<mojom::LifecycleControl>(this); 24 registry->AddInterface<mojom::LifecycleControl>(this);
21 return true; 25 return true;
22 } 26 }
23 27
24 bool AppClient::OnStop() { 28 bool AppClient::OnStop() {
25 base::MessageLoop::current()->QuitWhenIdle(); 29 base::MessageLoop::current()->QuitWhenIdle();
26 return true; 30 return true;
27 } 31 }
28 32
29 void AppClient::Create(const Identity& remote_identity, 33 void AppClient::Create(const Identity& remote_identity,
30 mojom::LifecycleControlRequest request) { 34 mojom::LifecycleControlRequest request) {
31 bindings_.AddBinding(this, std::move(request)); 35 bindings_.AddBinding(this, std::move(request));
32 } 36 }
33 37
34 void AppClient::Ping(const PingCallback& callback) { 38 void AppClient::Ping(const PingCallback& callback) {
35 callback.Run(); 39 callback.Run();
36 } 40 }
37 41
38 void AppClient::GracefulQuit() { 42 void AppClient::GracefulQuit() {
39 context()->RequestQuit(); 43 context_->RequestQuit();
40 } 44 }
41 45
42 void AppClient::Crash() { 46 void AppClient::Crash() {
43 // Rather than actually crash, which causes a bunch of console spray and 47 // Rather than actually crash, which causes a bunch of console spray and
44 // maybe UI clutter on some platforms, just exit without shutting anything 48 // maybe UI clutter on some platforms, just exit without shutting anything
45 // down properly. 49 // down properly.
46 exit(1); 50 exit(1);
47 } 51 }
48 52
49 void AppClient::CloseServiceManagerConnection() { 53 void AppClient::CloseServiceManagerConnection() {
50 context()->DisconnectFromServiceManager(); 54 context_->DisconnectFromServiceManager();
51 bindings_.set_connection_error_handler( 55 bindings_.set_connection_error_handler(
52 base::Bind(&AppClient::BindingLost, base::Unretained(this))); 56 base::Bind(&AppClient::BindingLost, base::Unretained(this)));
53 } 57 }
54 58
55 void AppClient::BindingLost() { 59 void AppClient::BindingLost() {
56 if (bindings_.empty()) 60 if (bindings_.empty())
57 OnStop(); 61 OnStop();
58 } 62 }
59 63
60 } // namespace test 64 } // namespace test
61 } // namespace service_manager 65 } // namespace service_manager
OLDNEW
« no previous file with comments | « services/service_manager/tests/lifecycle/app_client.h ('k') | services/service_manager/tests/lifecycle/package.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698