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" |
(...skipping 11 matching lines...) Expand all Loading... |
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" | 24 #include "mojo/services/native_viewport/gpu_impl.h" |
25 #include "mojo/services/native_viewport/native_viewport_impl.h" | 25 #include "mojo/services/native_viewport/native_viewport_impl.h" |
26 #include "mojo/shell/dynamic_application_loader.h" | 26 #include "mojo/shell/dynamic_application_loader.h" |
27 #include "mojo/shell/in_process_dynamic_service_runner.h" | 27 #include "mojo/shell/in_process_dynamic_service_runner.h" |
28 #include "mojo/shell/out_of_process_dynamic_service_runner.h" | 28 #include "mojo/shell/out_of_process_dynamic_service_runner.h" |
29 #include "mojo/shell/switches.h" | 29 #include "mojo/shell/switches.h" |
30 #include "mojo/shell/ui_application_loader_android.h" | 30 #include "mojo/shell/ui_application_loader_android.h" |
31 #include "mojo/spy/spy.h" | 31 #include "mojo/spy/spy.h" |
32 #include "ui/gl/gl_share_group.h" | |
33 | 32 |
34 #if defined(OS_LINUX) | 33 #if defined(OS_LINUX) |
35 #include "mojo/shell/dbus_application_loader_linux.h" | 34 #include "mojo/shell/dbus_application_loader_linux.h" |
36 #endif // defined(OS_LINUX) | 35 #endif // defined(OS_LINUX) |
37 | 36 |
38 #if defined(OS_ANDROID) | 37 #if defined(OS_ANDROID) |
| 38 #include "mojo/services/native_viewport/native_viewport_impl.h" |
39 #include "mojo/shell/network_application_loader.h" | 39 #include "mojo/shell/network_application_loader.h" |
| 40 #include "ui/gl/gl_share_group.h" |
40 #endif // defined(OS_ANDROID) | 41 #endif // defined(OS_ANDROID) |
41 | 42 |
42 #if defined(USE_AURA) | |
43 #include "mojo/shell/view_manager_loader.h" | |
44 #endif | |
45 | |
46 namespace mojo { | 43 namespace mojo { |
47 namespace shell { | 44 namespace shell { |
48 namespace { | 45 namespace { |
49 | 46 |
50 // These mojo: URLs are loaded directly from the local filesystem. They | 47 // These mojo: URLs are loaded directly from the local filesystem. They |
51 // correspond to shared libraries bundled alongside the mojo_shell. | 48 // correspond to shared libraries bundled alongside the mojo_shell. |
52 const char* kLocalMojoURLs[] = { | 49 const char* kLocalMojoURLs[] = { |
53 "mojo:mojo_network_service", | 50 "mojo:mojo_network_service", |
54 }; | 51 }; |
55 | 52 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 class EmptyServiceProvider : public InterfaceImpl<ServiceProvider> { | 96 class EmptyServiceProvider : public InterfaceImpl<ServiceProvider> { |
100 private: | 97 private: |
101 virtual void ConnectToService(const mojo::String& service_name, | 98 virtual void ConnectToService(const mojo::String& service_name, |
102 ScopedMessagePipeHandle client_handle) | 99 ScopedMessagePipeHandle client_handle) |
103 MOJO_OVERRIDE { | 100 MOJO_OVERRIDE { |
104 } | 101 } |
105 }; | 102 }; |
106 | 103 |
107 } // namespace | 104 } // namespace |
108 | 105 |
109 class Context::NativeViewportApplicationLoader | 106 #if defined(OS_ANDROID) |
110 : public ApplicationLoader, | 107 class NativeViewportApplicationLoader : public ApplicationLoader, |
111 public ApplicationDelegate, | 108 public ApplicationDelegate, |
112 public InterfaceFactory<NativeViewport>, | 109 public InterfaceFactory<NativeViewport>, |
113 public InterfaceFactory<Gpu> { | 110 public InterfaceFactory<Gpu> { |
114 public: | 111 public: |
115 NativeViewportApplicationLoader() | 112 NativeViewportApplicationLoader() |
116 : share_group_(new gfx::GLShareGroup), | 113 : share_group_(new gfx::GLShareGroup), |
117 mailbox_manager_(new gpu::gles2::MailboxManager) {} | 114 mailbox_manager_(new gpu::gles2::MailboxManager) {} |
118 virtual ~NativeViewportApplicationLoader() {} | 115 virtual ~NativeViewportApplicationLoader() {} |
119 | 116 |
120 private: | 117 private: |
121 // ApplicationLoader implementation. | 118 // ApplicationLoader implementation. |
122 virtual void Load(ApplicationManager* manager, | 119 virtual void Load(ApplicationManager* manager, |
123 const GURL& url, | 120 const GURL& url, |
(...skipping 25 matching lines...) Expand all Loading... |
149 InterfaceRequest<Gpu> request) OVERRIDE { | 146 InterfaceRequest<Gpu> request) OVERRIDE { |
150 BindToRequest(new GpuImpl(share_group_.get(), mailbox_manager_.get()), | 147 BindToRequest(new GpuImpl(share_group_.get(), mailbox_manager_.get()), |
151 &request); | 148 &request); |
152 } | 149 } |
153 | 150 |
154 scoped_refptr<gfx::GLShareGroup> share_group_; | 151 scoped_refptr<gfx::GLShareGroup> share_group_; |
155 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | 152 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; |
156 scoped_ptr<ApplicationImpl> app_; | 153 scoped_ptr<ApplicationImpl> app_; |
157 DISALLOW_COPY_AND_ASSIGN(NativeViewportApplicationLoader); | 154 DISALLOW_COPY_AND_ASSIGN(NativeViewportApplicationLoader); |
158 }; | 155 }; |
| 156 #endif |
159 | 157 |
160 Context::Context() { | 158 Context::Context() { |
161 DCHECK(!base::MessageLoop::current()); | 159 DCHECK(!base::MessageLoop::current()); |
162 } | 160 } |
163 | 161 |
164 Context::~Context() { | 162 Context::~Context() { |
165 DCHECK(!base::MessageLoop::current()); | 163 DCHECK(!base::MessageLoop::current()); |
166 } | 164 } |
167 | 165 |
168 void Context::Init() { | 166 void Context::Init() { |
(...skipping 20 matching lines...) Expand all Loading... |
189 | 187 |
190 // The native viewport service synchronously waits for certain messages. If we | 188 // The native viewport service synchronously waits for certain messages. If we |
191 // don't run it on its own thread we can easily deadlock. Long term native | 189 // don't run it on its own thread we can easily deadlock. Long term native |
192 // viewport should run its own process so that this isn't an issue. | 190 // viewport should run its own process so that this isn't an issue. |
193 #if defined(OS_ANDROID) | 191 #if defined(OS_ANDROID) |
194 application_manager_.SetLoaderForURL( | 192 application_manager_.SetLoaderForURL( |
195 scoped_ptr<ApplicationLoader>(new UIApplicationLoader( | 193 scoped_ptr<ApplicationLoader>(new UIApplicationLoader( |
196 scoped_ptr<ApplicationLoader>(new NativeViewportApplicationLoader()), | 194 scoped_ptr<ApplicationLoader>(new NativeViewportApplicationLoader()), |
197 this)), | 195 this)), |
198 GURL("mojo:mojo_native_viewport_service")); | 196 GURL("mojo:mojo_native_viewport_service")); |
199 #else | |
200 { | |
201 scoped_ptr<BackgroundShellApplicationLoader> loader( | |
202 new BackgroundShellApplicationLoader( | |
203 scoped_ptr<ApplicationLoader>( | |
204 new NativeViewportApplicationLoader()), | |
205 "native_viewport", | |
206 base::MessageLoop::TYPE_UI)); | |
207 application_manager_.SetLoaderForURL( | |
208 loader.PassAs<ApplicationLoader>(), | |
209 GURL("mojo:mojo_native_viewport_service")); | |
210 } | |
211 #endif | |
212 #if defined(USE_AURA) | |
213 // TODO(sky): need a better way to find this. It shouldn't be linked in. | |
214 application_manager_.SetLoaderForURL( | |
215 scoped_ptr<ApplicationLoader>(new ViewManagerLoader()), | |
216 GURL("mojo:mojo_view_manager")); | |
217 #endif | 197 #endif |
218 | 198 |
219 #if defined(OS_LINUX) | 199 #if defined(OS_LINUX) |
220 application_manager_.SetLoaderForScheme( | 200 application_manager_.SetLoaderForScheme( |
221 scoped_ptr<ApplicationLoader>(new DBusApplicationLoader(this)), "dbus"); | 201 scoped_ptr<ApplicationLoader>(new DBusApplicationLoader(this)), "dbus"); |
222 #endif // defined(OS_LINUX) | 202 #endif // defined(OS_LINUX) |
223 | 203 |
224 if (command_line->HasSwitch(switches::kSpy)) { | 204 if (command_line->HasSwitch(switches::kSpy)) { |
225 spy_.reset( | 205 spy_.reset( |
226 new mojo::Spy(&application_manager_, | 206 new mojo::Spy(&application_manager_, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 ScopedMessagePipeHandle Context::ConnectToServiceByName( | 242 ScopedMessagePipeHandle Context::ConnectToServiceByName( |
263 const GURL& application_url, | 243 const GURL& application_url, |
264 const std::string& service_name) { | 244 const std::string& service_name) { |
265 app_urls_.insert(application_url); | 245 app_urls_.insert(application_url); |
266 return application_manager_.ConnectToServiceByName( | 246 return application_manager_.ConnectToServiceByName( |
267 application_url, service_name).Pass(); | 247 application_url, service_name).Pass(); |
268 } | 248 } |
269 | 249 |
270 } // namespace shell | 250 } // namespace shell |
271 } // namespace mojo | 251 } // namespace mojo |
OLD | NEW |