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

Side by Side Diff: components/cronet/android/test/src/org/chromium/net/SdchTestUtil.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: Remove pref file support from legacy API 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.net;
6
7 import android.os.ConditionVariable;
8
9 import static junit.framework.Assert.assertNull;
10
11 import org.chromium.base.CalledByNative;
12 import org.chromium.base.JNINamespace;
13
14 /**
15 * Test utilities related to Sdch.
16 */
17 @JNINamespace("cronet")
18 public final class SdchTestUtil {
19 // Blocks until the native SdchObserver is added.
20 private static final ConditionVariable sAddBlock = new ConditionVariable();
21
22 /**
23 * Abstract class to listen for callbacks of the native SdchObserver.
24 */
25 public abstract static class SdchObserverCallback {
26 /**
27 * Called when a dictionary is added to the SdchManager.
28 * @param url the url of the dictionary added.
29 */
30 public abstract void onDictionaryAdded(String url);
31 }
32
33 private static SdchObserverCallback sCallback;
34 private static boolean sRegisterSdchObserverSucceeded = false;
35
36 /**
37 * Returns whether the native SdchObserver has been registered. The native
38 * SdchObserver will not be registered when dictionaries for the
39 * {@code targetUrl} are already loaded, for example.
40 */
41 public static boolean registerSdchObserverCallback(String targetUrl, long co ntextAdapter,
42 SdchObserverCallback callback, boolean isLegacyAPI) {
43 assertNull(sCallback);
44 sCallback = callback;
45 nativeAddSdchObserver(targetUrl, contextAdapter, isLegacyAPI);
46 sAddBlock.block();
47 sAddBlock.close();
48 return sRegisterSdchObserverSucceeded;
49 }
50
51 @CalledByNative
52 private static void onDictionaryAdded(String dictionaryURL) {
53 if (sCallback != null) {
54 sCallback.onDictionaryAdded(dictionaryURL);
55 sCallback = null;
56 }
57 }
58
59 @CalledByNative
60 private static void onAddSdchObserverCompleted(boolean succeeded) {
61 sRegisterSdchObserverSucceeded = succeeded;
62 sAddBlock.open();
63 }
64
65 private static native void nativeAddSdchObserver(
66 String targetUrl, long contextAdapter, boolean isLegacyAPI);
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698