}
protected ExtensionConnection connectTo(FirefoxBinary binary, FirefoxProfile profile,
String host) {
int profilePort = profile.getPort() == 0 ? DEFAULT_PORT : profile.getPort();
Lock lock = new SocketLock(profilePort - 1);
try {
FirefoxBinary bin = binary == null ? new FirefoxBinary() : binary;
return new NewProfileExtensionConnection(lock, bin, profile, host);
} catch (Exception e) {
throw new WebDriverException(e);
} finally {
lock.unlock();
}
}