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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/BrowsingDataCounterBridge.java

Issue 1530123002: Prepare ClearBrowsingDataDialogFragment for browsing data counters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@utils
Patch Set: s/default/NUM_TYPES/ Created 4 years, 11 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/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);
+}

Powered by Google App Engine
This is Rietveld 408576698