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

Side by Side Diff: content/shell/android/shell_library_loader.cc

Issue 10377059: Android content shell bringup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/debug/debugger.h"
7 #include "base/logging.h"
6 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
7 #include "base/android/jni_registrar.h" 9 #include "base/android/jni_registrar.h"
10 #include "content/public/app/content_main_runner.h"
8 #include "content/public/browser/android_library_loader_hooks.h" 11 #include "content/public/browser/android_library_loader_hooks.h"
9 #include "content/shell/shell_main_delegate.h" 12 #include "content/shell/shell_main_delegate.h"
10 #include "content/shell/android/shell_manager.h" 13 #include "content/shell/android/shell_manager.h"
11 #include "content/shell/android/shell_view.h" 14 #include "content/shell/android/shell_view.h"
12 15
13 static base::android::RegistrationMethod kRegistrationMethods[] = { 16 static base::android::RegistrationMethod kRegistrationMethods[] = {
14 { "ShellManager", content::RegisterShellManager }, 17 { "ShellManager", content::RegisterShellManager },
15 { "ShellView", content::ShellView::Register }, 18 { "ShellView", content::ShellView::Register },
16 }; 19 };
17 20
21 namespace {
22 content::ContentMainRunner* gContentMainRunner = NULL;
Yaron 2012/05/09 01:01:42 Shouldn't this be g_content_main_runner?
23 }
24
18 // This is called by the VM when the shared library is first loaded. 25 // This is called by the VM when the shared library is first loaded.
19 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { 26 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
27
28 // Don't call anything in base without initializing it.
29 // ContentMainRunner will do what we need.
30 gContentMainRunner = content::ContentMainRunner::Create();
31
32 // TODO(tedchoc): Set this to the main delegate once the Android specific
33 // browser process initialization gets checked in.
34 ShellMainDelegate* delegate = new ShellMainDelegate();
35
36 // We use a ShellContentClient, created as a member of
37 // ShellMainDelegate and set with a call to
38 // content::SetContentClient() in PreSandboxStartup().
39 // That must be done before ContentMainRunner::Initialize().
Yaron 2012/05/09 01:01:42 This pairs with the "return 0" early-out in conten
John Grabowski 2012/05/09 17:18:15 That isn't clear. If we don't PreSandboxStartup()
Yaron 2012/05/09 17:31:47 Well, downstream we don't need to do this. Also, i
John Grabowski 2012/05/09 17:44:35 TODO added
40 delegate->PreSandboxStartup();
41
42 // TODO(jrg): find command line info from java; pass down in here.
43 gContentMainRunner->Initialize(0, NULL, NULL);
44
20 base::android::InitVM(vm); 45 base::android::InitVM(vm);
21 JNIEnv* env = base::android::AttachCurrentThread(); 46 JNIEnv* env = base::android::AttachCurrentThread();
22 if (!RegisterLibraryLoaderEntryHook(env)) { 47 if (!RegisterLibraryLoaderEntryHook(env)) {
23 return -1; 48 return -1;
24 } 49 }
25 50
26 // To be called only from the UI thread. If loading the library is done on 51 // To be called only from the UI thread. If loading the library is done on
27 // a separate thread, this should be moved elsewhere. 52 // a separate thread, this should be moved elsewhere.
28 if (!base::android::RegisterNativeMethods(env, kRegistrationMethods, 53 if (!base::android::RegisterNativeMethods(env, kRegistrationMethods,
29 arraysize(kRegistrationMethods))) 54 arraysize(kRegistrationMethods)))
30 return -1; 55 return -1;
31 56
32 // TODO(tedchoc): Set this to the main delegate once the Android specific
33 // browser process initialization gets checked in.
34 new ShellMainDelegate();
35
36 return JNI_VERSION_1_4; 57 return JNI_VERSION_1_4;
37 } 58 }
59
60
61 JNI_EXPORT void JNI_OnUnload(JavaVM* vm, void* reserved) {
62 delete gContentMainRunner;
63 gContentMainRunner = NULL;
64 }
65
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698