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

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

Issue 1375313006: For c++, Generate enum classes instead of enum from mojom. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 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 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 <cstdlib>
6 6
7 #include "mojo/common/binding_set.h" 7 #include "mojo/common/binding_set.h"
8 #include "mojo/public/c/system/main.h" 8 #include "mojo/public/c/system/main.h"
9 #include "mojo/public/cpp/application/application_connection.h" 9 #include "mojo/public/cpp/application/application_connection.h"
10 #include "mojo/public/cpp/application/application_delegate.h" 10 #include "mojo/public/cpp/application/application_delegate.h"
11 #include "mojo/public/cpp/application/application_runner.h" 11 #include "mojo/public/cpp/application/application_runner.h"
12 #include "mojo/public/cpp/application/interface_factory.h" 12 #include "mojo/public/cpp/application/interface_factory.h"
13 #include "mojo/services/device_info/public/interfaces/device_info.mojom.h" 13 #include "mojo/services/device_info/public/interfaces/device_info.mojom.h"
14 14
15 namespace mojo { 15 namespace mojo {
16 namespace services { 16 namespace services {
17 namespace device_info { 17 namespace device_info {
18 18
19 // This is a native Mojo application which implements |DeviceInfo| interface for 19 // This is a native Mojo application which implements |DeviceInfo| interface for
20 // Linux. 20 // Linux.
21 class DeviceInfo : public mojo::ApplicationDelegate, 21 class DeviceInfo : public mojo::ApplicationDelegate,
22 public mojo::DeviceInfo, 22 public mojo::DeviceInfo,
23 public mojo::InterfaceFactory<mojo::DeviceInfo> { 23 public mojo::InterfaceFactory<mojo::DeviceInfo> {
24 public: 24 public:
25 // We look for the 'DISPLAY' environment variable. If present, then we assume 25 // We look for the 'DISPLAY' environment variable. If present, then we assume
26 // it to be a desktop, else we assume it to be a commandline 26 // it to be a desktop, else we assume it to be a commandline
27 void GetDeviceType(const GetDeviceTypeCallback& callback) override { 27 void GetDeviceType(const GetDeviceTypeCallback& callback) override {
28 callback.Run(getenv("DISPLAY") ? DEVICE_TYPE_DESKTOP 28 callback.Run(getenv("DISPLAY") ? DeviceInfo::DeviceType::DESKTOP
29 : DEVICE_TYPE_HEADLESS); 29 : DeviceInfo::DeviceType::HEADLESS);
30 } 30 }
31 31
32 // |ApplicationDelegate| override. 32 // |ApplicationDelegate| override.
33 bool ConfigureIncomingConnection( 33 bool ConfigureIncomingConnection(
34 mojo::ApplicationConnection* connection) override { 34 mojo::ApplicationConnection* connection) override {
35 connection->AddService<mojo::DeviceInfo>(this); 35 connection->AddService<mojo::DeviceInfo>(this);
36 return true; 36 return true;
37 } 37 }
38 38
39 // |InterfaceFactory<DeviceInfo>| implementation. 39 // |InterfaceFactory<DeviceInfo>| implementation.
40 void Create(mojo::ApplicationConnection* connection, 40 void Create(mojo::ApplicationConnection* connection,
41 mojo::InterfaceRequest<mojo::DeviceInfo> request) override { 41 mojo::InterfaceRequest<mojo::DeviceInfo> request) override {
42 binding_.AddBinding(this, request.Pass()); 42 binding_.AddBinding(this, request.Pass());
43 } 43 }
44 44
45 private: 45 private:
46 mojo::BindingSet<mojo::DeviceInfo> binding_; 46 mojo::BindingSet<mojo::DeviceInfo> binding_;
47 }; 47 };
48 48
49 } // namespace device_info 49 } // namespace device_info
50 } // namespace services 50 } // namespace services
51 } // namespace mojo 51 } // namespace mojo
52 52
53 MojoResult MojoMain(MojoHandle application_request) { 53 MojoResult MojoMain(MojoHandle application_request) {
54 mojo::ApplicationRunner runner(new mojo::services::device_info::DeviceInfo()); 54 mojo::ApplicationRunner runner(new mojo::services::device_info::DeviceInfo());
55 return runner.Run(application_request); 55 return runner.Run(application_request);
56 } 56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698