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

Side by Side Diff: services/prediction/prediction_service_impl.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, 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
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 "services/prediction/prediction_service_impl.h" 5 #include "services/prediction/prediction_service_impl.h"
6 6
7 #include "mojo/application/application_runner_chromium.h"
8 #include "mojo/public/c/system/main.h" 7 #include "mojo/public/c/system/main.h"
8 #include "mojo/public/cpp/application/application_impl_base.h"
9 #include "mojo/public/cpp/application/run_application.h"
9 #include "mojo/public/cpp/application/service_provider_impl.h" 10 #include "mojo/public/cpp/application/service_provider_impl.h"
10 11
11 namespace prediction { 12 namespace prediction {
12 13
13 PredictionServiceImpl::PredictionServiceImpl( 14 PredictionServiceImpl::PredictionServiceImpl(
14 mojo::InterfaceRequest<PredictionService> request) 15 mojo::InterfaceRequest<PredictionService> request)
15 : strong_binding_(this, request.Pass()) { 16 : strong_binding_(this, request.Pass()) {
16 ProximityInfoFactory proximity_info; 17 ProximityInfoFactory proximity_info;
17 proximity_settings_ = scoped_ptr<latinime::ProximityInfo>( 18 proximity_settings_ = scoped_ptr<latinime::ProximityInfo>(
18 proximity_info.GetNativeProximityInfo()); 19 proximity_info.GetNativeProximityInfo());
19 } 20 }
20 21
21 PredictionServiceImpl::~PredictionServiceImpl() { 22 PredictionServiceImpl::~PredictionServiceImpl() {
22 } 23 }
23 24
24 void PredictionServiceImpl::GetPredictionList( 25 void PredictionServiceImpl::GetPredictionList(
25 PredictionInfoPtr prediction_info, 26 PredictionInfoPtr prediction_info,
26 const GetPredictionListCallback& callback) { 27 const GetPredictionListCallback& callback) {
27 mojo::Array<mojo::String> prediction_list = 28 mojo::Array<mojo::String> prediction_list =
28 dictionary_service_.GetDictionarySuggestion(prediction_info.Pass(), 29 dictionary_service_.GetDictionarySuggestion(prediction_info.Pass(),
29 proximity_settings_.get()); 30 proximity_settings_.get());
30 callback.Run(prediction_list.Pass()); 31 callback.Run(prediction_list.Pass());
31 } 32 }
32 33
33 PredictionServiceDelegate::PredictionServiceDelegate() {} 34 // TODO(vtl): Maybe this (and MojoMain()) should go in a different file?
35 class PredictionServiceApp : public mojo::ApplicationImplBase {
36 public:
37 PredictionServiceApp() {}
38 ~PredictionServiceApp() override {}
34 39
35 PredictionServiceDelegate::~PredictionServiceDelegate() {} 40 // mojo::ApplicationImplBase override:
36 41 bool OnAcceptConnection(
37 bool PredictionServiceDelegate::ConfigureIncomingConnection( 42 mojo::ServiceProviderImpl* service_provider_impl) override {
38 mojo::ServiceProviderImpl* service_provider_impl) { 43 service_provider_impl->AddService<PredictionService>([](
39 service_provider_impl->AddService<PredictionService>( 44 const mojo::ConnectionContext& connection_context,
40 [](const mojo::ConnectionContext& connection_context, 45 mojo::InterfaceRequest<PredictionService> prediction_service_request) {
41 mojo::InterfaceRequest<PredictionService> prediction_service_request) { 46 new PredictionServiceImpl(prediction_service_request.Pass());
42 new PredictionServiceImpl(prediction_service_request.Pass()); 47 });
43 }); 48 return true;
44 return true; 49 }
45 } 50 };
46 51
47 } // namespace prediction 52 } // namespace prediction
48 53
49 MojoResult MojoMain(MojoHandle application_request) { 54 MojoResult MojoMain(MojoHandle application_request) {
50 mojo::ApplicationRunnerChromium runner( 55 prediction::PredictionServiceApp prediction_service_app;
51 new prediction::PredictionServiceDelegate()); 56 return mojo::RunMainApplication(application_request, &prediction_service_app);
52 return runner.Run(application_request);
53 } 57 }
OLDNEW
« services/media/audio/audio_server_app.cc ('K') | « services/prediction/prediction_service_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698