Index: chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/DomDistillerServiceFactory.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/DomDistillerServiceFactory.java b/chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/DomDistillerServiceFactory.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8a080babc30d8ee6f18f98c200dae4ffcd208161 |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/DomDistillerServiceFactory.java |
@@ -0,0 +1,38 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.chrome.browser.dom_distiller; |
+ |
+import org.chromium.base.JNINamespace; |
+import org.chromium.base.ThreadUtils; |
+import org.chromium.chrome.browser.profiles.Profile; |
+import org.chromium.components.dom_distiller.core.DomDistillerService; |
+ |
+import java.util.HashMap; |
+ |
+/** |
+ * DomDistillerServiceFactory maps Profiles to DomDistillerServices. |
nyquist
2014/07/09 23:49:03
Nit: Maybe "to {@link DomDistillerService} instanc
sunangel
2014/07/10 14:31:52
Done.
|
+ */ |
+@JNINamespace("dom_distiller::android") |
+public class DomDistillerServiceFactory { |
+ |
+ private static final HashMap<Profile, DomDistillerService> sServiceMap = |
+ new HashMap<Profile, DomDistillerService>(); |
+ |
+ /** |
+ * Returns Java DomDistillerService for given Profile. |
+ */ |
+ public static DomDistillerService getForProfile( |
+ Profile profile) { |
+ ThreadUtils.assertOnUiThread(); |
+ DomDistillerService service = sServiceMap.get(profile); |
+ if (service == null) { |
+ service = (DomDistillerService) nativeGetForProfile(profile); |
+ sServiceMap.put(profile, service); |
+ } |
+ return service; |
+ } |
+ |
+ private static native DomDistillerService nativeGetForProfile(Profile profile); |
+} |