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

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

Issue 10444113: Fixed the dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/public/browser/android_library_loader_hooks.h"
6
7 #include "base/android/base_jni_registrar.h"
8 #include "base/android/jni_registrar.h"
9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h"
11 #include "base/at_exit.h"
12 #include "base/command_line.h"
13 #include "base/debug/trace_event.h"
14 #include "base/file_path.h"
15 #include "base/file_util.h"
16 #include "base/logging.h"
17 #include "base/string_tokenizer.h"
18 #include "base/string_util.h"
19 #include "base/tracked_objects.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"
23 #include "media/base/android/media_jni_registrar.h"
24 #include "net/android/net_jni_registrar.h"
25
26 namespace {
27 base::AtExitManager* g_at_exit_manager = NULL;
28 }
29
30 jboolean LibraryLoaderEntryHook(JNIEnv* env, jclass clazz,
31 jobjectArray init_command_line) {
32 // We need the Chrome AtExitManager to be created before we do any tracing or
33 // logging.
34 g_at_exit_manager = new base::AtExitManager();
35 InitNativeCommandLineFromJavaArray(env, init_command_line);
36
37 CommandLine* command_line = CommandLine::ForCurrentProcess();
38
39 if (command_line->HasSwitch(switches::kTraceStartup)) {
40 base::debug::TraceLog::GetInstance()->SetEnabled(
41 command_line->GetSwitchValueASCII(switches::kTraceStartup));
42 }
43
44 // Can only use event tracing after setting up the command line.
45 TRACE_EVENT0("jni", "JNI_OnLoad continuation");
46
47 logging::InitLogging(NULL,
48 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
49 logging::DONT_LOCK_LOG_FILE,
50 logging::DELETE_OLD_LOG_FILE,
51 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
52 // To view log output with IDs and timestamps use "adb logcat -v threadtime".
53 logging::SetLogItems(false, // Process ID
54 false, // Thread ID
55 false, // Timestamp
56 false); // Tick count
57 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel()
58 << ", default verbosity = " << logging::GetVlogVerbosity();
59
60 if (!base::android::RegisterJni(env))
61 return JNI_FALSE;
62
63 if (!net::android::RegisterJni(env))
64 return JNI_FALSE;
65
66 if (!content::android::RegisterJni(env))
67 return JNI_FALSE;
68
69 if (!media::RegisterJni(env))
70 return JNI_FALSE;
71
72 return JNI_TRUE;
73 }
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
82 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) {
83 // TODO(bulach): use the jni generator once we move jni_helper methods here.
84 const JNINativeMethod kMethods[] = {
85 { "nativeLibraryLoadedOnMainThread", "([Ljava/lang/String;)Z",
86 reinterpret_cast<void*>(LibraryLoaderEntryHook) },
87 };
88 const int kMethodsSize = arraysize(kMethods);
89 const char kLibraryLoaderPath[] =
90 "org/chromium/content/browser/LibraryLoader";
91 base::android::ScopedJavaLocalRef<jclass> clazz =
92 base::android::GetClass(env, kLibraryLoaderPath);
93
94 if (env->RegisterNatives(clazz.obj(),
95 kMethods,
96 kMethodsSize) < 0) {
97 return false;
98 }
99 return true;
100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698