Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/launcher/launch_instance.h" | 5 #include "services/ui/launcher/launch_instance.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "mojo/application/application_runner_chromium.h" | 10 #include "mojo/application/application_runner_chromium.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 mojo::ConnectToService(app_impl_->shell(), "mojo:compositor_service", | 33 mojo::ConnectToService(app_impl_->shell(), "mojo:compositor_service", |
| 34 GetProxy(&compositor_)); | 34 GetProxy(&compositor_)); |
| 35 compositor_.set_connection_error_handler(base::Bind( | 35 compositor_.set_connection_error_handler(base::Bind( |
| 36 &LaunchInstance::OnCompositorConnectionError, base::Unretained(this))); | 36 &LaunchInstance::OnCompositorConnectionError, base::Unretained(this))); |
| 37 | 37 |
| 38 mojo::ConnectToService(app_impl_->shell(), "mojo:view_manager_service", | 38 mojo::ConnectToService(app_impl_->shell(), "mojo:view_manager_service", |
| 39 GetProxy(&view_manager_)); | 39 GetProxy(&view_manager_)); |
| 40 view_manager_.set_connection_error_handler(base::Bind( | 40 view_manager_.set_connection_error_handler(base::Bind( |
| 41 &LaunchInstance::OnViewManagerConnectionError, base::Unretained(this))); | 41 &LaunchInstance::OnViewManagerConnectionError, base::Unretained(this))); |
| 42 | 42 |
| 43 /// Connect to ViewAssociates. | |
| 44 // TODO(mikejurka): get this from the commandline? | |
| 45 std::vector<std::string> associate_urls; /// = command_line->GetArgs(); | |
| 46 if (associate_urls.empty()) { | |
| 47 // TODO(jeffbrown): Replace this hardcoded list. | |
| 48 associate_urls.push_back("mojo:input_manager_service"); | |
| 49 } | |
| 50 | |
| 51 for (const auto& url : associate_urls) { | |
| 52 DVLOG(2) << "Connecting to ViewAssociate " << url; | |
| 53 // Connect to the ViewAssociate. | |
| 54 mojo::ui::ViewAssociatePtr associate; | |
| 55 mojo::ConnectToService(app_impl_->shell(), url, GetProxy(&associate)); | |
| 56 | |
| 57 // Wire up the associate to the ViewManager. | |
| 58 view_manager_->RegisterViewAssociate(associate.Pass(), url); | |
| 59 } | |
| 60 | |
| 43 InitViewport(); | 61 InitViewport(); |
| 44 | 62 |
| 45 mojo::ui::ViewProviderPtr client_view_provider; | 63 mojo::ui::ViewProviderPtr client_view_provider; |
| 46 mojo::ConnectToService(app_impl_->shell(), app_url_, | 64 mojo::ConnectToService(app_impl_->shell(), app_url_, |
| 47 GetProxy(&client_view_provider)); | 65 GetProxy(&client_view_provider)); |
| 48 | 66 |
| 49 client_view_provider->CreateView(GetProxy(&client_view_owner_), nullptr, | 67 client_view_provider->CreateView(GetProxy(&client_view_owner_), nullptr, |
| 50 nullptr); | 68 nullptr); |
| 51 } | 69 } |
| 52 | 70 |
| 71 void LaunchInstance::OnViewAssociateConnectionError( | |
| 72 const mojo::String& label, | |
| 73 const OnViewAssociateConnectionErrorCallback& callback) { | |
| 74 LOG(ERROR) << "Exiting due to view associate connection error."; | |
| 75 // TODO(mikejurka): should we even be running this callback? | |
|
jeffbrown
2016/05/17 00:44:49
yes, all callbacks have to be invoked (unless you
| |
| 76 callback.Run(); | |
| 77 shutdown_callback_.Run(); | |
| 78 }; | |
| 79 | |
| 53 void LaunchInstance::OnCompositorConnectionError() { | 80 void LaunchInstance::OnCompositorConnectionError() { |
| 54 LOG(ERROR) << "Exiting due to compositor connection error."; | 81 LOG(ERROR) << "Exiting due to compositor connection error."; |
| 55 shutdown_callback_.Run(); | 82 shutdown_callback_.Run(); |
| 56 } | 83 } |
| 57 | 84 |
| 58 void LaunchInstance::OnViewManagerConnectionError() { | 85 void LaunchInstance::OnViewManagerConnectionError() { |
| 59 LOG(ERROR) << "Exiting due to view manager connection error."; | 86 LOG(ERROR) << "Exiting due to view manager connection error."; |
| 60 shutdown_callback_.Run(); | 87 shutdown_callback_.Run(); |
| 61 } | 88 } |
| 62 | 89 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 } | 141 } |
| 115 | 142 |
| 116 void LaunchInstance::OnEvent(mojo::EventPtr event, | 143 void LaunchInstance::OnEvent(mojo::EventPtr event, |
| 117 const mojo::Callback<void()>& callback) { | 144 const mojo::Callback<void()>& callback) { |
| 118 if (view_tree_) | 145 if (view_tree_) |
| 119 view_tree_->DispatchEvent(event.Pass()); | 146 view_tree_->DispatchEvent(event.Pass()); |
| 120 callback.Run(); | 147 callback.Run(); |
| 121 } | 148 } |
| 122 | 149 |
| 123 } // namespace launcher | 150 } // namespace launcher |
| OLD | NEW |