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