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

Side by Side Diff: examples/apptest/example_service_application.cc

Issue 2015643002: Add (optional) options to Run[Main]Application(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: doh 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "examples/apptest/example_service_application.h" 5 #include "examples/apptest/example_service_application.h"
6 6
7 #include <memory>
8
9 #include "mojo/public/c/system/main.h" 7 #include "mojo/public/c/system/main.h"
10 #include "mojo/public/cpp/application/application_runner.h" 8 #include "mojo/public/cpp/application/run_application.h"
11 #include "mojo/public/cpp/application/service_provider_impl.h" 9 #include "mojo/public/cpp/application/service_provider_impl.h"
12 10
13 namespace mojo { 11 namespace mojo {
14 12
15 ExampleServiceApplication::ExampleServiceApplication() {} 13 ExampleServiceApplication::ExampleServiceApplication() {}
16 14
17 ExampleServiceApplication::~ExampleServiceApplication() {} 15 ExampleServiceApplication::~ExampleServiceApplication() {}
18 16
19 bool ExampleServiceApplication::ConfigureIncomingConnection( 17 bool ExampleServiceApplication::OnAcceptConnection(
20 ServiceProviderImpl* service_provider_impl) { 18 ServiceProviderImpl* service_provider_impl) {
21 service_provider_impl->AddService<ExampleService>( 19 service_provider_impl->AddService<ExampleService>(
22 [](const ConnectionContext& connection_context, 20 [](const ConnectionContext& connection_context,
23 InterfaceRequest<ExampleService> example_service_request) { 21 InterfaceRequest<ExampleService> example_service_request) {
24 // Not leaked: ExampleServiceImpl is strongly bound to the pipe. 22 // Not leaked: ExampleServiceImpl is strongly bound to the pipe.
25 new ExampleServiceImpl(example_service_request.Pass()); 23 new ExampleServiceImpl(example_service_request.Pass());
26 }); 24 });
27 return true; 25 return true;
28 } 26 }
29 27
30 } // namespace mojo 28 } // namespace mojo
31 29
32 MojoResult MojoMain(MojoHandle application_request) { 30 MojoResult MojoMain(MojoHandle application_request) {
33 mojo::ApplicationRunner runner( 31 mojo::ExampleServiceApplication example_service_application;
34 std::unique_ptr<mojo::ExampleServiceApplication>( 32 return mojo::RunMainApplication(application_request,
35 new mojo::ExampleServiceApplication())); 33 &example_service_application);
36 return runner.Run(application_request);
37 } 34 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698