Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/BrowsingDataCounterBridge.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/BrowsingDataCounterBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/BrowsingDataCounterBridge.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e84eae3d7ea5701c4f862e5b0402ed1876f1e6ef |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/BrowsingDataCounterBridge.java |
| @@ -0,0 +1,55 @@ |
| +// Copyright 2016 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.preferences.privacy; |
| + |
| +import org.chromium.base.annotations.CalledByNative; |
| + |
| +/** |
| + * Communicates between BrowsingDataCounter (C++ backend) and ClearBrowsingDataFragment (Java UI). |
| + */ |
| +public class BrowsingDataCounterBridge { |
| + /** |
| + * Can receive a callback from a BrowsingDataCounter. |
| + */ |
| + public interface BrowsingDataCounterCallback { |
| + /** |
| + * The callback to be called when a BrowsingDataCounter is finished. |
| + * @param result the result of the counter. |
|
newt (away)
2016/01/13 20:01:49
how about: "A string describing how much storage s
msramek
2016/01/14 15:45:43
Done.
|
| + */ |
| + public void onCounterFinished(String result); |
| + } |
| + |
| + private long mNativeBrowsingDataCounterBridge; |
| + private BrowsingDataCounterCallback mCallback; |
| + |
| + /** |
| + * Initializes BrowsingDataCounterBridge. |
| + * @param callback a callback to call with the result when the counter finishes. |
| + * @param dataType the browsing data type to be counted (from the shared enum |
| + * {@link org.chromium.chrome.browser.BrowsingDataType}). |
| + */ |
| + public BrowsingDataCounterBridge(BrowsingDataCounterCallback callback, int dataType) { |
| + mCallback = callback; |
| + mNativeBrowsingDataCounterBridge = nativeInit(dataType); |
| + } |
| + |
| + /** |
| + * Destroys the native counterpart of this class. |
| + */ |
| + public void destroy() { |
| + if (mNativeBrowsingDataCounterBridge != 0) { |
| + nativeDestroy(mNativeBrowsingDataCounterBridge); |
| + mNativeBrowsingDataCounterBridge = 0; |
| + } |
| + } |
| + |
| + @CalledByNative |
| + private void onBrowsingDataCounterFinished(String result) { |
| + mCallback.onCounterFinished(result); |
| + } |
| + |
| + private native long nativeInit(int dataType); |
| + private native void nativeDestroy(long nativeBrowsingDataCounterBridge); |
| +} |