Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Side by Side Diff: base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java

Issue 684453003: Add UMA for testing whether the Chromium library was page aligned in the APK file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed histogram type to BooleanAligned Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.library_loader; 5 package org.chromium.base.library_loader;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.SystemClock; 8 import android.os.SystemClock;
9 import android.util.Log; 9 import android.util.Log;
10 10
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 nativeRecordNativeLibraryHack(sNativeLibraryHackWasUsed); 307 nativeRecordNativeLibraryHack(sNativeLibraryHackWasUsed);
308 } 308 }
309 309
310 // Record Chromium linker histogram state for the main browser process. Call ed from 310 // Record Chromium linker histogram state for the main browser process. Call ed from
311 // onNativeInitializationComplete(). 311 // onNativeInitializationComplete().
312 private static void recordBrowserProcessHistogram(Context context) { 312 private static void recordBrowserProcessHistogram(Context context) {
313 if (Linker.isUsed()) { 313 if (Linker.isUsed()) {
314 nativeRecordChromiumAndroidLinkerBrowserHistogram(sIsUsingBrowserSha redRelros, 314 nativeRecordChromiumAndroidLinkerBrowserHistogram(sIsUsingBrowserSha redRelros,
315 sLoadAtFixedAddres sFailed, 315 sLoadAtFixedAddres sFailed,
316 getLibraryLoadFrom ApkStatus(context)); 316 getLibraryLoadFrom ApkStatus(context));
317 if (Linker.isInZipFile()) {
318 nativeRecordChromiumAndroidLinkerLibraryAlignmentInApk(
picksi1 2014/10/28 11:37:08 This reads like you're checking if the linker is i
petrcermak 2014/10/28 12:16:48 I don't like the name either. It returns true iff
319 getLibraryAlignmentInApk(context));
320 }
317 } 321 }
318 } 322 }
319 323
320 // Returns the device's status for loading a library directly from the APK f ile. 324 // Returns the device's status for loading a library directly from the APK f ile.
321 // This method can only be called when the Chromium linker is used. 325 // This method can only be called when the Chromium linker is used.
322 private static int getLibraryLoadFromApkStatus(Context context) { 326 private static int getLibraryLoadFromApkStatus(Context context) {
323 assert Linker.isUsed(); 327 assert Linker.isUsed();
324 328
325 if (sLibraryWasLoadedFromApk) { 329 if (sLibraryWasLoadedFromApk) {
326 return LibraryLoadFromApkStatusCodes.SUCCESSFUL; 330 return LibraryLoadFromApkStatusCodes.SUCCESSFUL;
327 } 331 }
328 332
329 if (context == null) { 333 if (context == null) {
330 Log.w(TAG, "Unknown APK filename due to null context"); 334 Log.w(TAG, "Unknown APK filename due to null context");
331 return LibraryLoadFromApkStatusCodes.UNKNOWN; 335 return LibraryLoadFromApkStatusCodes.UNKNOWN;
332 } 336 }
333 337
334 return Linker.checkLibraryLoadFromApkSupport(context.getApplicationInfo( ).sourceDir) ? 338 return Linker.checkLibraryLoadFromApkSupport(context.getApplicationInfo( ).sourceDir) ?
335 LibraryLoadFromApkStatusCodes.SUPPORTED : 339 LibraryLoadFromApkStatusCodes.SUPPORTED :
336 LibraryLoadFromApkStatusCodes.NOT_SUPPORTED; 340 LibraryLoadFromApkStatusCodes.NOT_SUPPORTED;
337 } 341 }
338 342
343 // Returns true if the Chromium library is page aligned in the APK file.
344 // This method can only be called when the Chromium linker is used and the l ibrary
345 // can be loaded directly from the APK file.
346 private static boolean getLibraryAlignmentInApk(Context context) {
347 assert Linker.isUsed();
348 assert Linker.isInZipFile();
349
350 if (NativeLibraries.LIBRARIES.length != 2) {
351 Log.w(TAG, "NativeLibraryes.LIBRARIES should contain exactly 2 libra ries");
picksi1 2014/10/28 11:37:08 Is there a const or enum etc. we can use to avoid
petrcermak 2014/10/28 12:16:48 I removed this code. The point was that there shou
352 }
353
354 for (String library : NativeLibraries.LIBRARIES) {
355 if (!Linker.isLinkerLibrary(library)) {
356 return Linker.checkLibraryAlignedInApk(context.getApplicationInf o().sourceDir,
357 System.mapLibraryName(lib rary));
358 }
359 }
360
361 return false;
362 }
363
339 // Register pending Chromium linker histogram state for renderer processes. This cannot be 364 // Register pending Chromium linker histogram state for renderer processes. This cannot be
340 // recorded as a histogram immediately because histograms and IPC are not re ady at the 365 // recorded as a histogram immediately because histograms and IPC are not re ady at the
341 // time it are captured. This function stores a pending value, so that a lat er call to 366 // time it are captured. This function stores a pending value, so that a lat er call to
342 // RecordChromiumAndroidLinkerRendererHistogram() will record it correctly. 367 // RecordChromiumAndroidLinkerRendererHistogram() will record it correctly.
343 public static void registerRendererProcessHistogram(boolean requestedSharedR elro, 368 public static void registerRendererProcessHistogram(boolean requestedSharedR elro,
344 boolean loadAtFixedAddre ssFailed) { 369 boolean loadAtFixedAddre ssFailed) {
345 if (Linker.isUsed()) { 370 if (Linker.isUsed()) {
346 nativeRegisterChromiumAndroidLinkerRendererHistogram(requestedShared Relro, 371 nativeRegisterChromiumAndroidLinkerRendererHistogram(requestedShared Relro,
347 loadAtFixedAddr essFailed); 372 loadAtFixedAddr essFailed);
348 } 373 }
(...skipping 11 matching lines...) Expand all
360 385
361 // Method called to record statistics about the Chromium linker operation fo r the main 386 // Method called to record statistics about the Chromium linker operation fo r the main
362 // browser process. Indicates whether the linker attempted relro sharing for the browser, 387 // browser process. Indicates whether the linker attempted relro sharing for the browser,
363 // and if it did, whether the library failed to load at a fixed address. Als o records 388 // and if it did, whether the library failed to load at a fixed address. Als o records
364 // support for loading a library directly from the APK file. 389 // support for loading a library directly from the APK file.
365 private static native void nativeRecordChromiumAndroidLinkerBrowserHistogram ( 390 private static native void nativeRecordChromiumAndroidLinkerBrowserHistogram (
366 boolean isUsingBrowserSharedRelros, 391 boolean isUsingBrowserSharedRelros,
367 boolean loadAtFixedAddressFailed, 392 boolean loadAtFixedAddressFailed,
368 int libraryLoadFromApkStatus); 393 int libraryLoadFromApkStatus);
369 394
395 // Method called to record statistics about the page alignment of the Chromi um library
396 // in the APK file.
397 private static native void nativeRecordChromiumAndroidLinkerLibraryAlignment InApk(
398 boolean aligned);
399
370 // Method called to register (for later recording) statistics about the Chro mium linker 400 // Method called to register (for later recording) statistics about the Chro mium linker
371 // operation for a renderer process. Indicates whether the linker attempted relro sharing, 401 // operation for a renderer process. Indicates whether the linker attempted relro sharing,
372 // and if it did, whether the library failed to load at a fixed address. 402 // and if it did, whether the library failed to load at a fixed address.
373 private static native void nativeRegisterChromiumAndroidLinkerRendererHistog ram( 403 private static native void nativeRegisterChromiumAndroidLinkerRendererHistog ram(
374 boolean requestedSharedRelro, 404 boolean requestedSharedRelro,
375 boolean loadAtFixedAddressFailed); 405 boolean loadAtFixedAddressFailed);
376 406
377 // Get the version of the native library. This is needed so that we can chec k we 407 // Get the version of the native library. This is needed so that we can chec k we
378 // have the right version before initializing the (rest of the) JNI. 408 // have the right version before initializing the (rest of the) JNI.
379 private static native String nativeGetVersionNumber(); 409 private static native String nativeGetVersionNumber();
380 410
381 private static native void nativeRecordNativeLibraryHack(boolean usedHack); 411 private static native void nativeRecordNativeLibraryHack(boolean usedHack);
382 } 412 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698