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 "mojo/public/cpp/application/application_delegate.h" | 7 #include "mojo/public/cpp/application/application_delegate.h" |
8 #include "mojo/public/cpp/application/lib/service_registry.h" | 8 #include "mojo/public/cpp/application/lib/service_registry.h" |
9 #include "mojo/public/cpp/bindings/interface_ptr.h" | 9 #include "mojo/public/cpp/bindings/interface_ptr.h" |
10 | 10 |
11 namespace mojo { | 11 namespace mojo { |
12 | 12 |
13 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate) | 13 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate) |
14 : delegate_(delegate) {} | 14 : delegate_(delegate) {} |
15 | 15 |
16 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, | 16 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, |
17 ScopedMessagePipeHandle shell_handle) | 17 ScopedMessagePipeHandle shell_handle) |
18 : delegate_(delegate) { | 18 : delegate_(delegate) { |
19 BindShell(shell_handle.Pass()); | 19 BindShell(shell_handle.Pass()); |
20 } | 20 } |
21 | 21 |
22 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, | 22 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, |
23 MojoHandle shell_handle) | 23 MojoHandle shell_handle) |
24 : delegate_(delegate) { | 24 : delegate_(delegate) { |
25 BindShell(shell_handle); | 25 BindShell(shell_handle); |
26 } | 26 } |
27 | 27 |
28 ApplicationImpl::~ApplicationImpl() { | 28 void ApplicationImpl::ClearConnections() { |
29 for (ServiceRegistryList::iterator i(incoming_service_registries_.begin()); | 29 for (ServiceRegistryList::iterator i(incoming_service_registries_.begin()); |
30 i != incoming_service_registries_.end(); ++i) | 30 i != incoming_service_registries_.end(); ++i) |
31 delete *i; | 31 delete *i; |
32 for (ServiceRegistryList::iterator i(outgoing_service_registries_.begin()); | 32 for (ServiceRegistryList::iterator i(outgoing_service_registries_.begin()); |
33 i != outgoing_service_registries_.end(); ++i) | 33 i != outgoing_service_registries_.end(); ++i) |
34 delete *i; | 34 delete *i; |
| 35 incoming_service_registries_.clear(); |
| 36 outgoing_service_registries_.clear(); |
| 37 } |
| 38 |
| 39 ApplicationImpl::~ApplicationImpl() { |
| 40 ClearConnections(); |
35 } | 41 } |
36 | 42 |
37 ApplicationConnection* ApplicationImpl::ConnectToApplication( | 43 ApplicationConnection* ApplicationImpl::ConnectToApplication( |
38 const String& application_url) { | 44 const String& application_url) { |
39 ServiceProviderPtr out_service_provider; | 45 ServiceProviderPtr out_service_provider; |
40 shell_->ConnectToApplication(application_url, Get(&out_service_provider)); | 46 shell_->ConnectToApplication(application_url, Get(&out_service_provider)); |
41 internal::ServiceRegistry* registry = new internal::ServiceRegistry( | 47 internal::ServiceRegistry* registry = new internal::ServiceRegistry( |
42 this, | 48 this, |
43 application_url, | 49 application_url, |
44 out_service_provider.Pass()); | 50 out_service_provider.Pass()); |
(...skipping 19 matching lines...) Expand all Loading... |
64 ServiceProviderPtr service_provider) { | 70 ServiceProviderPtr service_provider) { |
65 internal::ServiceRegistry* registry = new internal::ServiceRegistry( | 71 internal::ServiceRegistry* registry = new internal::ServiceRegistry( |
66 this, requestor_url, service_provider.Pass()); | 72 this, requestor_url, service_provider.Pass()); |
67 if (!delegate_->ConfigureIncomingConnection(registry)) { | 73 if (!delegate_->ConfigureIncomingConnection(registry)) { |
68 delete registry; | 74 delete registry; |
69 return; | 75 return; |
70 } | 76 } |
71 incoming_service_registries_.push_back(registry); | 77 incoming_service_registries_.push_back(registry); |
72 } | 78 } |
73 | 79 |
| 80 void ApplicationImpl::Terminate() { |
| 81 ClearConnections(); |
| 82 TerminateImpl(); |
| 83 } |
| 84 |
74 } // namespace mojo | 85 } // namespace mojo |
OLD | NEW |