| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.os.Bundle; | 7 import android.os.Bundle; |
| 8 | 8 |
| 9 import org.chromium.content.common.FileDescriptorInfo; | 9 import org.chromium.content.common.FileDescriptorInfo; |
| 10 import org.chromium.content.common.IChildProcessCallback; | 10 import org.chromium.content.common.IChildProcessCallback; |
| 11 import org.chromium.content.common.IChildProcessService; | 11 import org.chromium.content.common.IChildProcessService; |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Manages a connection between the browser activity and a child service. ChildP
rocessConnection is | 14 * Manages a connection between the browser activity and a child service. ChildP
rocessConnection is |
| 15 * responsible for estabilishing the connection (start()), closing it (stop()) a
nd manipulating the | 15 * responsible for estabilishing the connection (start()), closing it (stop()) a
nd manipulating the |
| 16 * bindings held onto the service (addStrongBinding(), removeStrongBinding(), | 16 * bindings held onto the service (addStrongBinding(), removeStrongBinding(), |
| 17 * removeInitialBinding()). | 17 * removeInitialBinding()). |
| 18 */ | 18 */ |
| 19 public interface ChildProcessConnection { | 19 public interface ChildProcessConnection { |
| 20 /** | 20 /** |
| 21 * Used to notify the consumer about disconnection of the service. This call
back is provided | 21 * Used to notify the consumer about disconnection of the service. This call
back is provided |
| 22 * earlier than ConnectionCallbacks below, as a child process might die befo
re the connection is | 22 * earlier than ConnectionCallbacks below, as a child process might die befo
re the connection is |
| 23 * fully set up. | 23 * fully set up. |
| 24 */ | 24 */ |
| 25 interface DeathCallback { | 25 interface DeathCallback { |
| 26 void onChildProcessDied(ChildProcessConnection connection); | 26 void onChildProcessDied(ChildProcessConnection connection); |
| 27 } | 27 } |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * Used to notify the consumer about the process start. These callbacks will
be invoked before | |
| 31 * the ConnectionCallbacks. | |
| 32 */ | |
| 33 interface StartCallback { | |
| 34 /** | |
| 35 * Called when the child process has successfully started and is ready f
or connection | |
| 36 * setup. | |
| 37 */ | |
| 38 void onChildStarted(); | |
| 39 | |
| 40 /** | |
| 41 * Called when the child process failed to start. This can happen if the
process is already | |
| 42 * in use by another client. | |
| 43 */ | |
| 44 void onChildStartFailed(); | |
| 45 } | |
| 46 | |
| 47 /** | |
| 48 * Used to notify the consumer about the connection being established. | 30 * Used to notify the consumer about the connection being established. |
| 49 */ | 31 */ |
| 50 interface ConnectionCallback { | 32 interface ConnectionCallback { |
| 51 /** | 33 /** |
| 52 * Called when the connection to the service is established. | 34 * Called when the connection to the service is established. |
| 53 * @param pid the pid of the child process | 35 * @param pid the pid of the child process |
| 54 */ | 36 */ |
| 55 void onConnected(int pid); | 37 void onConnected(int pid); |
| 56 } | 38 } |
| 57 | 39 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 68 */ | 50 */ |
| 69 int getPid(); | 51 int getPid(); |
| 70 | 52 |
| 71 /** | 53 /** |
| 72 * Starts a connection to an IChildProcessService. This must be followed by
a call to | 54 * Starts a connection to an IChildProcessService. This must be followed by
a call to |
| 73 * setupConnection() to setup the connection parameters. start() and setupCo
nnection() are | 55 * setupConnection() to setup the connection parameters. start() and setupCo
nnection() are |
| 74 * separate to allow to pass whatever parameters are available in start(), a
nd complete the | 56 * separate to allow to pass whatever parameters are available in start(), a
nd complete the |
| 75 * remainder later while reducing the connection setup latency. | 57 * remainder later while reducing the connection setup latency. |
| 76 * @param commandLine (optional) command line for the child process. If omit
ted, then | 58 * @param commandLine (optional) command line for the child process. If omit
ted, then |
| 77 * the command line parameters must instead be passed to
setupConnection(). | 59 * the command line parameters must instead be passed to
setupConnection(). |
| 78 * @param startCallback (optional) callback when the child process starts or
fails to start. | |
| 79 */ | 60 */ |
| 80 void start(String[] commandLine, StartCallback startCallback); | 61 void start(String[] commandLine); |
| 81 | 62 |
| 82 /** | 63 /** |
| 83 * Setups the connection after it was started with start(). | 64 * Setups the connection after it was started with start(). |
| 84 * @param commandLine (optional) will be ignored if the command line was alr
eady sent in start() | 65 * @param commandLine (optional) will be ignored if the command line was alr
eady sent in start() |
| 85 * @param filesToBeMapped a list of file descriptors that should be register
ed | 66 * @param filesToBeMapped a list of file descriptors that should be register
ed |
| 86 * @param processCallback used for status updates regarding this process con
nection | 67 * @param processCallback used for status updates regarding this process con
nection |
| 87 * @param connectionCallback will be called exactly once after the connectio
n is set up or the | 68 * @param connectionCallback will be called exactly once after the connectio
n is set up or the |
| 88 * setup fails | 69 * setup fails |
| 89 */ | 70 */ |
| 90 void setupConnection( | 71 void setupConnection( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 void addModerateBinding(); | 126 void addModerateBinding(); |
| 146 | 127 |
| 147 /** | 128 /** |
| 148 * Called when the service is no longer in moderate use of the consumer. | 129 * Called when the service is no longer in moderate use of the consumer. |
| 149 */ | 130 */ |
| 150 void removeModerateBinding(); | 131 void removeModerateBinding(); |
| 151 | 132 |
| 152 /** @return true iff the moderate oom binding is currently bound. */ | 133 /** @return true iff the moderate oom binding is currently bound. */ |
| 153 boolean isModerateBindingBound(); | 134 boolean isModerateBindingBound(); |
| 154 } | 135 } |
| OLD | NEW |