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/android/mojo_main.h" | 5 #include "mojo/shell/android/mojo_main.h" |
6 | 6 |
7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "jni/MojoMain_jni.h" | 14 #include "jni/MojoMain_jni.h" |
15 #include "mojo/public/shell/application.h" | 15 #include "mojo/public/shell/application.h" |
16 #include "mojo/services/native_viewport/native_viewport_service.h" | 16 #include "mojo/services/native_viewport/native_viewport_service.h" |
17 #include "mojo/shell/context.h" | 17 #include "mojo/shell/context.h" |
18 #include "mojo/shell/init.h" | 18 #include "mojo/shell/init.h" |
19 #include "mojo/shell/run.h" | 19 #include "mojo/shell/run.h" |
20 #include "mojo/shell/service_connector.h" | 20 #include "mojo/shell/service_manager.h" |
21 #include "ui/gl/gl_surface_egl.h" | 21 #include "ui/gl/gl_surface_egl.h" |
22 | 22 |
23 using base::LazyInstance; | 23 using base::LazyInstance; |
24 | 24 |
25 namespace mojo { | 25 namespace mojo { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 LazyInstance<scoped_ptr<base::MessageLoop> > g_java_message_loop = | 29 LazyInstance<scoped_ptr<base::MessageLoop> > g_java_message_loop = |
30 LAZY_INSTANCE_INITIALIZER; | 30 LAZY_INSTANCE_INITIALIZER; |
31 | 31 |
32 LazyInstance<scoped_ptr<shell::Context> > g_context = | 32 LazyInstance<scoped_ptr<shell::Context> > g_context = |
33 LAZY_INSTANCE_INITIALIZER; | 33 LAZY_INSTANCE_INITIALIZER; |
34 | 34 |
35 class NativeViewportServiceLoader : public shell::ServiceConnector::Loader { | 35 class NativeViewportServiceLoader : public shell::ServiceManager::Loader { |
36 public: | 36 public: |
37 NativeViewportServiceLoader() {} | 37 NativeViewportServiceLoader() {} |
38 virtual ~NativeViewportServiceLoader() {} | 38 virtual ~NativeViewportServiceLoader() {} |
39 | 39 |
40 private: | 40 private: |
41 virtual void Load(const GURL& url, | 41 virtual void Load(const GURL& url, |
42 ScopedShellHandle service_handle) | 42 ScopedShellHandle service_handle) |
43 MOJO_OVERRIDE { | 43 MOJO_OVERRIDE { |
44 app_.reset(CreateNativeViewportService(g_context.Get().get(), | 44 app_.reset(CreateNativeViewportService(g_context.Get().get(), |
45 service_handle.Pass())); | 45 service_handle.Pass())); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 argv.push_back(app_url); | 85 argv.push_back(app_url); |
86 CommandLine::ForCurrentProcess()->InitFromArgv(argv); | 86 CommandLine::ForCurrentProcess()->InitFromArgv(argv); |
87 } | 87 } |
88 | 88 |
89 base::android::ScopedJavaGlobalRef<jobject> activity; | 89 base::android::ScopedJavaGlobalRef<jobject> activity; |
90 activity.Reset(env, context); | 90 activity.Reset(env, context); |
91 | 91 |
92 shell::Context* shell_context = new shell::Context(); | 92 shell::Context* shell_context = new shell::Context(); |
93 shell_context->set_activity(activity.obj()); | 93 shell_context->set_activity(activity.obj()); |
94 g_viewport_service_loader.Get().reset(new NativeViewportServiceLoader()); | 94 g_viewport_service_loader.Get().reset(new NativeViewportServiceLoader()); |
95 shell_context->service_connector()->SetLoaderForURL( | 95 shell_context->service_manager()->SetLoaderForURL( |
96 g_viewport_service_loader.Get().get(), | 96 g_viewport_service_loader.Get().get(), |
97 GURL("mojo:mojo_native_viewport_service")); | 97 GURL("mojo:mojo_native_viewport_service")); |
98 | 98 |
99 g_context.Get().reset(shell_context); | 99 g_context.Get().reset(shell_context); |
100 shell::Run(shell_context); | 100 shell::Run(shell_context); |
101 } | 101 } |
102 | 102 |
103 bool RegisterMojoMain(JNIEnv* env) { | 103 bool RegisterMojoMain(JNIEnv* env) { |
104 return RegisterNativesImpl(env); | 104 return RegisterNativesImpl(env); |
105 } | 105 } |
106 | 106 |
107 } // namespace mojo | 107 } // namespace mojo |
OLD | NEW |