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..0d45e10c8bca3d04bd34702f94e1dc2a031e6e20 |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/BrowsingDataCounterBridge.java |
@@ -0,0 +1,56 @@ |
+// 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 A string describing how much storage space will be reclaimed by clearing |
+ * this data type. |
+ */ |
+ 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); |
+} |