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

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: Addressed 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 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.assertEquals;
10 import static junit.framework.Assert.assertNull;
11
12 import org.chromium.base.CalledByNative;
13 import org.chromium.base.JNINamespace;
14
15 /**
16 * Test utilities related to Sdch.
17 */
18 @JNINamespace("cronet")
19 public final class SdchTestUtil {
20 // Blocks until the native SdchObserver is added or removed.
21 private static final ConditionVariable sAddRemoveBlock = new ConditionVariab le();
22
23 /**
24 * Abstract class to listen for callbacks of the native SdchObserver.
25 */
26 public abstract static class SdchObserverCallback {
27 /**
28 * Called when a dictionary is added to the SdchManager.
29 * @param url the url of the dictionary added.
30 */
31 public abstract void onDictionaryAdded(String url);
32 }
33
34 private static SdchObserverCallback sCallback;
35
36 public static void registerSdchObserverCallback(
37 long contextAdapter, SdchObserverCallback callback, boolean isLegacy API) {
38 assertNull(sCallback);
39 sCallback = callback;
40 nativeAddRemoveSdchObserver(contextAdapter, isLegacyAPI, true /** add */ );
41 sAddRemoveBlock.block();
42 sAddRemoveBlock.close();
43 }
44
45 public static void unregisterSdchObserverCallback(
46 long contextAdapter, SdchObserverCallback callback, boolean isLegacy API) {
47 assertEquals(sCallback, callback);
48 sCallback = null;
49 nativeAddRemoveSdchObserver(contextAdapter, isLegacyAPI, false /** add * /);
50 sAddRemoveBlock.block();
51 sAddRemoveBlock.close();
52 }
53
54 @CalledByNative
55 private static void onDictionaryAdded(String dictionaryURL) {
56 if (sCallback != null) {
57 sCallback.onDictionaryAdded(dictionaryURL);
58 }
59 }
60
61 @CalledByNative
62 private static void onAddRemoveSdchObserverCompleted() {
63 sAddRemoveBlock.open();
64 }
65
66 private static native void nativeAddRemoveSdchObserver(
67 long contextAdapter, boolean isLegacyAPI, boolean add);
68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698