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 content 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 private static final String EXTRA_LINKER_PARAMS_BASE_LOAD_ADDRESS = | |
26 "org.chromium.content.common.linker_params.base_load_address"; | |
27 | |
28 private static final String EXTRA_LINKER_PARAMS_WAIT_FOR_SHARED_RELRO = | |
29 "org.chromium.content.common.linker_params.wait_for_shared_relro"; | |
30 | |
31 private static final String EXTRA_LINKER_PARAMS_TEST_RUNNER_CLASS_NAME = | |
32 "org.chromium.content.common.linker_params.test_runner_class_name"; | |
33 | |
34 public LinkerParams(long baseLoadAddress, | |
35 boolean waitForSharedRelro, | |
36 String testRunnerClassName) { | |
37 mBaseLoadAddress = baseLoadAddress; | |
38 mWaitForSharedRelro = waitForSharedRelro; | |
39 mTestRunnerClassName = testRunnerClassName; | |
40 } | |
41 | |
42 /** | |
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 previo
us | |
45 * call to addIntentExtras(). | |
46 */ | |
47 public LinkerParams(Intent intent) { | |
48 mBaseLoadAddress = intent.getLongExtra(EXTRA_LINKER_PARAMS_BASE_LOAD_ADD
RESS, 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); | |
53 } | |
54 | |
55 /** | |
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 proc
ess. | |
59 */ | |
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, mWaitForShare
dRelro); | |
63 intent.putExtra(EXTRA_LINKER_PARAMS_TEST_RUNNER_CLASS_NAME, mTestRunnerC
lassName); | |
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 |