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

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 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 untilities lated to Sdch.
mef 2015/05/19 21:39:44 nit: typos.
xunjieli 2015/05/20 15:50:41 Done. So many typos :( not sure whether my mind wa
17 */
18 @JNINamespace("cronet")
19 public final class SdchTestUtil {
20 // Blocks until Sdch observer is added or removed.
21 private static final ConditionVariable sAddRemoveBlock = new ConditionVariab le();
22
23 /**
24 * SdchObserver interface.
25 */
26 public static interface SdchObserver {
mef 2015/05/19 21:39:44 nit: should it be interface OnDictionaryAddedListe
xunjieli 2015/05/20 15:50:41 You are right. If it's an interface, it should be
27 /**
28 * Called when a dictionary is added to the SdchManager.
29 * @param url the url of the dictionary added.
30 */
31 public void onDictionaryAdded(String url);
32 }
33
34 private static SdchObserver sObserver;
35
36 public static void addSdchObserver(
mef 2015/05/19 21:39:44 addDictionaryAddedListener?
xunjieli 2015/05/20 15:50:41 Done.
37 long contextAdapter, SdchObserver observer, boolean isLegacyAPI) {
38 assertNull(sObserver);
39 sObserver = observer;
40 nativeAddRemoveSdchObserver(contextAdapter, isLegacyAPI, true /** add */ );
41 sAddRemoveBlock.block();
42 sAddRemoveBlock.close();
43 }
44
45 public static void removeSdchObserver(
mef 2015/05/19 21:39:44 removeDictionaryAddedListener?
xunjieli 2015/05/20 15:50:41 Done.
46 long contextAdapter, SdchObserver observer, boolean isLegacyAPI) {
47 assertEquals(sObserver, observer);
48 sObserver = 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 (sObserver != null) {
57 sObserver.onDictionaryAdded(dictionaryURL);
58 }
59 }
60
61 @CalledByNative
62 private static void onAddRemoveSdchObserver() {
mef 2015/05/19 21:39:44 maybe call it 'onAddRemoveSdchObserverCompleted'?
xunjieli 2015/05/20 15:50:41 Done.
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