| OLD | NEW |
| 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 "mojo/public/cpp/application/application_impl.h" | 5 #include "mojo/public/cpp/application/application_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "mojo/public/cpp/application/application_delegate.h" | 9 #include "mojo/public/cpp/application/application_delegate.h" |
| 10 #include "mojo/public/cpp/application/connection_context.h" | 10 #include "mojo/public/cpp/application/connection_context.h" |
| 11 #include "mojo/public/cpp/application/service_provider_impl.h" | 11 #include "mojo/public/cpp/application/service_provider_impl.h" |
| 12 #include "mojo/public/cpp/bindings/interface_ptr.h" | 12 #include "mojo/public/cpp/bindings/interface_ptr.h" |
| 13 #include "mojo/public/cpp/bindings/interface_request.h" | 13 #include "mojo/public/cpp/bindings/interface_request.h" |
| 14 #include "mojo/public/cpp/environment/logging.h" | 14 #include "mojo/public/cpp/environment/logging.h" |
| 15 #include "mojo/public/cpp/system/message_pipe.h" | |
| 16 | 15 |
| 17 namespace mojo { | 16 namespace mojo { |
| 18 | 17 |
| 19 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, | 18 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, |
| 20 InterfaceRequest<Application> request) | 19 InterfaceRequest<Application> request) |
| 21 : delegate_(delegate), binding_(this, request.Pass()) {} | 20 : delegate_(delegate), application_binding_(this, request.Pass()) {} |
| 22 | 21 |
| 23 ApplicationImpl::~ApplicationImpl() {} | 22 ApplicationImpl::~ApplicationImpl() {} |
| 24 | 23 |
| 25 bool ApplicationImpl::HasArg(const std::string& arg) const { | 24 bool ApplicationImpl::HasArg(const std::string& arg) const { |
| 26 return std::find(args_.begin(), args_.end(), arg) != args_.end(); | 25 return std::find(args_.begin(), args_.end(), arg) != args_.end(); |
| 27 } | 26 } |
| 28 | 27 |
| 29 InterfaceHandle<ApplicationConnector> | |
| 30 ApplicationImpl::CreateApplicationConnector() { | |
| 31 MOJO_CHECK(shell_); | |
| 32 InterfaceHandle<ApplicationConnector> application_connector; | |
| 33 shell_->CreateApplicationConnector(GetProxy(&application_connector)); | |
| 34 return application_connector; | |
| 35 } | |
| 36 | |
| 37 void ApplicationImpl::WaitForInitialize() { | 28 void ApplicationImpl::WaitForInitialize() { |
| 38 if (!shell_) | 29 if (!shell_) |
| 39 binding_.WaitForIncomingMethodCall(); | 30 application_binding_.WaitForIncomingMethodCall(); |
| 40 } | 31 } |
| 41 | 32 |
| 42 void ApplicationImpl::UnbindConnections( | 33 void ApplicationImpl::UnbindConnections( |
| 43 InterfaceRequest<Application>* application_request, | 34 InterfaceRequest<Application>* application_request, |
| 44 ShellPtr* shell) { | 35 ShellPtr* shell) { |
| 45 *application_request = binding_.Unbind(); | 36 *application_request = application_binding_.Unbind(); |
| 46 shell->Bind(shell_.PassInterfaceHandle()); | 37 shell->Bind(shell_.PassInterfaceHandle()); |
| 47 } | 38 } |
| 48 | 39 |
| 49 void ApplicationImpl::Initialize(InterfaceHandle<Shell> shell, | 40 void ApplicationImpl::Initialize(InterfaceHandle<Shell> shell, |
| 50 Array<String> args, | 41 Array<String> args, |
| 51 const mojo::String& url) { | 42 const mojo::String& url) { |
| 52 shell_ = ShellPtr::Create(std::move(shell)); | 43 shell_ = ShellPtr::Create(std::move(shell)); |
| 53 shell_.set_connection_error_handler([this]() { | 44 shell_.set_connection_error_handler([this]() { |
| 54 delegate_->Quit(); | 45 delegate_->Quit(); |
| 55 service_provider_impls_.clear(); | 46 service_provider_impls_.clear(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 79 return; | 70 return; |
| 80 service_provider_impls_.push_back(std::move(service_provider_impl)); | 71 service_provider_impls_.push_back(std::move(service_provider_impl)); |
| 81 } | 72 } |
| 82 | 73 |
| 83 void ApplicationImpl::RequestQuit() { | 74 void ApplicationImpl::RequestQuit() { |
| 84 delegate_->Quit(); | 75 delegate_->Quit(); |
| 85 Terminate(); | 76 Terminate(); |
| 86 } | 77 } |
| 87 | 78 |
| 88 } // namespace mojo | 79 } // namespace mojo |
| OLD | NEW |