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

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: Address Misha's comments Created 5 years, 6 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
« no previous file with comments | « components/cronet/android/test/src/org/chromium/net/NativeTestServer.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /**
24 * Constructor.
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.
28 */
29 public SdchObserver(String targetUrl, long contextAdapter, boolean isLegacyA PI) {
30 if (isLegacyAPI) {
31 nativeAddSdchObserverLegacyAPI(targetUrl, contextAdapter);
32 } else {
33 nativeAddSdchObserver(targetUrl, contextAdapter);
34 }
35 mAddBlock.block();
36 mAddBlock.close();
37 }
38
39 /**
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.
42 */
43 @CalledByNative
44 public void onDictionaryAdded() {
45 // Left blank;
46 }
47
48 @CalledByNative
49 private void onAddSdchObserverCompleted() {
50 mAddBlock.open();
51 }
52
53 @CalledByNative
54 private void onDictionarySetAlreadyPresent() {
55 mDictionaryAlreadyPresent = true;
56 mAddBlock.open();
57 }
58
59 private native void nativeAddSdchObserver(String targetUrl, long contextAdap ter);
60 private native void nativeAddSdchObserverLegacyAPI(String targetUrl, long co ntextAdapter);
61 }
OLDNEW
« no previous file with comments | « components/cronet/android/test/src/org/chromium/net/NativeTestServer.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698