OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.content.Intent; | 7 import android.content.Intent; |
8 | 8 |
9 import org.chromium.base.library_loader.LibraryProcessType; | 9 import org.chromium.base.library_loader.LibraryProcessType; |
10 | 10 |
11 /** | 11 /** |
12 * Allows specifying the package name for looking up child services | 12 * Allows specifying the package name for looking up child services |
13 * configuration and classes into (if it differs from the application | 13 * configuration and classes into (if it differs from the application |
14 * package name, like in the case of Android WebView). Also allows | 14 * package name, like in the case of Android WebView). Also allows |
15 * specifying additional child service binging flags. | 15 * specifying additional child service binging flags. |
16 */ | 16 */ |
17 public class ChildProcessCreationParams { | 17 public class ChildProcessCreationParams { |
18 private final String mPackageName; | 18 private final String mPackageName; |
19 private final int mExtraBindFlags; | 19 private final int mExtraBindFlags; |
20 private final int mLibraryProcessType; | 20 private final int mLibraryProcessType; |
21 private static final String EXTRA_LIBRARY_PROCESS_TYPE = | 21 private static final String EXTRA_LIBRARY_PROCESS_TYPE = |
22 "org.chromium.content.common.child_service_params.library_process_ty pe"; | 22 "org.chromium.content.common.child_service_params.library_process_ty pe"; |
23 | 23 |
24 private static volatile ChildProcessCreationParams sChildProcessCreationPara ms; | 24 private static volatile ChildProcessCreationParams sChildProcessCreationPara ms; |
25 | 25 |
26 public static void set(ChildProcessCreationParams params) { | 26 public static void set(ChildProcessCreationParams params) { |
27 assert params != null; | |
27 sChildProcessCreationParams = params; | 28 sChildProcessCreationParams = params; |
28 } | 29 } |
29 | 30 |
30 public static ChildProcessCreationParams get() { | 31 public static ChildProcessCreationParams get() { |
31 return sChildProcessCreationParams; | 32 return sChildProcessCreationParams; |
32 } | 33 } |
33 | 34 |
34 public ChildProcessCreationParams(String packageName, int extraBindFlags, | 35 public ChildProcessCreationParams(String packageName, int extraBindFlags, |
35 int libraryProcessType) { | 36 int libraryProcessType) { |
36 mPackageName = packageName; | 37 mPackageName = packageName; |
37 mExtraBindFlags = extraBindFlags; | 38 mExtraBindFlags = extraBindFlags; |
38 mLibraryProcessType = libraryProcessType; | 39 mLibraryProcessType = libraryProcessType; |
39 } | 40 } |
40 | 41 |
42 @Override | |
43 public ChildProcessCreationParams clone() { | |
44 return new ChildProcessCreationParams(mPackageName, mExtraBindFlags, mLi braryProcessType); | |
pkotwicz
2016/05/27 21:10:13
Can you please check that there are no errors thro
Xi Han
2016/05/27 21:31:39
Good catch. Rename it to copy().
| |
45 } | |
46 | |
41 public String getPackageName() { | 47 public String getPackageName() { |
42 return mPackageName; | 48 return mPackageName; |
43 } | 49 } |
44 | 50 |
51 public int getExtraBindFlags() { | |
52 return mExtraBindFlags; | |
53 } | |
54 | |
45 /** | 55 /** |
46 * Adds required extra flags to the given child service binding flags and re turns them. | 56 * Adds required extra flags to the given child service binding flags and re turns them. |
47 * Does not modify the state of the ChildProcessCreationParams instance. | 57 * Does not modify the state of the ChildProcessCreationParams instance. |
48 * | 58 * |
49 * @param bindFlags Source bind flags to modify. | 59 * @param bindFlags Source bind flags to modify. |
50 * @return Bind flags with extra flags added. | 60 * @return Bind flags with extra flags added. |
51 */ | 61 */ |
52 public int addExtraBindFlags(int bindFlags) { | 62 public int addExtraBindFlags(int bindFlags) { |
53 return bindFlags | mExtraBindFlags; | 63 return bindFlags | mExtraBindFlags; |
54 } | 64 } |
55 | 65 |
56 public void addIntentExtras(Intent intent) { | 66 public void addIntentExtras(Intent intent) { |
57 intent.putExtra(EXTRA_LIBRARY_PROCESS_TYPE, mLibraryProcessType); | 67 intent.putExtra(EXTRA_LIBRARY_PROCESS_TYPE, mLibraryProcessType); |
58 } | 68 } |
59 | 69 |
60 public static int getLibraryProcessType(Intent intent) { | 70 public static int getLibraryProcessType(Intent intent) { |
61 return intent.getIntExtra(EXTRA_LIBRARY_PROCESS_TYPE, | 71 return intent.getIntExtra(EXTRA_LIBRARY_PROCESS_TYPE, |
62 LibraryProcessType.PROCESS_CHILD); | 72 LibraryProcessType.PROCESS_CHILD); |
63 } | 73 } |
64 } | 74 } |
OLD | NEW |