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

Side by Side 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: Removed globals 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 org.chromium.base.CalledByNative;
10 import org.chromium.base.JNINamespace;
11
12 /**
13 * Class to watch for Sdch dictionary events. The native implementation
14 * unregisters itself when an event happens. Therefore, an instance of this
15 * class is only able to receive a notification of the earliest event.
16 * Currently, implemented events include {@link #onDictionaryAdded}.
17 */
18 @JNINamespace("cronet")
19 public class SdchObserver {
20 protected boolean mDictionaryAlreadyPresent = false;
21 private final ConditionVariable mAddBlock = new ConditionVariable();
22
23 public SdchObserver(String targetUrl, long contextAdapter, boolean isLegacyA PI) {
24 if (isLegacyAPI) {
25 nativeAddSdchObserverLegacyAPI(targetUrl, contextAdapter);
26 } else {
27 nativeAddSdchObserver(targetUrl, contextAdapter);
28 }
29 mAddBlock.block();
30 mAddBlock.close();
31 }
32
33 /**
34 * Called when a dictionary is added to the SdchManager.
35 * Override this method if caller would like to get notified.
36 * @param url the url of the dictionary added.
37 */
38 @CalledByNative
39 public void onDictionaryAdded(String url) {
40 // Left blank;
41 }
42
43 @CalledByNative
44 private void onAddSdchObserverCompleted() {
45 mAddBlock.open();
46 }
47
48 @CalledByNative
49 private void onDictionarySetAlreadyPresent() {
50 mDictionaryAlreadyPresent = true;
51 mAddBlock.open();
52 }
53
54 private native void nativeAddSdchObserver(String targetUrl, long contextAdap ter);
55 private native void nativeAddSdchObserverLegacyAPI(String targetUrl, long co ntextAdapter);
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698