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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "mojo/application/public/cpp/application_delegate.h" | 9 #include "mojo/application/public/cpp/application_delegate.h" |
10 #include "mojo/application/public/cpp/lib/service_registry.h" | 10 #include "mojo/application/public/cpp/lib/service_registry.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 base::Bind(&DefaultTerminationClosure)) { | 28 base::Bind(&DefaultTerminationClosure)) { |
29 } | 29 } |
30 | 30 |
31 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, | 31 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, |
32 InterfaceRequest<Application> request, | 32 InterfaceRequest<Application> request, |
33 const base::Closure& termination_closure) | 33 const base::Closure& termination_closure) |
34 : delegate_(delegate), | 34 : delegate_(delegate), |
35 binding_(this, request.Pass()), | 35 binding_(this, request.Pass()), |
36 termination_closure_(termination_closure), | 36 termination_closure_(termination_closure), |
37 app_lifetime_helper_(this), | 37 app_lifetime_helper_(this), |
38 quit_requested_(false) { | 38 quit_requested_(false), |
| 39 weak_factory_(this) { |
39 } | 40 } |
40 | 41 |
41 void ApplicationImpl::ClearConnections() { | 42 void ApplicationImpl::ClearConnections() { |
42 for (ServiceRegistryList::iterator i(incoming_service_registries_.begin()); | 43 for (ServiceRegistryList::iterator i(incoming_service_registries_.begin()); |
43 i != incoming_service_registries_.end(); | 44 i != incoming_service_registries_.end(); |
44 ++i) | 45 ++i) |
45 delete *i; | 46 delete *i; |
46 for (ServiceRegistryList::iterator i(outgoing_service_registries_.begin()); | 47 for (ServiceRegistryList::iterator i(outgoing_service_registries_.begin()); |
47 i != outgoing_service_registries_.end(); | 48 i != outgoing_service_registries_.end(); |
48 ++i) | 49 ++i) |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 void ApplicationImpl::OnQuitRequested(const Callback<void(bool)>& callback) { | 134 void ApplicationImpl::OnQuitRequested(const Callback<void(bool)>& callback) { |
134 // If by the time we got the reply from the shell, more requests had come in | 135 // If by the time we got the reply from the shell, more requests had come in |
135 // then we don't want to quit the app anymore so we return false. Otherwise | 136 // then we don't want to quit the app anymore so we return false. Otherwise |
136 // |quit_requested_| is true so we tell the shell to proceed with the quit. | 137 // |quit_requested_| is true so we tell the shell to proceed with the quit. |
137 callback.Run(quit_requested_); | 138 callback.Run(quit_requested_); |
138 if (quit_requested_) | 139 if (quit_requested_) |
139 QuitNow(); | 140 QuitNow(); |
140 } | 141 } |
141 | 142 |
142 void ApplicationImpl::OnConnectionError() { | 143 void ApplicationImpl::OnConnectionError() { |
| 144 base::WeakPtr<ApplicationImpl> ptr(weak_factory_.GetWeakPtr()); |
143 QuitNow(); | 145 QuitNow(); |
| 146 if (!ptr) |
| 147 return; |
144 shell_ = nullptr; | 148 shell_ = nullptr; |
145 } | 149 } |
146 | 150 |
147 } // namespace mojo | 151 } // namespace mojo |
OLD | NEW |