зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1362231 - Remove GeckoInterface.getProfile; r=snorp
Since we only support one profile per process, replace all calls to GeckoInterface.getProfile() with calls to GeckoThread.getActiveProfile(). MozReview-Commit-ID: 9PZOoBZt7Er
This commit is contained in:
Родитель
99336e02ef
Коммит
7f18399feb
|
@ -191,10 +191,7 @@ public final class ANRReporter extends BroadcastReceiver
|
|||
}
|
||||
|
||||
private static File getPingFile() {
|
||||
if (GeckoAppShell.getContext() == null) {
|
||||
return null;
|
||||
}
|
||||
GeckoProfile profile = GeckoAppShell.getGeckoInterface().getProfile();
|
||||
final GeckoProfile profile = GeckoThread.getActiveProfile();
|
||||
if (profile == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -2016,8 +2016,7 @@ public abstract class GeckoApp extends GeckoActivity
|
|||
return mLayerView.getEventDispatcher();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoProfile getProfile() {
|
||||
protected static GeckoProfile getProfile() {
|
||||
return GeckoThread.getActiveProfile();
|
||||
}
|
||||
|
||||
|
|
|
@ -50,11 +50,6 @@ public class Restrictions {
|
|||
return configuration instanceof GuestProfileConfiguration;
|
||||
}
|
||||
|
||||
GeckoAppShell.GeckoInterface geckoInterface = GeckoAppShell.getGeckoInterface();
|
||||
if (geckoInterface != null) {
|
||||
return geckoInterface.getProfile().inGuestMode();
|
||||
}
|
||||
|
||||
return GeckoProfile.get(context).inGuestMode();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.mozilla.gecko.BrowserApp;
|
|||
import org.mozilla.gecko.GeckoApp;
|
||||
import org.mozilla.gecko.GeckoProfile;
|
||||
import org.mozilla.gecko.GeckoSharedPrefs;
|
||||
import org.mozilla.gecko.GeckoThread;
|
||||
import org.mozilla.gecko.Telemetry;
|
||||
import org.mozilla.gecko.TelemetryContract;
|
||||
import org.mozilla.gecko.adjust.AttributionHelperListener;
|
||||
|
@ -45,7 +46,7 @@ public class TelemetryCorePingDelegate extends BrowserAppDelegateWithReference
|
|||
|
||||
@Override
|
||||
public void onStart(final BrowserApp browserApp) {
|
||||
TelemetryPreferences.initPreferenceObserver(browserApp, browserApp.getProfile().getName());
|
||||
TelemetryPreferences.initPreferenceObserver(browserApp, GeckoThread.getActiveProfile().getName());
|
||||
|
||||
// We don't upload in onCreate because that's only called when the Activity needs to be instantiated
|
||||
// and it's possible the system will never free the Activity from memory.
|
||||
|
@ -104,7 +105,7 @@ public class TelemetryCorePingDelegate extends BrowserAppDelegateWithReference
|
|||
@WorkerThread // via constructor
|
||||
private TelemetryDispatcher getTelemetryDispatcher(final BrowserApp browserApp) {
|
||||
if (telemetryDispatcher == null) {
|
||||
final GeckoProfile profile = browserApp.getProfile();
|
||||
final GeckoProfile profile = GeckoThread.getActiveProfile();
|
||||
final String profilePath = profile.getDir().getAbsolutePath();
|
||||
final String profileName = profile.getName();
|
||||
telemetryDispatcher = new TelemetryDispatcher(profilePath, profileName);
|
||||
|
@ -113,7 +114,7 @@ public class TelemetryCorePingDelegate extends BrowserAppDelegateWithReference
|
|||
}
|
||||
|
||||
private SharedPreferences getSharedPreferences(final BrowserApp activity) {
|
||||
return GeckoSharedPrefs.forProfileName(activity, activity.getProfile().getName());
|
||||
return GeckoSharedPrefs.forProfileName(activity, GeckoThread.getActiveProfile().getName());
|
||||
}
|
||||
|
||||
// via SearchEngineCallback - may be called from any thread.
|
||||
|
@ -137,7 +138,7 @@ public class TelemetryCorePingDelegate extends BrowserAppDelegateWithReference
|
|||
return;
|
||||
}
|
||||
|
||||
final GeckoProfile profile = activity.getProfile();
|
||||
final GeckoProfile profile = GeckoThread.getActiveProfile();
|
||||
if (!TelemetryUploadService.isUploadEnabledByProfileConfig(activity, profile)) {
|
||||
Log.d(LOGTAG, "Core ping upload disabled by profile config. Returning.");
|
||||
return;
|
||||
|
|
|
@ -15,7 +15,6 @@ import android.widget.AbsoluteLayout;
|
|||
|
||||
public class BaseGeckoInterface implements GeckoAppShell.GeckoInterface {
|
||||
private final Context mContext;
|
||||
private GeckoProfile mProfile;
|
||||
private final EventDispatcher eventDispatcher;
|
||||
|
||||
public BaseGeckoInterface(Context context) {
|
||||
|
@ -28,15 +27,6 @@ public class BaseGeckoInterface implements GeckoAppShell.GeckoInterface {
|
|||
return eventDispatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoProfile getProfile() {
|
||||
// Fall back to default profile if we didn't load a specific one
|
||||
if (mProfile == null) {
|
||||
mProfile = GeckoProfile.get(mContext);
|
||||
}
|
||||
return mProfile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
// By default, GeckoView consumers do not have a distinguished current foreground Activity.
|
||||
|
|
|
@ -1661,7 +1661,6 @@ public class GeckoAppShell
|
|||
|
||||
public interface GeckoInterface {
|
||||
public @NonNull EventDispatcher getAppEventDispatcher();
|
||||
public GeckoProfile getProfile();
|
||||
public Activity getActivity();
|
||||
public String getDefaultUAString();
|
||||
|
||||
|
@ -2014,8 +2013,8 @@ public class GeckoAppShell
|
|||
GeckoAppShell.killAnyZombies();
|
||||
|
||||
// Then force unlock this profile
|
||||
if (getGeckoInterface() != null) {
|
||||
GeckoProfile profile = getGeckoInterface().getProfile();
|
||||
final GeckoProfile profile = GeckoThread.getActiveProfile();
|
||||
if (profile != null) {
|
||||
File lock = profile.getFile(".parentlock");
|
||||
return lock.exists() && lock.delete();
|
||||
}
|
||||
|
|
|
@ -333,6 +333,7 @@ public class GeckoThread extends Thread {
|
|||
return args.toArray(new String[args.size()]);
|
||||
}
|
||||
|
||||
@RobocopTarget
|
||||
public static GeckoProfile getActiveProfile() {
|
||||
return INSTANCE.getProfile();
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ import java.io.File;
|
|||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.mozilla.gecko.GeckoApp;
|
||||
import org.mozilla.gecko.GeckoProfile;
|
||||
import org.mozilla.gecko.GeckoProfileDirectories;
|
||||
import org.mozilla.gecko.GeckoSharedPrefs;
|
||||
import org.mozilla.gecko.GeckoThread;
|
||||
import org.mozilla.gecko.util.INIParser;
|
||||
import org.mozilla.gecko.util.INISection;
|
||||
|
||||
|
@ -46,7 +46,8 @@ public class testGeckoProfile extends PixelTest {
|
|||
// "Default" is a custom profile set up by the test harness.
|
||||
mAsserter.info("Test using the test profile", GeckoProfile.CUSTOM_PROFILE);
|
||||
GeckoProfile profile = GeckoProfile.get(getActivity());
|
||||
verifyProfile(profile, GeckoProfile.CUSTOM_PROFILE, ((GeckoApp) getActivity()).getProfile().getDir(), true);
|
||||
verifyProfile(profile, GeckoProfile.CUSTOM_PROFILE,
|
||||
GeckoThread.getActiveProfile().getDir(), true);
|
||||
|
||||
try {
|
||||
profile = GeckoProfile.get(null);
|
||||
|
@ -65,7 +66,7 @@ public class testGeckoProfile extends PixelTest {
|
|||
removeProfile(profile, true);
|
||||
} else {
|
||||
// Passing in null for a profile name, should get you the default
|
||||
File defaultProfile = ((GeckoApp) getActivity()).getProfile().getDir();
|
||||
File defaultProfile = GeckoThread.getActiveProfile().getDir();
|
||||
verifyProfile(profile, GeckoProfile.CUSTOM_PROFILE, defaultProfile, true);
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +117,7 @@ public class testGeckoProfile extends PixelTest {
|
|||
f.mkdir();
|
||||
}
|
||||
|
||||
final File testProfileDir = ((GeckoApp) getActivity()).getProfile().getDir();
|
||||
final File testProfileDir = GeckoThread.getActiveProfile().getDir();
|
||||
final String expectedName = name != null ? name : GeckoProfile.CUSTOM_PROFILE;
|
||||
|
||||
final GeckoProfile profile;
|
||||
|
@ -182,7 +183,7 @@ public class testGeckoProfile extends PixelTest {
|
|||
|
||||
// Tests of Guest profile methods
|
||||
private void checkGuestProfile() {
|
||||
final File testProfileDir = ((GeckoApp) getActivity()).getProfile().getDir();
|
||||
final File testProfileDir = GeckoThread.getActiveProfile().getDir();
|
||||
|
||||
mAsserter.info("Test getting a guest profile", "");
|
||||
GeckoProfile profile = GeckoProfile.getGuestProfile(getActivity());
|
||||
|
|
Загрузка…
Ссылка в новой задаче