зеркало из https://github.com/mozilla/gecko-dev.git
bug 672356 - plugin-container not set to background cgroup r=dougt
This commit is contained in:
Родитель
f6e7ea13ac
Коммит
237262a45f
|
@ -393,14 +393,17 @@ abstract public class GeckoApp
|
|||
// etc., and generally mark the profile as 'clean', and then
|
||||
// dirty it again if we get an onResume.
|
||||
|
||||
|
||||
GeckoAppShell.sendEventToGecko(new GeckoEvent(GeckoEvent.ACTIVITY_STOPPING));
|
||||
super.onStop();
|
||||
GeckoAppShell.putChildInBackground();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestart()
|
||||
{
|
||||
Log.i("GeckoApp", "restart");
|
||||
GeckoAppShell.putChildInForeground();
|
||||
super.onRestart();
|
||||
}
|
||||
|
||||
|
|
|
@ -1165,6 +1165,52 @@ public class GeckoAppShell
|
|||
return result;
|
||||
}
|
||||
|
||||
public static void putChildInBackground() {
|
||||
try {
|
||||
File cgroupFile = new File("/proc" + android.os.Process.myPid() + "/cgroup");
|
||||
BufferedReader br = new BufferedReader(new FileReader(cgroupFile));
|
||||
String[] cpuLine = br.readLine().split("/");
|
||||
br.close();
|
||||
final String backgroundGroup = cpuLine.length == 2 ? cpuLine[1] : "";
|
||||
GeckoProcessesVisitor visitor = new GeckoProcessesVisitor() {
|
||||
public boolean callback(int pid) {
|
||||
if (pid != android.os.Process.myPid()) {
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(
|
||||
new File("/dev/cpuctl/" + backgroundGroup +"/tasks"));
|
||||
fos.write(new Integer(pid).toString().getBytes());
|
||||
fos.close();
|
||||
} catch(Exception e) {
|
||||
Log.e("GeckoAppShell", "error putting child in the background", e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
EnumerateGeckoProcesses(visitor);
|
||||
} catch (Exception e) {
|
||||
Log.e("GeckoInputStream", "error reading cgroup", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void putChildInForeground() {
|
||||
GeckoProcessesVisitor visitor = new GeckoProcessesVisitor() {
|
||||
public boolean callback(int pid) {
|
||||
if (pid != android.os.Process.myPid()) {
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(new File("/dev/cpuctl/tasks"));
|
||||
fos.write(new Integer(pid).toString().getBytes());
|
||||
fos.close();
|
||||
} catch(Exception e) {
|
||||
Log.e("GeckoAppShell", "error putting child in the foreground", e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
EnumerateGeckoProcesses(visitor);
|
||||
}
|
||||
|
||||
public static void killAnyZombies() {
|
||||
GeckoProcessesVisitor visitor = new GeckoProcessesVisitor() {
|
||||
public boolean callback(int pid) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче