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

Side by Side Diff: services/device_info/device_info.cc

Issue 2019743002: Yet more ApplicationDelegate/ApplicationRunner conversion. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 6 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 | « examples/indirect_service/integer_service.cc ('k') | services/nacl/nonsfi/pnacl_compile.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <cstdlib> 5 #include <stdlib.h>
6 #include <memory>
7 6
8 #include "mojo/common/binding_set.h" 7 #include "mojo/common/binding_set.h"
9 #include "mojo/public/c/system/main.h" 8 #include "mojo/public/c/system/main.h"
10 #include "mojo/public/cpp/application/application_delegate.h" 9 #include "mojo/public/cpp/application/application_impl_base.h"
11 #include "mojo/public/cpp/application/application_runner.h" 10 #include "mojo/public/cpp/application/run_application.h"
12 #include "mojo/public/cpp/application/service_provider_impl.h" 11 #include "mojo/public/cpp/application/service_provider_impl.h"
13 #include "mojo/services/device_info/interfaces/device_info.mojom.h" 12 #include "mojo/services/device_info/interfaces/device_info.mojom.h"
14 13
15 namespace mojo { 14 namespace mojo {
16 namespace services { 15 namespace services {
17 namespace device_info { 16 namespace device_info {
18 17
19 // This is a native Mojo application which implements |DeviceInfo| interface for 18 // This is a native Mojo application which implements |DeviceInfo| interface for
20 // Linux. 19 // Linux.
21 class DeviceInfo : public ApplicationDelegate, public mojo::DeviceInfo { 20 class DeviceInfoApp : public ApplicationImplBase, public mojo::DeviceInfo {
22 public: 21 public:
23 // We look for the 'DISPLAY' environment variable. If present, then we assume 22 // We look for the 'DISPLAY' environment variable. If present, then we assume
24 // it to be a desktop, else we assume it to be a commandline 23 // it to be a desktop, else we assume it to be a commandline
25 void GetDeviceType(const GetDeviceTypeCallback& callback) override { 24 void GetDeviceType(const GetDeviceTypeCallback& callback) override {
26 callback.Run(getenv("DISPLAY") ? DeviceInfo::DeviceType::DESKTOP 25 callback.Run(getenv("DISPLAY") ? DeviceInfo::DeviceType::DESKTOP
27 : DeviceInfo::DeviceType::HEADLESS); 26 : DeviceInfo::DeviceType::HEADLESS);
28 } 27 }
29 28
30 // |ApplicationDelegate| override. 29 // |ApplicationImplBase| override.
31 bool ConfigureIncomingConnection( 30 bool OnAcceptConnection(ServiceProviderImpl* service_provider_impl) override {
32 ServiceProviderImpl* service_provider_impl) override {
33 service_provider_impl->AddService<mojo::DeviceInfo>( 31 service_provider_impl->AddService<mojo::DeviceInfo>(
34 [this](const ConnectionContext& connection_context, 32 [this](const ConnectionContext& connection_context,
35 InterfaceRequest<mojo::DeviceInfo> device_info_request) { 33 InterfaceRequest<mojo::DeviceInfo> device_info_request) {
36 binding_.AddBinding(this, device_info_request.Pass()); 34 binding_.AddBinding(this, device_info_request.Pass());
37 }); 35 });
38 return true; 36 return true;
39 } 37 }
40 38
41 private: 39 private:
42 mojo::BindingSet<mojo::DeviceInfo> binding_; 40 mojo::BindingSet<mojo::DeviceInfo> binding_;
43 }; 41 };
44 42
45 } // namespace device_info 43 } // namespace device_info
46 } // namespace services 44 } // namespace services
47 } // namespace mojo 45 } // namespace mojo
48 46
49 MojoResult MojoMain(MojoHandle application_request) { 47 MojoResult MojoMain(MojoHandle application_request) {
50 mojo::ApplicationRunner runner( 48 mojo::services::device_info::DeviceInfoApp device_info_app;
51 std::unique_ptr<mojo::services::device_info::DeviceInfo>( 49 return mojo::RunMainApplication(application_request, &device_info_app);
52 new mojo::services::device_info::DeviceInfo()));
53 return runner.Run(application_request);
54 } 50 }
OLDNEW
« no previous file with comments | « examples/indirect_service/integer_service.cc ('k') | services/nacl/nonsfi/pnacl_compile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698