xref: /aosp_15_r20/external/cronet/base/test/library_loader/early_native_test_helper.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2019 The Chromium Authors
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 "base/base_javatests_jni/EarlyNativeTest_jni.h"
6 #include "base/command_line.h"
7 #include "base/process/current_process.h"
8 #include "base/trace_event/trace_log.h"
9 #include "base/tracing_buildflags.h"
10 
11 namespace base {
12 
13 // Ensures that the LibraryLoader swapped over to the native command line.
JNI_EarlyNativeTest_IsCommandLineInitialized(JNIEnv * env)14 jboolean JNI_EarlyNativeTest_IsCommandLineInitialized(JNIEnv* env) {
15   return CommandLine::InitializedForCurrentProcess();
16 }
17 
18 // Ensures that native initialization took place, allowing early native code to
19 // use things like Tracing that don't depend on content initialization.
JNI_EarlyNativeTest_IsProcessNameEmpty(JNIEnv * env)20 jboolean JNI_EarlyNativeTest_IsProcessNameEmpty(JNIEnv* env) {
21 #if BUILDFLAG(ENABLE_BASE_TRACING)
22   return CurrentProcess::GetInstance().IsProcessNameEmpty();
23 #else   // BUILDFLAG(ENABLE_BASE_TRACING)
24   return false;
25 #endif  // BUILDFLAG(ENABLE_BASE_TRACING)
26 }
27 
28 }  // namespace base
29