Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1553)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ChromeApplication.java

Issue 2673113002: Remove implementation map from ChromeApplication (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/ChromeApplication.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeApplication.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeApplication.java
index a15c2f93b5271900e45964e21493373028c209c6..2a973473ef9c52ed815d48f98dbb072e92580b95 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeApplication.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeApplication.java
@@ -11,7 +11,6 @@ import android.content.SharedPreferences;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
-import android.support.v4.util.ArrayMap;
import android.util.Log;
import org.chromium.base.ActivityState;
@@ -67,8 +66,6 @@ import org.chromium.content.browser.ChildProcessCreationParams;
import org.chromium.policy.AppRestrictionsProvider;
import org.chromium.policy.CombinedPolicyProvider;
-import java.util.Map;
-
/**
* Basic application functionality that should be shared among all browser applications that use
* chrome layer.
@@ -84,17 +81,10 @@ public class ChromeApplication extends ContentApplication {
private static DocumentTabModelSelector sDocumentTabModelSelector;
- protected Map<Class, Class> mImplementationMap;
-
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
ContextUtils.initApplicationContext(this);
-
- // This field may be used before onCreate is called, so we need to create it here.
- // It may be wise to update this anticipated capacity from time time as expectations for
- // the quantity of downsteam-specific implementations increases (or decreases).
- mImplementationMap = new ArrayMap<Class, Class>(8);
}
/**
@@ -430,39 +420,4 @@ public class ChromeApplication extends ContentApplication {
public AccountManagerDelegate createAccountManagerDelegate() {
return new SystemAccountManagerDelegate(this);
}
-
- /**
- * Instantiates an object of a given type.
- * This method exists as a utility to generate objects of types that have different
- * implementations upstream and downstream. To use this,
- * - give the upstream class a public parameterless constructor (required!)
- * e.g., public MyType() {},
- * - register the downstream object in mImplementationMap,
- * e.g., mImplementationMap.put(MyType.class, MySubType.class);
- * - invoke this method on the appropriate class,
- * e.g., ChromeApplication.createObject(MyType.class).
- * @param klass The class that the Chrome Application should create an instance of.
- */
- @SuppressWarnings("unchecked")
- public static <T> T createObject(Class<T> klass) {
- Class newKlass = ((ChromeApplication) ContextUtils.getApplicationContext())
- .mImplementationMap.get(klass);
- if (newKlass == null) {
- newKlass = klass;
- }
-
- Object obj;
- try {
- obj = newKlass.newInstance();
- } catch (InstantiationException e) {
- throw new RuntimeException("Asked to create unexpected class: " + klass.getName(), e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException("Asked to create unexpected class: " + klass.getName(), e);
- }
- if (!klass.isInstance(obj)) {
- throw new RuntimeException("Created an instance of type " + obj.getClass().getName()
- + " when expected an instance of type " + klass.getName());
- }
- return (T) obj;
- }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698