| Index: third_party/mojo/src/mojo/public/cpp/application/lib/application_impl.cc
|
| diff --git a/third_party/mojo/src/mojo/public/cpp/application/lib/application_impl.cc b/third_party/mojo/src/mojo/public/cpp/application/lib/application_impl.cc
|
| index 894060d8bf2eb064a7585c442429622c4320d8da..4d1f8dcf3442827c84090373b6a7e2f06c1048fd 100644
|
| --- a/third_party/mojo/src/mojo/public/cpp/application/lib/application_impl.cc
|
| +++ b/third_party/mojo/src/mojo/public/cpp/application/lib/application_impl.cc
|
| @@ -25,15 +25,11 @@ class ApplicationImpl::ShellPtrWatcher : public ErrorHandler {
|
| };
|
|
|
| ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
|
| - ScopedMessagePipeHandle shell_handle)
|
| - : initialized_(false), delegate_(delegate), shell_watch_(nullptr) {
|
| - BindShell(shell_handle.Pass());
|
| -}
|
| -
|
| -ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
|
| - MojoHandle shell_handle)
|
| - : initialized_(false), delegate_(delegate), shell_watch_(nullptr) {
|
| - BindShell(MakeScopedHandle(MessagePipeHandle(shell_handle)));
|
| + InterfaceRequest<Application> request)
|
| + : initialized_(false),
|
| + delegate_(delegate),
|
| + binding_(this, request.Pass()),
|
| + shell_watch_(nullptr) {
|
| }
|
|
|
| bool ApplicationImpl::HasArg(const std::string& arg) const {
|
| @@ -60,7 +56,7 @@ ApplicationImpl::~ApplicationImpl() {
|
|
|
| ApplicationConnection* ApplicationImpl::ConnectToApplication(
|
| const String& application_url) {
|
| - MOJO_CHECK(initialized_);
|
| + MOJO_CHECK(shell_);
|
| ServiceProviderPtr local_services;
|
| InterfaceRequest<ServiceProvider> local_request = GetProxy(&local_services);
|
| ServiceProviderPtr remote_services;
|
| @@ -76,29 +72,24 @@ ApplicationConnection* ApplicationImpl::ConnectToApplication(
|
| return registry;
|
| }
|
|
|
| -bool ApplicationImpl::WaitForInitialize() {
|
| - MOJO_CHECK(!initialized_);
|
| - bool result = shell_.WaitForIncomingMethodCall();
|
| - MOJO_CHECK(initialized_ || !result);
|
| - return result;
|
| -}
|
| -
|
| -ScopedMessagePipeHandle ApplicationImpl::UnbindShell() {
|
| - return shell_.PassMessagePipe();
|
| -}
|
| -
|
| -void ApplicationImpl::Initialize(Array<String> args) {
|
| - MOJO_CHECK(!initialized_);
|
| - initialized_ = true;
|
| +void ApplicationImpl::Initialize(ShellPtr shell, Array<String> args) {
|
| + shell_ = shell.Pass();
|
| + shell_watch_ = new ShellPtrWatcher(this);
|
| + shell_.set_error_handler(shell_watch_);
|
| args_ = args.To<std::vector<std::string>>();
|
| delegate_->Initialize(this);
|
| }
|
|
|
| -void ApplicationImpl::BindShell(ScopedMessagePipeHandle shell_handle) {
|
| - shell_watch_ = new ShellPtrWatcher(this);
|
| - shell_.Bind(shell_handle.Pass());
|
| - shell_.set_client(this);
|
| - shell_.set_error_handler(shell_watch_);
|
| +void ApplicationImpl::WaitForInitialize() {
|
| + if (!shell_)
|
| + binding_.WaitForIncomingMethodCall();
|
| +}
|
| +
|
| +void ApplicationImpl::UnbindConnections(
|
| + InterfaceRequest<Application>* application_request,
|
| + ShellPtr* shell) {
|
| + *application_request = binding_.Unbind();
|
| + shell->Bind(shell_.PassMessagePipe());
|
| }
|
|
|
| void ApplicationImpl::AcceptConnection(
|
|
|