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

Unified Diff: components/cronet/android/test/src/org/chromium/net/SdchObserver.java

Issue 1133883002: [Cronet] Enable persistence mode for Sdch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@quic_server_remove_loop
Patch Set: Address Misha's comments Created 5 years, 7 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
« no previous file with comments | « components/cronet/android/test/src/org/chromium/net/NativeTestServer.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cronet/android/test/src/org/chromium/net/SdchObserver.java
diff --git a/components/cronet/android/test/src/org/chromium/net/SdchObserver.java b/components/cronet/android/test/src/org/chromium/net/SdchObserver.java
new file mode 100644
index 0000000000000000000000000000000000000000..f3a0f0533a4041e459e4b0759fe1168db3f2c0fd
--- /dev/null
+++ b/components/cronet/android/test/src/org/chromium/net/SdchObserver.java
@@ -0,0 +1,61 @@
+// Copyright 2015 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.net;
+
+import android.os.ConditionVariable;
+
+import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
+
+/**
+ * Class to watch for Sdch dictionary events. The native implementation
+ * unregisters itself when an event happens. Therefore, an instance of this
+ * class is only able to receive a notification of the earliest event.
+ * Currently, implemented events include {@link #onDictionaryAdded}.
+ */
+@JNINamespace("cronet")
+public class SdchObserver {
+ protected boolean mDictionaryAlreadyPresent = false;
+ private final ConditionVariable mAddBlock = new ConditionVariable();
+
+ /**
+ * Constructor.
+ * @param targetUrl the target url on which sdch encoding will be used.
+ * @param contextAdapter the native context adapter to register the observer.
+ * @param isLegacyApi whether legacy api is used.
+ */
+ public SdchObserver(String targetUrl, long contextAdapter, boolean isLegacyAPI) {
+ if (isLegacyAPI) {
+ nativeAddSdchObserverLegacyAPI(targetUrl, contextAdapter);
+ } else {
+ nativeAddSdchObserver(targetUrl, contextAdapter);
+ }
+ mAddBlock.block();
+ mAddBlock.close();
+ }
+
+ /**
+ * Called when a dictionary is added to the SdchManager for the target url.
+ * Override this method if caller would like to get notified.
+ */
+ @CalledByNative
+ public void onDictionaryAdded() {
+ // Left blank;
+ }
+
+ @CalledByNative
+ private void onAddSdchObserverCompleted() {
+ mAddBlock.open();
+ }
+
+ @CalledByNative
+ private void onDictionarySetAlreadyPresent() {
+ mDictionaryAlreadyPresent = true;
+ mAddBlock.open();
+ }
+
+ private native void nativeAddSdchObserver(String targetUrl, long contextAdapter);
+ private native void nativeAddSdchObserverLegacyAPI(String targetUrl, long contextAdapter);
+}
« no previous file with comments | « components/cronet/android/test/src/org/chromium/net/NativeTestServer.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698