Skip to content

Commit

Permalink
Remove android_library_loader_hook from content API
Browse files Browse the repository at this point in the history
As content_jni_onload.h was added, android_library_loader_hook is not needed be a content API, move it to content/app/android/

BUG=447393

Review URL: https://codereview.chromium.org/914083004

Cr-Commit-Position: refs/heads/master@{#316376}
  • Loading branch information
michaelbai authored and Commit bot committed Feb 14, 2015
1 parent 0a243a4 commit 236b82b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 36 deletions.
1 change: 1 addition & 0 deletions content/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ content_app_sources = [
"android/content_main.cc",
"android/content_main.h",
"android/library_loader_hooks.cc",
"android/library_loader_hooks.h",
"content_main.cc",
"content_main_runner.cc",
"mojo/mojo_init.cc",
Expand Down
1 change: 0 additions & 1 deletion content/app/android/child_process_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "content/common/android/surface_texture_manager.h"
#include "content/common/android/surface_texture_peer.h"
#include "content/common/gpu/gpu_surface_lookup.h"
#include "content/public/app/android_library_loader_hooks.h"
#include "content/public/common/content_descriptors.h"
#include "ipc/ipc_descriptors.h"
#include "jni/ChildProcessService_jni.h"
Expand Down
5 changes: 1 addition & 4 deletions content/app/android/content_jni_onload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "base/android/base_jni_onload.h"
#include "base/android/jni_onload_delegate.h"
#include "base/android/library_loader/library_loader_hooks.h"
#include "content/public/app/android_library_loader_hooks.h"
#include "content/app/android/library_loader_hooks.h"
#include "content/public/app/content_main.h"

namespace content {
Expand All @@ -25,9 +25,6 @@ class ContentJNIOnLoadDelegate
};

bool ContentJNIOnLoadDelegate::RegisterJNI(JNIEnv* env) {
// TODO(michaelbai): Remove the EnsureJniRegistered from
// content::LibraryLoaded and move android_library_loader_hooks.h to
// content/app/android/.
return content::EnsureJniRegistered(env);
}

Expand Down
4 changes: 2 additions & 2 deletions content/app/android/library_loader_hooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/public/app/android_library_loader_hooks.h"
#include "content/app/android/library_loader_hooks.h"

#include "base/android/base_jni_registrar.h"
#include "base/android/command_line_android.h"
Expand Down Expand Up @@ -112,7 +112,7 @@ bool LibraryLoaded(JNIEnv* env, jclass clazz) {
VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel()
<< ", default verbosity = " << logging::GetVlogVerbosity();

return EnsureJniRegistered(env);
return true;
}

} // namespace content
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_PUBLIC_APP_ANDROID_LIBRARY_LOADER_HOOKS_H_
#define CONTENT_PUBLIC_APP_ANDROID_LIBRARY_LOADER_HOOKS_H_
#ifndef CONTENT_APP_ANDROID_LIBRARY_LOADER_HOOKS_H_
#define CONTENT_APP_ANDROID_LIBRARY_LOADER_HOOKS_H_

#include <jni.h>

#include "base/basictypes.h"
#include "content/common/content_export.h"

namespace content {

// Register all content JNI functions now, rather than waiting for the process
// of fully loading the native library to complete.
CONTENT_EXPORT bool EnsureJniRegistered(JNIEnv* env);
bool EnsureJniRegistered(JNIEnv* env);

// Do the intialization of content needed immediately after the native library
// has loaded.
// This is designed to be used as a hook function to be passed to
// base::android::SetLibraryLoadedHook
CONTENT_EXPORT bool LibraryLoaded(JNIEnv* env,
jclass clazz);
bool LibraryLoaded(JNIEnv* env, jclass clazz);

} // namespace content

#endif // CONTENT_PUBLIC_APP_ANDROID_LIBRARY_LOADER_HOOKS_H_
#endif // CONTENT_APP_ANDROID_LIBRARY_LOADER_HOOKS_H_
2 changes: 1 addition & 1 deletion content/content_app.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
'app/android/content_main.cc',
'app/android/content_main.h',
'app/android/library_loader_hooks.cc',
'app/android/library_loader_hooks.h',
'app/content_main.cc',
'app/content_main_runner.cc',
'app/mojo/mojo_init.cc',
'app/mojo/mojo_init.h',
'public/app/android_library_loader_hooks.h',
'public/app/content_jni_onload.h',
'public/app/content_main.h',
'public/app/content_main_delegate.cc',
Expand Down
1 change: 0 additions & 1 deletion content/public/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
# //content/public/app:both_sources (source set)

public_app_shared_sources = [
"android_library_loader_hooks.h",
"content_jni_onload.h",
"content_main.h",
"content_main_delegate.cc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,45 @@
// found in the LICENSE file.

#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
#include "base/android/library_loader/library_loader_hooks.h"
#include "base/basictypes.h"
#include "base/debug/debugger.h"
#include "base/logging.h"
#include "content/public/app/android_library_loader_hooks.h"
#include "base/android/jni_onload_delegate.h"
#include "content/public/app/content_jni_onload.h"
#include "content/public/app/content_main.h"
#include "content/public/browser/android/compositor.h"
#include "content/shell/android/linker_test_apk/chromium_linker_test_linker_tests.h"
#include "content/shell/android/shell_jni_registrar.h"
#include "content/shell/app/shell_main_delegate.h"

// This is called by the VM when the shared library is first loaded.
JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
namespace {

base::android::SetLibraryLoadedHook(&content::LibraryLoaded);
class ChromiumLinkerTestJNIOnLoadDelegate :
public base::android::JNIOnLoadDelegate {
public:
bool RegisterJNI(JNIEnv* env) override {
// To be called only from the UI thread. If loading the library is done on
// a separate thread, this should be moved elsewhere.
if (!content::android::RegisterShellJni(env))
return false;

base::android::InitVM(vm);
JNIEnv* env = base::android::AttachCurrentThread();
if (!content::RegisterLinkerTestsJni(env))
return false;

if (!base::android::RegisterLibraryLoaderEntryHook(env))
return -1;
return true;
}

// To be called only from the UI thread. If loading the library is done on
// a separate thread, this should be moved elsewhere.
if (!content::android::RegisterShellJni(env))
return -1;
bool Init() override {
content::Compositor::Initialize();
content::SetContentMainDelegate(new content::ShellMainDelegate());
return true;
}
};

if (!content::RegisterLinkerTestsJni(env))
} // namespace

// This is called by the VM when the shared library is first loaded.
JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
ChromiumLinkerTestJNIOnLoadDelegate delegate;
if (!content::android::OnJNIOnLoad(vm, &delegate))
return -1;

content::Compositor::Initialize();
content::SetContentMainDelegate(new content::ShellMainDelegate());
return JNI_VERSION_1_4;
}

0 comments on commit 236b82b

Please sign in to comment.