OLD | NEW |
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" |
| 6 |
5 #include "mojo/application/application_runner_chromium.h" | 7 #include "mojo/application/application_runner_chromium.h" |
6 #include "mojo/public/c/system/main.h" | 8 #include "mojo/public/c/system/main.h" |
7 #include "mojo/public/cpp/application/application_connection.h" | 9 #include "mojo/public/cpp/application/application_connection.h" |
8 #include "mojo/public/cpp/application/application_delegate.h" | |
9 #include "mojo/public/cpp/bindings/strong_binding.h" | |
10 #include "services/prediction/dictionary_service.h" | |
11 #include "services/prediction/prediction_service_impl.h" | |
12 | 10 |
13 namespace prediction { | 11 namespace prediction { |
14 | 12 |
15 PredictionServiceImpl::PredictionServiceImpl( | 13 PredictionServiceImpl::PredictionServiceImpl( |
16 mojo::InterfaceRequest<PredictionService> request) | 14 mojo::InterfaceRequest<PredictionService> request) |
17 : strong_binding_(this, request.Pass()) { | 15 : strong_binding_(this, request.Pass()) { |
18 ProximityInfoFactory proximity_info; | 16 ProximityInfoFactory proximity_info; |
19 proximity_settings_ = scoped_ptr<latinime::ProximityInfo>( | 17 proximity_settings_ = scoped_ptr<latinime::ProximityInfo>( |
20 proximity_info.GetNativeProximityInfo()); | 18 proximity_info.GetNativeProximityInfo()); |
21 } | 19 } |
22 | 20 |
23 PredictionServiceImpl::~PredictionServiceImpl() { | 21 PredictionServiceImpl::~PredictionServiceImpl() { |
24 } | 22 } |
25 | 23 |
26 // PredictionService implementation | |
27 void PredictionServiceImpl::GetPredictionList( | 24 void PredictionServiceImpl::GetPredictionList( |
28 PredictionInfoPtr prediction_info, | 25 PredictionInfoPtr prediction_info, |
29 const GetPredictionListCallback& callback) { | 26 const GetPredictionListCallback& callback) { |
30 mojo::Array<mojo::String> prediction_list = | 27 mojo::Array<mojo::String> prediction_list = |
31 dictionary_service_.GetDictionarySuggestion(prediction_info.Pass(), | 28 dictionary_service_.GetDictionarySuggestion(prediction_info.Pass(), |
32 proximity_settings_.get()); | 29 proximity_settings_.get()); |
33 callback.Run(prediction_list.Pass()); | 30 callback.Run(prediction_list.Pass()); |
34 } | 31 } |
35 | 32 |
36 PredictionServiceDelegate::PredictionServiceDelegate() { | 33 PredictionServiceDelegate::PredictionServiceDelegate() {} |
37 } | |
38 | 34 |
39 PredictionServiceDelegate::~PredictionServiceDelegate() { | 35 PredictionServiceDelegate::~PredictionServiceDelegate() {} |
40 } | |
41 | 36 |
42 // mojo::ApplicationDelegate implementation | |
43 bool PredictionServiceDelegate::ConfigureIncomingConnection( | 37 bool PredictionServiceDelegate::ConfigureIncomingConnection( |
44 mojo::ApplicationConnection* connection) { | 38 mojo::ApplicationConnection* connection) { |
45 connection->AddService<PredictionService>(this); | 39 connection->GetServiceProviderImpl().AddService<PredictionService>( |
| 40 [](const mojo::ConnectionContext& connection_context, |
| 41 mojo::InterfaceRequest<PredictionService> prediction_service_request) { |
| 42 new PredictionServiceImpl(prediction_service_request.Pass()); |
| 43 }); |
46 return true; | 44 return true; |
47 } | 45 } |
48 | 46 |
49 // mojo::InterfaceRequest<PredictionService> implementation | |
50 void PredictionServiceDelegate::Create( | |
51 const mojo::ConnectionContext& connection_context, | |
52 mojo::InterfaceRequest<PredictionService> request) { | |
53 new PredictionServiceImpl(request.Pass()); | |
54 } | |
55 | |
56 } // namespace prediction | 47 } // namespace prediction |
57 | 48 |
58 MojoResult MojoMain(MojoHandle application_request) { | 49 MojoResult MojoMain(MojoHandle application_request) { |
59 mojo::ApplicationRunnerChromium runner( | 50 mojo::ApplicationRunnerChromium runner( |
60 new prediction::PredictionServiceDelegate()); | 51 new prediction::PredictionServiceDelegate()); |
61 return runner.Run(application_request); | 52 return runner.Run(application_request); |
62 } | 53 } |
OLD | NEW |