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

Side by Side Diff: services/service_manager/tests/lifecycle/app_client.cc

Issue 2701883002: service_manager: More consistent Service lifecycle API (Closed)
Patch Set: . Created 3 years, 10 months 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 bool AppClient::OnConnect(const ServiceInfo& remote_info, 18 bool AppClient::OnConnect(const ServiceInfo& remote_info,
19 InterfaceRegistry* registry) { 19 InterfaceRegistry* registry) {
20 registry->AddInterface<mojom::LifecycleControl>(this); 20 registry->AddInterface<mojom::LifecycleControl>(this);
21 return true; 21 return true;
22 } 22 }
23 23
24 bool AppClient::OnStop() { 24 bool AppClient::OnServiceManagerConnectionLost() {
25 base::MessageLoop::current()->QuitWhenIdle(); 25 base::MessageLoop::current()->QuitWhenIdle();
26 return true; 26 return true;
27 } 27 }
28 28
29 void AppClient::Create(const Identity& remote_identity, 29 void AppClient::Create(const Identity& remote_identity,
30 mojom::LifecycleControlRequest request) { 30 mojom::LifecycleControlRequest request) {
31 bindings_.AddBinding(this, std::move(request)); 31 bindings_.AddBinding(this, std::move(request));
32 } 32 }
33 33
34 void AppClient::Ping(const PingCallback& callback) { 34 void AppClient::Ping(const PingCallback& callback) {
(...skipping 12 matching lines...) Expand all
47 } 47 }
48 48
49 void AppClient::CloseServiceManagerConnection() { 49 void AppClient::CloseServiceManagerConnection() {
50 context()->DisconnectFromServiceManager(); 50 context()->DisconnectFromServiceManager();
51 bindings_.set_connection_error_handler( 51 bindings_.set_connection_error_handler(
52 base::Bind(&AppClient::BindingLost, base::Unretained(this))); 52 base::Bind(&AppClient::BindingLost, base::Unretained(this)));
53 } 53 }
54 54
55 void AppClient::BindingLost() { 55 void AppClient::BindingLost() {
56 if (bindings_.empty()) 56 if (bindings_.empty())
57 OnStop(); 57 OnServiceManagerConnectionLost();
58 } 58 }
59 59
60 } // namespace test 60 } // namespace test
61 } // namespace service_manager 61 } // namespace service_manager
OLDNEW
« no previous file with comments | « services/service_manager/tests/lifecycle/app_client.h ('k') | services/service_manager/tests/service_manager/embedder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698