OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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 |
| 5 package org.chromium.content.app; |
| 6 |
| 7 import android.content.Intent; |
| 8 |
| 9 /** |
| 10 * A class to hold information passed from the browser process to each |
| 11 * service one when using the Chrome linker. For more information, read the |
| 12 * technical notes in Linker.java. |
| 13 */ |
| 14 public class LinkerParams { |
| 15 // Use this base address to load native shared libraries. If 0, ignore other
members. |
| 16 public final long mBaseLoadAddress; |
| 17 |
| 18 // If true, wait for a shared RELRO Bundle just after loading the libraries. |
| 19 public final boolean mWaitForSharedRelro; |
| 20 |
| 21 // If not empty, name of Linker.TestRunner implementation that needs to be |
| 22 // registered in the service process. |
| 23 public final String mTestRunnerClassName; |
| 24 |
| 25 public LinkerParams(long baseLoadAddress, |
| 26 boolean waitForSharedRelro, |
| 27 String testRunnerClassName) { |
| 28 mBaseLoadAddress = baseLoadAddress; |
| 29 mWaitForSharedRelro = waitForSharedRelro; |
| 30 mTestRunnerClassName = testRunnerClassName; |
| 31 } |
| 32 |
| 33 private static final String EXTRA_LINKER_PARAMS_BASE_LOAD_ADDRESS = |
| 34 "org.chromium.content.common.linker_params.base_load_address"; |
| 35 |
| 36 private static final String EXTRA_LINKER_PARAMS_WAIT_FOR_SHARED_RELRO = |
| 37 "org.chromium.content.common.linker_params.wait_for_shared_relro"; |
| 38 |
| 39 private static final String EXTRA_LINKER_PARAMS_TEST_RUNNER_CLASS_NAME = |
| 40 "org.chromium.content.common.linker_params.test_runner_class_name"; |
| 41 |
| 42 /** |
| 43 * Ensure this LinkerParams instance is sent to a service process by adding |
| 44 * it to an intent's extras. |
| 45 * @param intent An Intent use to start or connect to the child service proc
ess. |
| 46 */ |
| 47 public void addIntentExtras(Intent intent) { |
| 48 intent.putExtra(EXTRA_LINKER_PARAMS_BASE_LOAD_ADDRESS, mBaseLoadAddress)
; |
| 49 intent.putExtra(EXTRA_LINKER_PARAMS_WAIT_FOR_SHARED_RELRO, mWaitForShare
dRelro); |
| 50 intent.putExtra(EXTRA_LINKER_PARAMS_TEST_RUNNER_CLASS_NAME, mTestRunnerC
lassName); |
| 51 } |
| 52 |
| 53 /** |
| 54 * Use this constructor to recreate a LinkerParams instance from an Intent. |
| 55 * @param intent An Intent, its content must have been populated by a previo
us |
| 56 * call to addIntentExtras(). |
| 57 */ |
| 58 public LinkerParams(Intent intent) { |
| 59 mBaseLoadAddress = intent.getLongExtra(EXTRA_LINKER_PARAMS_BASE_LOAD_ADD
RESS, 0); |
| 60 mWaitForSharedRelro = intent.getBooleanExtra( |
| 61 EXTRA_LINKER_PARAMS_WAIT_FOR_SHARED_RELRO, false); |
| 62 mTestRunnerClassName = intent.getStringExtra( |
| 63 EXTRA_LINKER_PARAMS_TEST_RUNNER_CLASS_NAME); |
| 64 } |
| 65 |
| 66 // For debugging traces only. |
| 67 public String toString() { |
| 68 return String.format( |
| 69 "LinkerParams(baseLoadAddress:0x%x, waitForSharedRelro:%s, " + |
| 70 "testRunnerClassName:%s", |
| 71 mBaseLoadAddress, |
| 72 mWaitForSharedRelro ? "true" : "false", |
| 73 mTestRunnerClassName); |
| 74 } |
| 75 } |
OLD | NEW |