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

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: Missing include 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 * Wrapper class to start an in-process native test server, and get URLs
17 * needed to talk to it.
18 */
19 @JNINamespace("cronet")
20 public final class SdchTestUtil {
21 // Blocks until Sdch observer is added or removed.
22 private static final ConditionVariable sAddRemoveBlock = new ConditionVariab le();
23
24 /**
25 * SdchObserver interface.
26 */
27 public static interface SdchObserver {
28 /**
29 * Called when a dictionary is added to the SdchManager.
30 * @param url the url of the dictionary added.
31 */
32 public void onDictionaryAdded(String url);
33 }
34
35 private static SdchObserver sObserver;
36
37 public static void addSdchObserver(
38 long contextAdapter, SdchObserver observer, boolean isLegacyAPI) {
39 assertNull(sObserver);
40 sObserver = observer;
41 nativeAddRemoveSdchObserver(contextAdapter, isLegacyAPI, true /** add */ );
42 sAddRemoveBlock.block();
43 sAddRemoveBlock.close();
44 }
45
46 public static void removeSdchObserver(
47 long contextAdapter, SdchObserver observer, boolean isLegacyAPI) {
48 assertEquals(sObserver, observer);
49 sObserver = null;
50 nativeAddRemoveSdchObserver(contextAdapter, isLegacyAPI, false /** add * /);
51 sAddRemoveBlock.block();
52 sAddRemoveBlock.close();
53 }
54
55 @CalledByNative
56 private static void onDictionaryAdded(String dictionaryURL) {
57 if (sObserver != null) {
58 sObserver.onDictionaryAdded(dictionaryURL);
59 }
60 }
61
62 @CalledByNative
63 private static void onAddRemoveSdchObserver() {
64 sAddRemoveBlock.open();
65 }
66
67 private static native void nativeAddRemoveSdchObserver(
68 long contextAdapter, boolean isLegacyAPI, boolean add);
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698