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..1cf056b69fd7adbee4c8e652a109e60eb762130c |
| --- /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; |
| + |
|
nyquist
2014/06/30 20:33:22
Nit: Ordering. See https://source.android.com/sour
sunangel
2014/07/07 21:21:28
Done.
|
| +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 = |
|
nyquist
2014/06/30 20:33:22
private static final. Also, use camel case in java
sunangel
2014/07/07 21:21:28
Done.
|
| + new HashMap<Profile, DomDistillerService>(); |
| + |
| + /** |
| + * Returns Java DomDistillerService for given Profile. |
| + */ |
| + public static DomDistillerService getDomDistillerServiceForProfile( |
|
nyquist
2014/06/30 20:33:22
This class is already called DomDistillerServiceFa
sunangel
2014/07/07 21:21:29
Done.
|
| + Profile profile) { |
| + DomDistillerService mDDS; |
|
nyquist
2014/06/30 20:33:22
The m-prefix is for members. I think you can just
sunangel
2014/07/07 21:21:28
Done.
|
| + if (profiles_to_DDS.get(profile) == null) { |
| + mDDS = new DomDistillerService( |
| + nativeGetDomDistillerServiceForProfile(profile)); |
| + profiles_to_DDS.put(profile, mDDS); |
| + } else { |
|
nyquist
2014/06/30 20:33:22
Could you add an assert that this is only called o
sunangel
2014/07/07 21:21:28
I think I did this ....not sure if I did it right.
|
| + mDDS = profiles_to_DDS.get(profile); |
| + } |
| + return mDDS; |
| + } |
| + |
| + private static native long nativeGetDomDistillerServiceForProfile( |
|
nyquist
2014/06/30 20:33:22
private static native DomDistillerService nativeGe
|
| + Profile profile); |
| +} |