| 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 | 15 |
| 16 namespace mojo { | 16 namespace mojo { |
| 17 | 17 |
| 18 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, | 18 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, |
| 19 InterfaceRequest<Application> request) | 19 InterfaceRequest<Application> request) |
| 20 : delegate_(delegate), application_binding_(this, request.Pass()) {} | 20 : delegate_(delegate), application_binding_(this, request.Pass()) {} |
| 21 | 21 |
| 22 ApplicationImpl::~ApplicationImpl() {} | 22 ApplicationImpl::~ApplicationImpl() {} |
| 23 | 23 |
| 24 bool ApplicationImpl::HasArg(const std::string& arg) const { | 24 bool ApplicationImpl::HasArg(const std::string& arg) const { |
| 25 return std::find(args_.begin(), args_.end(), arg) != args_.end(); | 25 return std::find(args_.begin(), args_.end(), arg) != args_.end(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void ApplicationImpl::WaitForInitialize() { | |
| 29 if (!shell_) | |
| 30 application_binding_.WaitForIncomingMethodCall(); | |
| 31 } | |
| 32 | |
| 33 void ApplicationImpl::UnbindConnections( | |
| 34 InterfaceRequest<Application>* application_request, | |
| 35 ShellPtr* shell) { | |
| 36 *application_request = application_binding_.Unbind(); | |
| 37 shell->Bind(shell_.PassInterfaceHandle()); | |
| 38 } | |
| 39 | |
| 40 void ApplicationImpl::Initialize(InterfaceHandle<Shell> shell, | 28 void ApplicationImpl::Initialize(InterfaceHandle<Shell> shell, |
| 41 Array<String> args, | 29 Array<String> args, |
| 42 const mojo::String& url) { | 30 const mojo::String& url) { |
| 43 shell_ = ShellPtr::Create(std::move(shell)); | 31 shell_ = ShellPtr::Create(std::move(shell)); |
| 44 shell_.set_connection_error_handler([this]() { | 32 shell_.set_connection_error_handler([this]() { |
| 45 delegate_->Quit(); | 33 delegate_->Quit(); |
| 46 service_provider_impls_.clear(); | 34 service_provider_impls_.clear(); |
| 47 Terminate(); | 35 Terminate(); |
| 48 }); | 36 }); |
| 49 url_ = url; | 37 url_ = url; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 70 return; | 58 return; |
| 71 service_provider_impls_.push_back(std::move(service_provider_impl)); | 59 service_provider_impls_.push_back(std::move(service_provider_impl)); |
| 72 } | 60 } |
| 73 | 61 |
| 74 void ApplicationImpl::RequestQuit() { | 62 void ApplicationImpl::RequestQuit() { |
| 75 delegate_->Quit(); | 63 delegate_->Quit(); |
| 76 Terminate(); | 64 Terminate(); |
| 77 } | 65 } |
| 78 | 66 |
| 79 } // namespace mojo | 67 } // namespace mojo |
| OLD | NEW |