OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shell/context.h" | 5 #include "mojo/shell/context.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 scoped_ptr<ServiceLoader>(new NativeViewportServiceLoader()), | 115 scoped_ptr<ServiceLoader>(new NativeViewportServiceLoader()), |
116 this)), | 116 this)), |
117 GURL("mojo:mojo_native_viewport_service")); | 117 GURL("mojo:mojo_native_viewport_service")); |
118 #else | 118 #else |
119 { | 119 { |
120 scoped_ptr<BackgroundShellServiceLoader> loader( | 120 scoped_ptr<BackgroundShellServiceLoader> loader( |
121 new BackgroundShellServiceLoader( | 121 new BackgroundShellServiceLoader( |
122 scoped_ptr<ServiceLoader>(new NativeViewportServiceLoader()), | 122 scoped_ptr<ServiceLoader>(new NativeViewportServiceLoader()), |
123 "native_viewport", | 123 "native_viewport", |
124 base::MessageLoop::TYPE_UI)); | 124 base::MessageLoop::TYPE_UI)); |
| 125 // TODO(tim): NativeViewportService doesn't quit itself yet. |
| 126 loader->set_quit_on_shutdown(); |
125 service_manager_.SetLoaderForURL( | 127 service_manager_.SetLoaderForURL( |
126 loader.PassAs<ServiceLoader>(), | 128 loader.PassAs<ServiceLoader>(), |
127 GURL("mojo:mojo_native_viewport_service")); | 129 GURL("mojo:mojo_native_viewport_service")); |
128 } | 130 } |
129 #endif | 131 #endif |
130 #if defined(USE_AURA) | 132 #if defined(USE_AURA) |
131 // TODO(sky): need a better way to find this. It shouldn't be linked in. | 133 // TODO(sky): need a better way to find this. It shouldn't be linked in. |
132 service_manager_.SetLoaderForURL( | 134 service_manager_.SetLoaderForURL( |
133 scoped_ptr<ServiceLoader>(new ViewManagerLoader()), | 135 scoped_ptr<ServiceLoader>(new ViewManagerLoader()), |
134 GURL("mojo:mojo_view_manager")); | 136 GURL("mojo:mojo_view_manager")); |
(...skipping 12 matching lines...) Expand all Loading... |
147 | 149 |
148 #if defined(OS_ANDROID) | 150 #if defined(OS_ANDROID) |
149 // On android, the network service is bundled with the shell because the | 151 // On android, the network service is bundled with the shell because the |
150 // network stack depends on the android runtime. | 152 // network stack depends on the android runtime. |
151 { | 153 { |
152 scoped_ptr<BackgroundShellServiceLoader> loader( | 154 scoped_ptr<BackgroundShellServiceLoader> loader( |
153 new BackgroundShellServiceLoader( | 155 new BackgroundShellServiceLoader( |
154 scoped_ptr<ServiceLoader>(new NetworkServiceLoader()), | 156 scoped_ptr<ServiceLoader>(new NetworkServiceLoader()), |
155 "network_service", | 157 "network_service", |
156 base::MessageLoop::TYPE_IO)); | 158 base::MessageLoop::TYPE_IO)); |
| 159 // TODO(tim): NetworkService doesn't quit itself yet. |
| 160 loader->set_quit_on_shutdown(); |
157 service_manager_.SetLoaderForURL(loader.PassAs<ServiceLoader>(), | 161 service_manager_.SetLoaderForURL(loader.PassAs<ServiceLoader>(), |
158 GURL("mojo:mojo_network_service")); | 162 GURL("mojo:mojo_network_service")); |
159 } | 163 } |
160 #endif | 164 #endif |
161 } | 165 } |
162 | 166 |
| 167 void Context::Shutdown() { |
| 168 // mojo_view_manager uses native_viewport. Destroy mojo_view_manager first so |
| 169 // that there aren't shutdown ordering issues. Once native viewport service is |
| 170 // moved into its own process this can likely be nuked. |
| 171 #if defined(USE_AURA) |
| 172 service_manager_.SetLoaderForURL( |
| 173 scoped_ptr<ServiceLoader>(), |
| 174 GURL("mojo:mojo_view_manager")); |
| 175 #endif |
| 176 service_manager_.set_default_loader(scoped_ptr<ServiceLoader>()); |
| 177 service_manager_.TerminateShellConnections(); |
| 178 } |
| 179 |
163 Context::~Context() { | 180 Context::~Context() { |
164 DCHECK(!base::MessageLoop::current()); | 181 DCHECK(!base::MessageLoop::current()); |
| 182 Shutdown(); |
165 } | 183 } |
166 | 184 |
167 } // namespace shell | 185 } // namespace shell |
168 } // namespace mojo | 186 } // namespace mojo |
OLD | NEW |