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.
5 package org
.chromium
.net
;
7 import android
.os
.ConditionVariable
;
9 import org
.chromium
.base
.annotations
.CalledByNative
;
10 import org
.chromium
.base
.annotations
.JNINamespace
;
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}.
18 @JNINamespace("cronet")
19 public class SdchObserver
{
20 protected boolean mDictionaryAlreadyPresent
= false;
21 private final ConditionVariable mAddBlock
= new ConditionVariable();
25 * @param targetUrl the target url on which sdch encoding will be used.
26 * @param contextAdapter the native context adapter to register the observer.
27 * @param isLegacyApi whether legacy api is used.
29 public SdchObserver(String targetUrl
, long contextAdapter
, boolean isLegacyAPI
) {
31 nativeAddSdchObserverLegacyAPI(targetUrl
, contextAdapter
);
33 nativeAddSdchObserver(targetUrl
, contextAdapter
);
40 * Called when a dictionary is added to the SdchManager for the target url.
41 * Override this method if caller would like to get notified.
44 public void onDictionaryAdded() {
49 private void onAddSdchObserverCompleted() {
54 private void onDictionarySetAlreadyPresent() {
55 mDictionaryAlreadyPresent
= true;
59 private native void nativeAddSdchObserver(String targetUrl
, long contextAdapter
);
60 private native void nativeAddSdchObserverLegacyAPI(String targetUrl
, long contextAdapter
);