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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "gpu/command_buffer/service/mailbox_manager.h" | 15 #include "gpu/command_buffer/service/mailbox_manager.h" |
16 #include "mojo/application_manager/application_loader.h" | 16 #include "mojo/application_manager/application_loader.h" |
17 #include "mojo/application_manager/application_manager.h" | 17 #include "mojo/application_manager/application_manager.h" |
18 #include "mojo/application_manager/background_shell_application_loader.h" | 18 #include "mojo/application_manager/background_shell_application_loader.h" |
19 #include "mojo/embedder/embedder.h" | 19 #include "mojo/embedder/embedder.h" |
20 #include "mojo/embedder/simple_platform_support.h" | 20 #include "mojo/embedder/simple_platform_support.h" |
21 #include "mojo/public/cpp/application/application_connection.h" | 21 #include "mojo/public/cpp/application/application_connection.h" |
22 #include "mojo/public/cpp/application/application_delegate.h" | 22 #include "mojo/public/cpp/application/application_delegate.h" |
23 #include "mojo/public/cpp/application/application_impl.h" | 23 #include "mojo/public/cpp/application/application_impl.h" |
24 #include "mojo/services/native_viewport/gpu_impl.h" | |
25 #include "mojo/services/native_viewport/native_viewport_impl.h" | |
26 #include "mojo/shell/dynamic_application_loader.h" | 24 #include "mojo/shell/dynamic_application_loader.h" |
27 #include "mojo/shell/in_process_dynamic_service_runner.h" | 25 #include "mojo/shell/in_process_dynamic_service_runner.h" |
28 #include "mojo/shell/out_of_process_dynamic_service_runner.h" | 26 #include "mojo/shell/out_of_process_dynamic_service_runner.h" |
29 #include "mojo/shell/switches.h" | 27 #include "mojo/shell/switches.h" |
30 #include "mojo/shell/ui_application_loader_android.h" | 28 #include "mojo/shell/ui_application_loader_android.h" |
31 #include "mojo/spy/spy.h" | 29 #include "mojo/spy/spy.h" |
32 #include "ui/gl/gl_share_group.h" | |
33 | 30 |
34 #if defined(OS_LINUX) | 31 #if defined(OS_LINUX) |
35 #include "mojo/shell/dbus_application_loader_linux.h" | 32 #include "mojo/shell/dbus_application_loader_linux.h" |
36 #endif // defined(OS_LINUX) | 33 #endif // defined(OS_LINUX) |
37 | 34 |
38 #if defined(OS_ANDROID) | 35 #if defined(OS_ANDROID) |
| 36 #include "mojo/services/native_viewport/gpu_impl.h" |
| 37 #include "mojo/services/native_viewport/native_viewport_impl.h" |
39 #include "mojo/shell/network_application_loader.h" | 38 #include "mojo/shell/network_application_loader.h" |
| 39 #include "ui/gl/gl_share_group.h" |
40 #endif // defined(OS_ANDROID) | 40 #endif // defined(OS_ANDROID) |
41 | 41 |
42 #if defined(USE_AURA) | |
43 #include "mojo/shell/view_manager_loader.h" | |
44 #endif | |
45 | |
46 namespace mojo { | 42 namespace mojo { |
47 namespace shell { | 43 namespace shell { |
48 namespace { | 44 namespace { |
49 | 45 |
50 // These mojo: URLs are loaded directly from the local filesystem. They | 46 // These mojo: URLs are loaded directly from the local filesystem. They |
51 // correspond to shared libraries bundled alongside the mojo_shell. | 47 // correspond to shared libraries bundled alongside the mojo_shell. |
52 const char* kLocalMojoURLs[] = { | 48 const char* kLocalMojoURLs[] = { |
53 "mojo:mojo_network_service", | 49 "mojo:mojo_network_service", |
54 }; | 50 }; |
55 | 51 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 class EmptyServiceProvider : public InterfaceImpl<ServiceProvider> { | 100 class EmptyServiceProvider : public InterfaceImpl<ServiceProvider> { |
105 private: | 101 private: |
106 virtual void ConnectToService(const mojo::String& service_name, | 102 virtual void ConnectToService(const mojo::String& service_name, |
107 ScopedMessagePipeHandle client_handle) | 103 ScopedMessagePipeHandle client_handle) |
108 MOJO_OVERRIDE { | 104 MOJO_OVERRIDE { |
109 } | 105 } |
110 }; | 106 }; |
111 | 107 |
112 } // namespace | 108 } // namespace |
113 | 109 |
| 110 #if defined(OS_ANDROID) |
114 class Context::NativeViewportApplicationLoader | 111 class Context::NativeViewportApplicationLoader |
115 : public ApplicationLoader, | 112 : public ApplicationLoader, |
116 public ApplicationDelegate, | 113 public ApplicationDelegate, |
117 public InterfaceFactory<NativeViewport>, | 114 public InterfaceFactory<NativeViewport>, |
118 public InterfaceFactory<Gpu> { | 115 public InterfaceFactory<Gpu> { |
119 public: | 116 public: |
120 NativeViewportApplicationLoader() | 117 NativeViewportApplicationLoader() |
121 : share_group_(new gfx::GLShareGroup), | 118 : share_group_(new gfx::GLShareGroup), |
122 mailbox_manager_(new gpu::gles2::MailboxManager) {} | 119 mailbox_manager_(new gpu::gles2::MailboxManager) {} |
123 virtual ~NativeViewportApplicationLoader() {} | 120 virtual ~NativeViewportApplicationLoader() {} |
(...skipping 30 matching lines...) Expand all Loading... |
154 InterfaceRequest<Gpu> request) OVERRIDE { | 151 InterfaceRequest<Gpu> request) OVERRIDE { |
155 BindToRequest(new GpuImpl(share_group_.get(), mailbox_manager_.get()), | 152 BindToRequest(new GpuImpl(share_group_.get(), mailbox_manager_.get()), |
156 &request); | 153 &request); |
157 } | 154 } |
158 | 155 |
159 scoped_refptr<gfx::GLShareGroup> share_group_; | 156 scoped_refptr<gfx::GLShareGroup> share_group_; |
160 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | 157 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; |
161 scoped_ptr<ApplicationImpl> app_; | 158 scoped_ptr<ApplicationImpl> app_; |
162 DISALLOW_COPY_AND_ASSIGN(NativeViewportApplicationLoader); | 159 DISALLOW_COPY_AND_ASSIGN(NativeViewportApplicationLoader); |
163 }; | 160 }; |
| 161 #endif |
164 | 162 |
165 Context::Context() { | 163 Context::Context() { |
166 DCHECK(!base::MessageLoop::current()); | 164 DCHECK(!base::MessageLoop::current()); |
167 } | 165 } |
168 | 166 |
169 Context::~Context() { | 167 Context::~Context() { |
170 DCHECK(!base::MessageLoop::current()); | 168 DCHECK(!base::MessageLoop::current()); |
171 } | 169 } |
172 | 170 |
173 void Context::Init() { | 171 void Context::Init() { |
(...skipping 20 matching lines...) Expand all Loading... |
194 | 192 |
195 // The native viewport service synchronously waits for certain messages. If we | 193 // The native viewport service synchronously waits for certain messages. If we |
196 // don't run it on its own thread we can easily deadlock. Long term native | 194 // don't run it on its own thread we can easily deadlock. Long term native |
197 // viewport should run its own process so that this isn't an issue. | 195 // viewport should run its own process so that this isn't an issue. |
198 #if defined(OS_ANDROID) | 196 #if defined(OS_ANDROID) |
199 application_manager_.SetLoaderForURL( | 197 application_manager_.SetLoaderForURL( |
200 scoped_ptr<ApplicationLoader>(new UIApplicationLoader( | 198 scoped_ptr<ApplicationLoader>(new UIApplicationLoader( |
201 scoped_ptr<ApplicationLoader>(new NativeViewportApplicationLoader()), | 199 scoped_ptr<ApplicationLoader>(new NativeViewportApplicationLoader()), |
202 this)), | 200 this)), |
203 GURL("mojo:mojo_native_viewport_service")); | 201 GURL("mojo:mojo_native_viewport_service")); |
204 #else | |
205 { | |
206 scoped_ptr<BackgroundShellApplicationLoader> loader( | |
207 new BackgroundShellApplicationLoader( | |
208 scoped_ptr<ApplicationLoader>( | |
209 new NativeViewportApplicationLoader()), | |
210 "native_viewport", | |
211 base::MessageLoop::TYPE_UI)); | |
212 application_manager_.SetLoaderForURL( | |
213 loader.PassAs<ApplicationLoader>(), | |
214 GURL("mojo:mojo_native_viewport_service")); | |
215 } | |
216 #endif | |
217 #if defined(USE_AURA) | |
218 // TODO(sky): need a better way to find this. It shouldn't be linked in. | |
219 application_manager_.SetLoaderForURL( | |
220 scoped_ptr<ApplicationLoader>(new ViewManagerLoader()), | |
221 GURL("mojo:mojo_view_manager")); | |
222 #endif | 202 #endif |
223 | 203 |
224 #if defined(OS_LINUX) | 204 #if defined(OS_LINUX) |
225 application_manager_.SetLoaderForScheme( | 205 application_manager_.SetLoaderForScheme( |
226 scoped_ptr<ApplicationLoader>(new DBusApplicationLoader(this)), "dbus"); | 206 scoped_ptr<ApplicationLoader>(new DBusApplicationLoader(this)), "dbus"); |
227 #endif // defined(OS_LINUX) | 207 #endif // defined(OS_LINUX) |
228 | 208 |
229 if (command_line->HasSwitch(switches::kSpy)) { | 209 if (command_line->HasSwitch(switches::kSpy)) { |
230 spy_.reset( | 210 spy_.reset( |
231 new mojo::Spy(&application_manager_, | 211 new mojo::Spy(&application_manager_, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 ScopedMessagePipeHandle Context::ConnectToServiceByName( | 247 ScopedMessagePipeHandle Context::ConnectToServiceByName( |
268 const GURL& application_url, | 248 const GURL& application_url, |
269 const std::string& service_name) { | 249 const std::string& service_name) { |
270 app_urls_.insert(application_url); | 250 app_urls_.insert(application_url); |
271 return application_manager_.ConnectToServiceByName( | 251 return application_manager_.ConnectToServiceByName( |
272 application_url, service_name).Pass(); | 252 application_url, service_name).Pass(); |
273 } | 253 } |
274 | 254 |
275 } // namespace shell | 255 } // namespace shell |
276 } // namespace mojo | 256 } // namespace mojo |
OLD | NEW |