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

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

Issue 340403004: Java wrapper for DistilledPagePrefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: namespaces to classes, native init, enum Created 6 years, 5 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
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..de39d5042bac0c9260dfbe75addd79bcb6808d81
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/DomDistillerServiceFactory.java
@@ -0,0 +1,37 @@
+// 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.
+ */
+@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 mDDS = sServiceMap.get(profile);
nyquist 2014/07/08 01:02:32 s/mDDS/service/
sunangel 2014/07/08 20:40:56 Done.
+ if (sServiceMap.get(profile) == null) {
+ mDDS = (DomDistillerService) nativeGetForProfile(profile);
+ sServiceMap.put(profile, mDDS);
+ }
+ return mDDS;
+ }
+ private static native DomDistillerService nativeGetForProfile(Profile profile);
nyquist 2014/07/08 01:02:32 missing newline before this.
sunangel 2014/07/08 20:40:56 Done.
+}

Powered by Google App Engine
This is Rietveld 408576698