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

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

Issue 10035034: Implement the skeleton of an android content shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move content/android -> content/public/android Created 8 years, 8 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) 2010 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/browser/android/library_loader_hooks.h"
6
7 #include "base/android/base_jni_registrar.h"
8 #include "base/android/jni_android.h"
9 #include "base/android/jni_string.h"
10 #include "base/command_line.h"
11 #include "base/debug/trace_event.h"
12 #include "base/file_path.h"
13 #include "base/file_util.h"
14 #include "base/logging.h"
15 #include "base/string_tokenizer.h"
16 #include "base/string_util.h"
17 #include "base/tracked_objects.h"
18 #include "content/public/common/content_switches.h"
19 #include "media/base/android/media_jni_registrar.h"
20
21 jboolean LibraryLoaderEntryHook(JNIEnv* env, jclass clazz,
22 jobjectArray init_command_line) {
23
24 // TODO(tedchoc): Initialize the native command line from the java array
25 // passed in.
26
27 CommandLine* command_line = CommandLine::ForCurrentProcess();
28
29 if (command_line->HasSwitch(switches::kTraceStartup)) {
30 base::debug::TraceLog::GetInstance()->SetEnabled(
31 command_line->GetSwitchValueASCII(switches::kTraceStartup));
32 }
33
34 // Can only use event tracing after setting up the command line.
35 TRACE_EVENT0("jni", "JNI_OnLoad continuation");
36
37 logging::InitLogging(NULL,
38 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
39 logging::DONT_LOCK_LOG_FILE,
40 logging::DELETE_OLD_LOG_FILE,
41 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
42 // To view log output with IDs and timestamps use "adb logcat -v threadtime".
43 logging::SetLogItems(false, // Process ID
44 false, // Thread ID
45 false, // Timestamp
46 false); // Tick count
47 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel()
48 << ", default verbosity = " << logging::GetVlogVerbosity();
49
50 if (!base::android::RegisterJni(env))
51 return JNI_FALSE;
52
53 // TODO(yfriedman): Add net registration.
54
55 if (!media::RegisterJni(env))
56 return JNI_FALSE;
57
58 return JNI_TRUE;
59 }
60
61 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) {
62 // TODO(bulach): use the jni generator once we move jni_helper methods here.
63 const JNINativeMethod kMethods[] = {
64 { "nativeLibraryLoadedOnMainThread", "([Ljava/lang/String;)Z",
65 reinterpret_cast<void*>(LibraryLoaderEntryHook) },
66 };
67 const int kMethodsSize = arraysize(kMethods);
68 // TODO(tedchoc): Upstream LibraryLoader.java and replace path to make this
69 // work.
70 const char kLibraryLoaderPath[] = "";
71 base::android::ScopedJavaLocalRef<jclass> clazz =
72 base::android::GetClass(env, kLibraryLoaderPath);
73
74 if (env->RegisterNatives(clazz.obj(),
75 kMethods,
76 kMethodsSize) < 0) {
77 return false;
78 }
79 return true;
80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698