Commit 370e13d1 authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

Minor BindingManager clean up

Inline two methods that's has a single call site. Rename methods to
add/removeConnection since BindingManager isn't based on LRU anymore.

Change-Id: I292a9a596c89720ab17f0bade704fa5c30d11d15
Reviewed-on: https://chromium-review.googlesource.com/1239345Reviewed-by: default avatarSiddhartha S <ssid@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593360}
parent dd3845f1
......@@ -80,20 +80,6 @@ class BindingManager implements ComponentCallbacks2 {
assert mConnections.size() == newSize;
}
private void addAndUseConnection(ChildProcessConnection connection) {
// Note that the size of connections is currently fairly small (40).
// If it became bigger we should consider using an alternate data structure.
boolean alreadyInQueue = !mConnections.add(connection);
if (!alreadyInQueue) connection.addModerateBinding();
assert mConnections.size() <= mMaxSize;
}
private void removeConnection(ChildProcessConnection connection) {
boolean alreadyInQueue = mConnections.remove(connection);
if (alreadyInQueue) connection.removeModerateBinding();
assert !mConnections.contains(connection);
}
private void removeAllConnections() {
removeOldConnections(mConnections.size());
}
......@@ -162,13 +148,20 @@ class BindingManager implements ComponentCallbacks2 {
context.registerComponentCallbacks(this);
}
public void increaseRecency(ChildProcessConnection connection) {
public void addConnection(ChildProcessConnection connection) {
assert LauncherThread.runningOnLauncherThread();
addAndUseConnection(connection);
// Note that the size of connections is currently fairly small (40).
// If it became bigger we should consider using an alternate data structure.
boolean alreadyInQueue = !mConnections.add(connection);
if (!alreadyInQueue) connection.addModerateBinding();
assert mConnections.size() <= mMaxSize;
}
public void dropRecency(ChildProcessConnection connection) {
public void removeConnection(ChildProcessConnection connection) {
assert LauncherThread.runningOnLauncherThread();
removeConnection(connection);
boolean alreadyInQueue = mConnections.remove(connection);
if (alreadyInQueue) connection.removeModerateBinding();
assert !mConnections.contains(connection);
}
}
......@@ -156,7 +156,7 @@ public final class ChildProcessLauncherHelperImpl {
sLauncherByPid.remove(connection.getPid());
BindingManager manager = getBindingManager();
if (mUseBindingManager && manager != null) {
manager.dropRecency(connection);
manager.removeConnection(connection);
}
if (mRanking != null) {
mRanking.removeConnection(connection);
......@@ -473,7 +473,7 @@ public final class ChildProcessLauncherHelperImpl {
if (shouldAddToBindingManager && !wasAddedToBindingManager) {
BindingManager manager = getBindingManager();
if (mUseBindingManager && manager != null) {
manager.increaseRecency(connection);
manager.addConnection(connection);
}
}
......
......@@ -48,7 +48,7 @@ public class BindingManagerTest {
null /* serviceBundle */);
connection.setPid(pid);
connection.start(false /* useStrongBinding */, null /* serviceCallback */);
manager.increaseRecency(connection);
manager.addConnection(connection);
iterable.add(connection);
connection.removeModerateBinding(); // Remove initial binding.
return connection;
......@@ -181,7 +181,7 @@ public class BindingManagerTest {
// Verify that each connection has a moderate binding after binding and releasing a
// strong binding.
for (ChildProcessConnection connection : connections) {
manager.increaseRecency(connection);
manager.addConnection(connection);
mIterable.add(connection);
Assert.assertTrue(message, connection.isModerateBindingBound());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment