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