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/application/public/cpp/application_impl.h" | 5 #include "mojo/application/public/cpp/application_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 ApplicationImpl::~ApplicationImpl() { | 59 ApplicationImpl::~ApplicationImpl() { |
60 DCHECK(!in_destructor_); | 60 DCHECK(!in_destructor_); |
61 in_destructor_ = true; | 61 in_destructor_ = true; |
62 ClearConnections(); | 62 ClearConnections(); |
63 app_lifetime_helper_.ApplicationTerminated(); | 63 app_lifetime_helper_.ApplicationTerminated(); |
64 } | 64 } |
65 | 65 |
66 ApplicationConnection* ApplicationImpl::ConnectToApplication( | 66 ApplicationConnection* ApplicationImpl::ConnectToApplication( |
67 mojo::URLRequestPtr request) { | 67 mojo::URLRequestPtr request) { |
68 MOJO_CHECK(shell_); | 68 if (!shell_) |
| 69 return nullptr; |
69 ServiceProviderPtr local_services; | 70 ServiceProviderPtr local_services; |
70 InterfaceRequest<ServiceProvider> local_request = GetProxy(&local_services); | 71 InterfaceRequest<ServiceProvider> local_request = GetProxy(&local_services); |
71 ServiceProviderPtr remote_services; | 72 ServiceProviderPtr remote_services; |
72 std::string application_url = request->url.To<std::string>(); | 73 std::string application_url = request->url.To<std::string>(); |
73 shell_->ConnectToApplication(request.Pass(), GetProxy(&remote_services), | 74 shell_->ConnectToApplication(request.Pass(), GetProxy(&remote_services), |
74 local_services.Pass()); | 75 local_services.Pass()); |
75 internal::ServiceRegistry* registry = new internal::ServiceRegistry( | 76 internal::ServiceRegistry* registry = new internal::ServiceRegistry( |
76 this, application_url, application_url, remote_services.Pass(), | 77 this, application_url, application_url, remote_services.Pass(), |
77 local_request.Pass()); | 78 local_request.Pass()); |
78 if (!delegate_->ConfigureOutgoingConnection(registry)) { | 79 if (!delegate_->ConfigureOutgoingConnection(registry)) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 166 |
166 void ApplicationImpl::OnConnectionError() { | 167 void ApplicationImpl::OnConnectionError() { |
167 base::WeakPtr<ApplicationImpl> ptr(weak_factory_.GetWeakPtr()); | 168 base::WeakPtr<ApplicationImpl> ptr(weak_factory_.GetWeakPtr()); |
168 QuitNow(); | 169 QuitNow(); |
169 if (!ptr) | 170 if (!ptr) |
170 return; | 171 return; |
171 shell_ = nullptr; | 172 shell_ = nullptr; |
172 } | 173 } |
173 | 174 |
174 } // namespace mojo | 175 } // namespace mojo |
OLD | NEW |