1// Copyright 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
5package org.chromium.base;
6
7import org.chromium.base.annotations.JNINamespace;
8
9// The only purpose of this class is to allow sending CPU properties
10// from the browser process to sandboxed renderer processes. This is
11// needed because sandboxed processes cannot, on ARM, query the kernel
12// about the CPU's properties by parsing /proc, so this operation must
13// be performed in the browser process, and the result passed to
14// renderer ones.
15//
16// For more context, see http://crbug.com/164154
17//
18// Technically, this is a wrapper around the native NDK cpufeatures
19// library. The exact CPU features bits are never used in Java so
20// there is no point in duplicating their definitions here.
21//
22@JNINamespace("base::android")
23public abstract class CpuFeatures {
24    /**
25     * Return the number of CPU Cores on the device.
26     */
27    public static int getCount() {
28        return nativeGetCoreCount();
29    }
30
31    /**
32     * Return the CPU feature mask.
33     * This is a 64-bit integer that corresponds to the CPU's features.
34     * The value comes directly from android_getCpuFeatures().
35     */
36    public static long getMask() {
37        return nativeGetCpuFeatures();
38    }
39
40    private static native int nativeGetCoreCount();
41    private static native long nativeGetCpuFeatures();
42}
43