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/ui/view_manager/view_manager_app.h" | 5 #include "services/ui/view_manager/view_manager_app.h" |
6 | 6 |
7 #include <string> | |
8 #include <vector> | |
9 | |
10 #include "base/command_line.h" | 7 #include "base/command_line.h" |
11 #include "base/logging.h" | 8 #include "base/logging.h" |
12 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
13 #include "mojo/application/application_runner_chromium.h" | |
14 #include "mojo/common/tracing_impl.h" | 10 #include "mojo/common/tracing_impl.h" |
15 #include "mojo/public/c/system/main.h" | |
16 #include "mojo/public/cpp/application/application_impl.h" | |
17 #include "mojo/public/cpp/application/connect.h" | 11 #include "mojo/public/cpp/application/connect.h" |
| 12 #include "mojo/public/cpp/application/run_application.h" |
18 #include "mojo/public/cpp/application/service_provider_impl.h" | 13 #include "mojo/public/cpp/application/service_provider_impl.h" |
19 #include "services/ui/view_manager/view_manager_impl.h" | 14 #include "services/ui/view_manager/view_manager_impl.h" |
20 | 15 |
21 namespace view_manager { | 16 namespace view_manager { |
22 | 17 |
23 ViewManagerApp::ViewManagerApp() : app_impl_(nullptr) {} | 18 ViewManagerApp::ViewManagerApp() {} |
24 | 19 |
25 ViewManagerApp::~ViewManagerApp() {} | 20 ViewManagerApp::~ViewManagerApp() {} |
26 | 21 |
27 void ViewManagerApp::Initialize(mojo::ApplicationImpl* app_impl) { | 22 void ViewManagerApp::OnInitialize() { |
28 app_impl_ = app_impl; | |
29 | |
30 auto command_line = base::CommandLine::ForCurrentProcess(); | 23 auto command_line = base::CommandLine::ForCurrentProcess(); |
31 command_line->InitFromArgv(app_impl_->args()); | 24 command_line->InitFromArgv(args()); |
32 logging::LoggingSettings settings; | 25 logging::LoggingSettings settings; |
33 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 26 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
34 logging::InitLogging(settings); | 27 logging::InitLogging(settings); |
35 | 28 |
36 tracing_.Initialize(app_impl_->shell(), &app_impl_->args()); | 29 tracing_.Initialize(shell(), &args()); |
37 | 30 |
38 // Connect to compositor. | 31 // Connect to compositor. |
39 mojo::gfx::composition::CompositorPtr compositor; | 32 mojo::gfx::composition::CompositorPtr compositor; |
40 mojo::ConnectToService(app_impl_->shell(), "mojo:compositor_service", | 33 mojo::ConnectToService(shell(), "mojo:compositor_service", |
41 GetProxy(&compositor)); | 34 GetProxy(&compositor)); |
42 compositor.set_connection_error_handler(base::Bind( | 35 compositor.set_connection_error_handler(base::Bind( |
43 &ViewManagerApp::OnCompositorConnectionError, base::Unretained(this))); | 36 &ViewManagerApp::OnCompositorConnectionError, base::Unretained(this))); |
44 | 37 |
45 // Create the registry. | 38 // Create the registry. |
46 registry_.reset(new ViewRegistry(compositor.Pass())); | 39 registry_.reset(new ViewRegistry(compositor.Pass())); |
47 } | 40 } |
48 | 41 |
49 bool ViewManagerApp::ConfigureIncomingConnection( | 42 bool ViewManagerApp::OnAcceptConnection( |
50 mojo::ServiceProviderImpl* service_provider_impl) { | 43 mojo::ServiceProviderImpl* service_provider_impl) { |
51 service_provider_impl->AddService<mojo::ui::ViewManager>([this]( | 44 service_provider_impl->AddService<mojo::ui::ViewManager>([this]( |
52 const mojo::ConnectionContext& connection_context, | 45 const mojo::ConnectionContext& connection_context, |
53 mojo::InterfaceRequest<mojo::ui::ViewManager> view_manager_request) { | 46 mojo::InterfaceRequest<mojo::ui::ViewManager> view_manager_request) { |
54 DCHECK(registry_); | 47 DCHECK(registry_); |
55 view_managers_.AddBinding(new ViewManagerImpl(registry_.get()), | 48 view_managers_.AddBinding(new ViewManagerImpl(registry_.get()), |
56 view_manager_request.Pass()); | 49 view_manager_request.Pass()); |
57 }); | 50 }); |
58 return true; | 51 return true; |
59 } | 52 } |
60 | 53 |
61 void ViewManagerApp::OnCompositorConnectionError() { | 54 void ViewManagerApp::OnCompositorConnectionError() { |
62 LOG(ERROR) << "Exiting due to compositor connection error."; | 55 LOG(ERROR) << "Exiting due to compositor connection error."; |
63 Shutdown(); | 56 Shutdown(); |
64 } | 57 } |
65 | 58 |
66 void ViewManagerApp::Shutdown() { | 59 void ViewManagerApp::Shutdown() { |
67 app_impl_->Terminate(); | 60 mojo::TerminateApplication(MOJO_RESULT_OK); |
68 } | 61 } |
69 | 62 |
70 } // namespace view_manager | 63 } // namespace view_manager |
OLD | NEW |