Chromium Code Reviews| Index: base/android/java/src/org/chromium/base/CpuFeatures.java |
| diff --git a/base/android/java/src/org/chromium/base/CpuFeatures.java b/base/android/java/src/org/chromium/base/CpuFeatures.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..878ac259d0b8bea122df6605bbe1bff89b479ffc |
| --- /dev/null |
| +++ b/base/android/java/src/org/chromium/base/CpuFeatures.java |
| @@ -0,0 +1,53 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.base; |
| + |
| +// The only purpose of this class is to allow sending CPU properties |
| +// from the browser process to sandboxed renderer processes. This is |
| +// needed because sandboxed processes cannot, on ARM, query the kernel |
| +// about the CPU's properties by parsing /proc, so this operation must |
| +// be performed in the browser process, and the result passed to |
| +// renderer ones. |
| +// |
| +// For more context, see crbug.com/164154 |
|
joth
2012/12/19 19:09:40
nit: linkify.
digit1
2013/01/09 11:26:19
Sure, will do.
|
| +// |
| +// Technically, this is a wrapper around the native NDK cpufeatures |
| +// library. The exact CPU features bits are never used in Java so |
| +// there is no point in duplicating their definitions here. |
| +// |
| +@JNINamespace("base::android") |
| +public abstract class CpuFeatures { |
| + /** |
| + * Return the number of CPU Cores on the device. |
| + */ |
| + public static int getCount() { |
| + return nativeGetCoreCount(); |
| + } |
| + |
| + /** |
| + * Return the CPU feature mask. |
| + * This is a 64-bit integer that corresponds to the CPU's features. |
| + * The value is taken directory to |
|
agl
2012/12/19 18:26:36
Comment seems truncated?
digit1
2013/01/09 11:26:19
Yes, I'll update it.
|
| + */ |
| + public static long getMask() { |
| + return nativeGetCpuFeatures(); |
| + } |
| + |
| + /** |
| + * Set CPU core count and feature mask. |
| + * This must be called in sandboxed renderer processes before any |
| + * other function from the native library that might depend on the |
| + * the CPU count / features. |
| + * @param coreCount Number of CPU cores on device. |
| + * @param featuresMask CPU features mask. |
| + */ |
| + public static void set(int coreCount, long featuresMask) { |
|
joth
2012/12/19 19:09:40
is this needed? loos like the sandbox process is a
digit1
2013/01/09 11:26:19
Indeed, this is no longer needed.
|
| + nativeSetCpu(coreCount, featuresMask); |
| + } |
| + |
| + private static native int nativeGetCoreCount(); |
| + private static native long nativeGetCpuFeatures(); |
| + private static native void nativeSetCpu(int coreCount, long featuresMask); |
| +} |