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

Side by Side Diff: mojo/shell/tests/lifecycle/app_client.cc

Issue 1877753003: Move mojo\shell to services\shell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@62scan
Patch Set: . Created 4 years, 8 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
« no previous file with comments | « mojo/shell/tests/lifecycle/app_client.h ('k') | mojo/shell/tests/lifecycle/app_manifest.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mojo/shell/tests/lifecycle/app_client.h"
6
7 #include "mojo/shell/public/cpp/shell_connection.h"
8
9 namespace mojo {
10 namespace shell {
11 namespace test {
12
13 AppClient::AppClient() {}
14 AppClient::AppClient(shell::mojom::ShellClientRequest request)
15 : connection_(new ShellConnection(this, std::move(request))) {}
16 AppClient::~AppClient() {}
17
18 bool AppClient::AcceptConnection(mojo::Connection* connection) {
19 connection->AddInterface<LifecycleControl>(this);
20 return true;
21 }
22
23 void AppClient::Create(mojo::Connection* connection,
24 LifecycleControlRequest request) {
25 bindings_.AddBinding(this, std::move(request));
26 }
27
28 void AppClient::Ping(const PingCallback& callback) {
29 callback.Run();
30 }
31
32 void AppClient::GracefulQuit() {
33 base::MessageLoop::current()->QuitWhenIdle();
34 }
35
36 void AppClient::Crash() {
37 // Rather than actually crash, which causes a bunch of console spray and
38 // maybe UI clutter on some platforms, just exit without shutting anything
39 // down properly.
40 exit(1);
41 }
42
43 void AppClient::CloseShellConnection() {
44 DCHECK(runner_);
45 runner_->DestroyShellConnection();
46 // Quit the app once the caller goes away.
47 bindings_.set_connection_error_handler(
48 base::Bind(&AppClient::BindingLost, base::Unretained(this)));
49 }
50
51 void AppClient::BindingLost() {
52 if (bindings_.empty())
53 GracefulQuit();
54 }
55
56 } // namespace test
57 } // namespace shell
58 } // namespace mojo
59
60
OLDNEW
« no previous file with comments | « mojo/shell/tests/lifecycle/app_client.h ('k') | mojo/shell/tests/lifecycle/app_manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698