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

Side by Side Diff: chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkSandboxedProcessService.java

Issue 2049843004: Upstream: Renderers are running in WebAPKs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a check. Created 4 years, 6 months 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
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.webapk.lib.common;
6
7 import android.app.Service;
8 import android.content.Context;
9 import android.content.Intent;
10 import android.os.IBinder;
11 import android.util.Log;
12
13 import java.lang.reflect.Method;
14
15 /**
16 * Child process service hosted by WebAPKs. This class uses Chrome's ClassLoader to create a
17 * {@link ChildProcessServiceImpl} object which loads Chrome's native libraries, initializes JNI
18 * and creates the renderer.
19 */
20 public class WebApkSandboxedProcessService extends Service {
21 private static final String CHILD_PROCESS_SERVICE_IMPL_CLASS_NAME =
22 "org.chromium.content.app.ChildProcessServiceImpl";
Maria 2016/06/20 18:49:22 I think you may want to add a test that this is up
Xi Han 2016/06/20 19:12:34 Good point. I added a note here. Beside, I add a W
23 private static final String TAG = "cr_WebApkSandboxedProcessService";
24
25 private Class<?> mChildProcessServiceImplClass;
26 private Object mChildProcessServiceImplInstance;
27
28 @Override
29 public void onCreate() {
30 super.onCreate();
31
32 try {
33 Context hostBrowserContext =
34 WebApkUtils.getHostBrowserContext(getApplicationContext());
35 ClassLoader classLoader = hostBrowserContext.getClassLoader();
36 mChildProcessServiceImplClass =
37 classLoader.loadClass(CHILD_PROCESS_SERVICE_IMPL_CLASS_NAME) ;
38 mChildProcessServiceImplInstance = mChildProcessServiceImplClass.new Instance();
39
40 Method createMethod = mChildProcessServiceImplClass.getMethod("creat e",
41 Context.class, Context.class);
42 createMethod.invoke(mChildProcessServiceImplInstance, getApplication Context(),
43 hostBrowserContext);
44 } catch (Exception e) {
45 Log.d(TAG, "Unable to create a ChildProcessServiceImpl for the WebAP K.", e);
Maria 2016/06/20 18:49:22 I would log with lower verbosity in all these meth
Xi Han 2016/06/20 19:12:34 Got it this time:)
46 }
47 }
48
49 @Override
50 public IBinder onBind(Intent intent) {
51 // We call stopSelf() to request that this service be stopped as soon as the client
52 // unbinds. Otherwise the system may keep it around and available for a reconnect. The
53 // child processes do not currently support reconnect; they must be init ialized from
54 // scratch every time.
55 stopSelf();
56 try {
57 Method bindMethod = mChildProcessServiceImplClass.getMethod(
58 "bind", Intent.class);
59 return (IBinder) bindMethod.invoke(mChildProcessServiceImplInstance, intent);
60 } catch (Exception e) {
61 Log.d(TAG, "Unable to bind to the WebApkSandboxedProcessService.", e );
62 }
63 return null;
64 }
65
66 @Override
67 public void onDestroy() {
68 super.onDestroy();
69 try {
70 Method destroyMethod = mChildProcessServiceImplClass.getMethod("dest roy");
71 destroyMethod.invoke(mChildProcessServiceImplInstance);
72 } catch (Exception e) {
73 Log.d(TAG, "Unable to destroy the WebApkSandboxedProcessService.", e );
74 }
75 }
76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698