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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/prerender/ChromePrerenderService.java

Issue 2017963003: Upstream: ChildProcessLauncher connects renderer processes of WebAPKs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove PROCESS_WEBAPK_CHILD. 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.chrome.browser.prerender; 5 package org.chromium.chrome.browser.prerender;
6 6
7 import android.app.Service; 7 import android.app.Service;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.os.AsyncTask; 10 import android.os.AsyncTask;
(...skipping 21 matching lines...) Expand all
32 * A bound service that warms up Chrome and performs actions related with preren dering urls. 32 * A bound service that warms up Chrome and performs actions related with preren dering urls.
33 */ 33 */
34 public class ChromePrerenderService extends Service { 34 public class ChromePrerenderService extends Service {
35 public static final int MSG_PRERENDER_URL = 1; 35 public static final int MSG_PRERENDER_URL = 1;
36 public static final int MSG_CANCEL_PRERENDER = 2; 36 public static final int MSG_CANCEL_PRERENDER = 2;
37 public static final String KEY_PRERENDERED_URL = "url_to_prerender"; 37 public static final String KEY_PRERENDERED_URL = "url_to_prerender";
38 public static final String KEY_PRERENDER_WIDTH = "prerender_width"; 38 public static final String KEY_PRERENDER_WIDTH = "prerender_width";
39 public static final String KEY_PRERENDER_HEIGHT = "prerender_height"; 39 public static final String KEY_PRERENDER_HEIGHT = "prerender_height";
40 public static final String KEY_REFERRER = "referrer"; 40 public static final String KEY_REFERRER = "referrer";
41 41
42 private static class LauncherWarmUpTaskParams {
43 final Context mContext;
44 final ChildProcessCreationParams mParams;
45
46 LauncherWarmUpTaskParams(Context context, ChildProcessCreationParams par ams) {
47 mContext = context;
48 mParams = params;
49 }
50 }
51
52 private static class LauncherWarmUpTask
53 extends AsyncTask<LauncherWarmUpTaskParams, Void, Void> {
54 @Override
55 protected Void doInBackground(LauncherWarmUpTaskParams... args) {
56 ChildProcessLauncher.warmUp(args[0].mContext, args[0].mParams);
57 return null;
58 }
59 }
60
61 /** 42 /**
62 * Handler of incoming messages from clients. 43 * Handler of incoming messages from clients.
63 */ 44 */
64 class IncomingHandler extends VerifiedHandler { 45 class IncomingHandler extends VerifiedHandler {
65 IncomingHandler(Context context) { 46 IncomingHandler(Context context) {
66 super(context, ChromeVersionInfo.isLocalBuild() 47 super(context, ChromeVersionInfo.isLocalBuild()
67 ? 0 : ExternalAuthUtils.FLAG_SHOULD_BE_GOOGLE_SIGNED); 48 ? 0 : ExternalAuthUtils.FLAG_SHOULD_BE_GOOGLE_SIGNED);
68 } 49 }
69 50
70 @Override 51 @Override
(...skipping 12 matching lines...) Expand all
83 * for sending messages to the service. 64 * for sending messages to the service.
84 */ 65 */
85 @SuppressFBWarnings("DM_EXIT") 66 @SuppressFBWarnings("DM_EXIT")
86 @Override 67 @Override
87 public IBinder onBind(Intent intent) { 68 public IBinder onBind(Intent intent) {
88 mMessenger = new Messenger(new IncomingHandler(getApplicationContext())) ; 69 mMessenger = new Messenger(new IncomingHandler(getApplicationContext())) ;
89 70
90 try { 71 try {
91 final Context context = getApplicationContext(); 72 final Context context = getApplicationContext();
92 final ChromeApplication chrome = (ChromeApplication) context; 73 final ChromeApplication chrome = (ChromeApplication) context;
93 new LauncherWarmUpTask().execute(new LauncherWarmUpTaskParams( 74 ChildProcessCreationParams.set(chrome.getChildProcessCreationParams( ));
94 context, chrome.getChildProcessCreationParams())); 75 new AsyncTask<Context, Void, Void>() {
76 @Override
77 protected Void doInBackground(Context... params) {
78 ChildProcessLauncher.warmUp(params[0]);
79 return null;
80 }
81 }.execute(context);
95 ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup( ); 82 ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup( );
96 83
97 ApplicationInitialization.enableFullscreenFlags( 84 ApplicationInitialization.enableFullscreenFlags(
98 getApplicationContext().getResources(), 85 getApplicationContext().getResources(),
99 getApplicationContext(), R.dimen.control_container_height); 86 getApplicationContext(), R.dimen.control_container_height);
100 } catch (ProcessInitException e) { 87 } catch (ProcessInitException e) {
101 Log.e(this.getClass().toString(), 88 Log.e(this.getClass().toString(),
102 "ProcessInitException while starting the browser process"); 89 "ProcessInitException while starting the browser process");
103 // Since the library failed to initialize nothing in the application 90 // Since the library failed to initialize nothing in the application
104 // can work, so kill the whole application not just the activity 91 // can work, so kill the whole application not just the activity
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 break; 125 break;
139 default: 126 default:
140 break; 127 break;
141 } 128 }
142 } 129 }
143 130
144 private void prerenderUrl(String url, String referrer, int width, int height ) { 131 private void prerenderUrl(String url, String referrer, int width, int height ) {
145 WarmupManager.getInstance().prerenderUrl(url, referrer, width, height); 132 WarmupManager.getInstance().prerenderUrl(url, referrer, width, height);
146 } 133 }
147 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698