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

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

Issue 1979723002: ApplicationConnection devolution, part 3. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 7 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 | « services/debugger/debugger.cc ('k') | services/files/main.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 <cstdlib>
6 #include <memory> 6 #include <memory>
7 7
8 #include "mojo/common/binding_set.h" 8 #include "mojo/common/binding_set.h"
9 #include "mojo/public/c/system/main.h" 9 #include "mojo/public/c/system/main.h"
10 #include "mojo/public/cpp/application/application_connection.h" 10 #include "mojo/public/cpp/application/application_connection.h"
(...skipping 11 matching lines...) Expand all
22 public: 22 public:
23 // We look for the 'DISPLAY' environment variable. If present, then we assume 23 // 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 24 // it to be a desktop, else we assume it to be a commandline
25 void GetDeviceType(const GetDeviceTypeCallback& callback) override { 25 void GetDeviceType(const GetDeviceTypeCallback& callback) override {
26 callback.Run(getenv("DISPLAY") ? DeviceInfo::DeviceType::DESKTOP 26 callback.Run(getenv("DISPLAY") ? DeviceInfo::DeviceType::DESKTOP
27 : DeviceInfo::DeviceType::HEADLESS); 27 : DeviceInfo::DeviceType::HEADLESS);
28 } 28 }
29 29
30 // |ApplicationDelegate| override. 30 // |ApplicationDelegate| override.
31 bool ConfigureIncomingConnection( 31 bool ConfigureIncomingConnection(
32 mojo::ApplicationConnection* connection) override { 32 ServiceProviderImpl* service_provider_impl) override {
33 connection->GetServiceProviderImpl().AddService<mojo::DeviceInfo>( 33 service_provider_impl->AddService<mojo::DeviceInfo>(
34 [this](const ConnectionContext& connection_context, 34 [this](const ConnectionContext& connection_context,
35 InterfaceRequest<mojo::DeviceInfo> device_info_request) { 35 InterfaceRequest<mojo::DeviceInfo> device_info_request) {
36 binding_.AddBinding(this, device_info_request.Pass()); 36 binding_.AddBinding(this, device_info_request.Pass());
37 }); 37 });
38 return true; 38 return true;
39 } 39 }
40 40
41 private: 41 private:
42 mojo::BindingSet<mojo::DeviceInfo> binding_; 42 mojo::BindingSet<mojo::DeviceInfo> binding_;
43 }; 43 };
44 44
45 } // namespace device_info 45 } // namespace device_info
46 } // namespace services 46 } // namespace services
47 } // namespace mojo 47 } // namespace mojo
48 48
49 MojoResult MojoMain(MojoHandle application_request) { 49 MojoResult MojoMain(MojoHandle application_request) {
50 mojo::ApplicationRunner runner( 50 mojo::ApplicationRunner runner(
51 std::unique_ptr<mojo::services::device_info::DeviceInfo>( 51 std::unique_ptr<mojo::services::device_info::DeviceInfo>(
52 new mojo::services::device_info::DeviceInfo())); 52 new mojo::services::device_info::DeviceInfo()));
53 return runner.Run(application_request); 53 return runner.Run(application_request);
54 } 54 }
OLDNEW
« no previous file with comments | « services/debugger/debugger.cc ('k') | services/files/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698