Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: sky/shell/sky_main.cc

Issue 936883002: Connect Sky and Ganesh in SkyShell (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address review comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/shell/shell.cc ('k') | sky/shell/sky_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "sky/shell/sky_main.h" 5 #include "sky/shell/sky_main.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
(...skipping 13 matching lines...) Expand all
24 using base::LazyInstance; 24 using base::LazyInstance;
25 25
26 namespace sky { 26 namespace sky {
27 namespace shell { 27 namespace shell {
28 28
29 namespace { 29 namespace {
30 30
31 LazyInstance<scoped_ptr<base::MessageLoop>> g_java_message_loop = 31 LazyInstance<scoped_ptr<base::MessageLoop>> g_java_message_loop =
32 LAZY_INSTANCE_INITIALIZER; 32 LAZY_INSTANCE_INITIALIZER;
33 33
34 LazyInstance<base::android::ScopedJavaGlobalRef<jobject>> g_main_activiy =
35 LAZY_INSTANCE_INITIALIZER;
36
37 LazyInstance<scoped_ptr<Shell>> g_shell = LAZY_INSTANCE_INITIALIZER;
38
39 void InitializeLogging() { 34 void InitializeLogging() {
40 logging::LoggingSettings settings; 35 logging::LoggingSettings settings;
41 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; 36 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
42 logging::InitLogging(settings); 37 logging::InitLogging(settings);
43 // To view log output with IDs and timestamps use "adb logcat -v threadtime". 38 // To view log output with IDs and timestamps use "adb logcat -v threadtime".
44 logging::SetLogItems(false, // Process ID 39 logging::SetLogItems(false, // Process ID
45 false, // Thread ID 40 false, // Thread ID
46 false, // Timestamp 41 false, // Timestamp
47 false); // Tick count 42 false); // Tick count
48 } 43 }
49 44
50 } // namespace 45 } // namespace
51 46
52 static void Init(JNIEnv* env, 47 static void Init(JNIEnv* env, jclass clazz, jobject context) {
53 jclass clazz, 48 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context);
54 jobject activity) { 49 base::android::InitApplicationContext(env, scoped_context);
55 g_main_activiy.Get().Reset(env, activity);
56
57 base::android::ScopedJavaLocalRef<jobject> scoped_activity(env, activity);
58 base::android::InitApplicationContext(env, scoped_activity);
59 50
60 base::CommandLine::Init(0, nullptr); 51 base::CommandLine::Init(0, nullptr);
61
62 InitializeLogging(); 52 InitializeLogging();
63 53
64 g_java_message_loop.Get().reset(new base::MessageLoopForUI); 54 g_java_message_loop.Get().reset(new base::MessageLoopForUI);
65 base::MessageLoopForUI::current()->Start(); 55 base::MessageLoopForUI::current()->Start();
66 56
67 base::i18n::InitializeICU(); 57 base::i18n::InitializeICU();
68 gfx::GLSurface::InitializeOneOff(); 58 gfx::GLSurface::InitializeOneOff();
69 59
70 g_shell.Get().reset(new Shell(g_java_message_loop.Get()->task_runner())); 60 Shell::Init(g_java_message_loop.Get()->task_runner());
71
72 g_java_message_loop.Get()->PostTask(
73 FROM_HERE,
74 base::Bind(&Shell::Init, base::Unretained(g_shell.Get().get())));
75 }
76
77 static jboolean Start(JNIEnv* env, jclass clazz) {
78 LOG(INFO) << "Native code started!";
79 return true;
80 } 61 }
81 62
82 bool RegisterSkyMain(JNIEnv* env) { 63 bool RegisterSkyMain(JNIEnv* env) {
83 return RegisterNativesImpl(env); 64 return RegisterNativesImpl(env);
84 } 65 }
85 66
86 } // namespace sky 67 } // namespace sky
87 } // namespace mojo 68 } // namespace mojo
OLDNEW
« no previous file with comments | « sky/shell/shell.cc ('k') | sky/shell/sky_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698