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

Side by Side Diff: content/browser/android/library_loader_hooks.cc

Issue 10377059: Android content shell bringup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix deps so builds on clean machine 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
« no previous file with comments | « content/browser/android/jni_helper.cc ('k') | content/browser/android/trace_event_binding.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 (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 "content/public/browser/android_library_loader_hooks.h" 5 #include "content/public/browser/android_library_loader_hooks.h"
6 6
7 #include "base/android/base_jni_registrar.h" 7 #include "base/android/base_jni_registrar.h"
8 #include "base/android/jni_registrar.h"
8 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
9 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
11 #include "base/at_exit.h"
10 #include "base/command_line.h" 12 #include "base/command_line.h"
11 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
12 #include "base/file_path.h" 14 #include "base/file_path.h"
13 #include "base/file_util.h" 15 #include "base/file_util.h"
14 #include "base/logging.h" 16 #include "base/logging.h"
15 #include "base/string_tokenizer.h" 17 #include "base/string_tokenizer.h"
16 #include "base/string_util.h" 18 #include "base/string_util.h"
17 #include "base/tracked_objects.h" 19 #include "base/tracked_objects.h"
18 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
21 #include "content/browser/android/command_line.h"
22 #include "content/browser/android/content_jni_registrar.h"
19 #include "media/base/android/media_jni_registrar.h" 23 #include "media/base/android/media_jni_registrar.h"
20 #include "net/android/net_jni_registrar.h" 24 #include "net/android/net_jni_registrar.h"
21 25
26 namespace {
27 base::AtExitManager* g_at_exit_manager = NULL;
28 }
29
22 jboolean LibraryLoaderEntryHook(JNIEnv* env, jclass clazz, 30 jboolean LibraryLoaderEntryHook(JNIEnv* env, jclass clazz,
23 jobjectArray init_command_line) { 31 jobjectArray init_command_line) {
24 32 // We need the Chrome AtExitManager to be created before we do any tracing or
25 // TODO(tedchoc): Initialize the native command line from the java array 33 // logging.
26 // passed in. 34 g_at_exit_manager = new base::AtExitManager();
35 InitNativeCommandLineFromJavaArray(env, init_command_line);
27 36
28 CommandLine* command_line = CommandLine::ForCurrentProcess(); 37 CommandLine* command_line = CommandLine::ForCurrentProcess();
29 38
30 if (command_line->HasSwitch(switches::kTraceStartup)) { 39 if (command_line->HasSwitch(switches::kTraceStartup)) {
31 base::debug::TraceLog::GetInstance()->SetEnabled( 40 base::debug::TraceLog::GetInstance()->SetEnabled(
32 command_line->GetSwitchValueASCII(switches::kTraceStartup)); 41 command_line->GetSwitchValueASCII(switches::kTraceStartup));
33 } 42 }
34 43
35 // Can only use event tracing after setting up the command line. 44 // Can only use event tracing after setting up the command line.
36 TRACE_EVENT0("jni", "JNI_OnLoad continuation"); 45 TRACE_EVENT0("jni", "JNI_OnLoad continuation");
(...skipping 10 matching lines...) Expand all
47 false); // Tick count 56 false); // Tick count
48 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel() 57 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel()
49 << ", default verbosity = " << logging::GetVlogVerbosity(); 58 << ", default verbosity = " << logging::GetVlogVerbosity();
50 59
51 if (!base::android::RegisterJni(env)) 60 if (!base::android::RegisterJni(env))
52 return JNI_FALSE; 61 return JNI_FALSE;
53 62
54 if (!net::android::RegisterJni(env)) 63 if (!net::android::RegisterJni(env))
55 return JNI_FALSE; 64 return JNI_FALSE;
56 65
66 if (!content::android::RegisterJni(env))
67 return JNI_FALSE;
68
57 if (!media::RegisterJni(env)) 69 if (!media::RegisterJni(env))
58 return JNI_FALSE; 70 return JNI_FALSE;
59 71
60 return JNI_TRUE; 72 return JNI_TRUE;
61 } 73 }
62 74
75 void LibraryLoaderExitHook() {
76 if (g_at_exit_manager) {
77 delete g_at_exit_manager;
78 g_at_exit_manager = NULL;
79 }
80 }
81
63 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) { 82 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) {
64 // TODO(bulach): use the jni generator once we move jni_helper methods here. 83 // TODO(bulach): use the jni generator once we move jni_helper methods here.
65 const JNINativeMethod kMethods[] = { 84 const JNINativeMethod kMethods[] = {
66 { "nativeLibraryLoadedOnMainThread", "([Ljava/lang/String;)Z", 85 { "nativeLibraryLoadedOnMainThread", "([Ljava/lang/String;)Z",
67 reinterpret_cast<void*>(LibraryLoaderEntryHook) }, 86 reinterpret_cast<void*>(LibraryLoaderEntryHook) },
68 }; 87 };
69 const int kMethodsSize = arraysize(kMethods); 88 const int kMethodsSize = arraysize(kMethods);
70 // TODO(tedchoc): Upstream LibraryLoader.java and replace path to make this 89 const char kLibraryLoaderPath[] =
71 // work. 90 "org/chromium/content/browser/LibraryLoader";
72 const char kLibraryLoaderPath[] = "";
73 base::android::ScopedJavaLocalRef<jclass> clazz = 91 base::android::ScopedJavaLocalRef<jclass> clazz =
74 base::android::GetClass(env, kLibraryLoaderPath); 92 base::android::GetClass(env, kLibraryLoaderPath);
75 93
76 if (env->RegisterNatives(clazz.obj(), 94 if (env->RegisterNatives(clazz.obj(),
77 kMethods, 95 kMethods,
78 kMethodsSize) < 0) { 96 kMethodsSize) < 0) {
79 return false; 97 return false;
80 } 98 }
81 return true; 99 return true;
82 } 100 }
OLDNEW
« no previous file with comments | « content/browser/android/jni_helper.cc ('k') | content/browser/android/trace_event_binding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698