Chromium Code Reviews| 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..51fa866251a7dc222d9689f546741c579759d40e |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/dom_distiller/DomDistillerServiceFactory.java |
| @@ -0,0 +1,39 @@ |
| +// 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 java.util.HashMap; |
| + |
| +import org.chromium.chrome.browser.profiles.Profile; |
| +import org.chromium.components.dom_distiller.core.DomDistillerService; |
| + |
| +/** |
| + * DomDistillerServiceFactory maps Profiles to DomDistillerServices. |
| + */ |
| +public class DomDistillerServiceFactory { |
| + |
| + static HashMap<Profile, DomDistillerService> profiles_to_DDS = |
| + new HashMap<Profile, DomDistillerService>(); |
|
robliao
2014/06/27 18:08:49
Does this need to be a thread-safe hash-map?
sunangel
2014/06/27 18:16:29
I don't think so, already asked nyquist@ once befo
|
| + |
| + /** |
| + * Returns Java DomDistillerService for given Profile. |
|
robliao
2014/06/27 18:08:49
Align the asterisks.
sunangel
2014/06/27 18:16:29
Done.
|
| + */ |
| + public static DomDistillerService getDomDistillerServiceForProfile( |
| + Profile profile) { |
| + DomDistillerService mDDS; |
| + if (profiles_to_DDS.get(profile) == null) { |
| + mDDS = new DomDistillerService( |
| + nativeGetDomDistillerServiceForProfile(profile)); |
| + profiles_to_DDS.put(profile, mDDS); |
| + } |
| + else { |
|
robliao
2014/06/27 18:08:49
} else {
sunangel
2014/06/27 18:16:29
Done.
|
| + mDDS = profiles_to_DDS.get(profile); |
| + } |
| + return mDDS; |
| + } |
| + |
| + private static native long nativeGetDomDistillerServiceForProfile( |
| + Profile profile); |
| +} |