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