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

Side by Side Diff: components/cronet/android/test/src/org/chromium/net/SdchObserver.java

Issue 2361413002: Obliterate legacy cronet API. All of its users have been migrated. (Closed)
Patch Set: Created 4 years, 2 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.net; 5 package org.chromium.net;
6 6
7 import android.os.ConditionVariable; 7 import android.os.ConditionVariable;
8 8
9 import org.chromium.base.annotations.CalledByNative; 9 import org.chromium.base.annotations.CalledByNative;
10 import org.chromium.base.annotations.JNINamespace; 10 import org.chromium.base.annotations.JNINamespace;
11 11
12 /** 12 /**
13 * Class to watch for Sdch dictionary events. The native implementation 13 * Class to watch for Sdch dictionary events. The native implementation
14 * unregisters itself when an event happens. Therefore, an instance of this 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. 15 * class is only able to receive a notification of the earliest event.
16 * Currently, implemented events include {@link #onDictionaryAdded}. 16 * Currently, implemented events include {@link #onDictionaryAdded}.
17 */ 17 */
18 @JNINamespace("cronet") 18 @JNINamespace("cronet")
19 public class SdchObserver { 19 public class SdchObserver {
20 protected boolean mDictionaryAlreadyPresent = false; 20 protected boolean mDictionaryAlreadyPresent = false;
21 private final ConditionVariable mAddBlock = new ConditionVariable(); 21 private final ConditionVariable mAddBlock = new ConditionVariable();
22 22
23 /** 23 /**
24 * Constructor. 24 * Constructor.
25 * @param targetUrl the target url on which sdch encoding will be used. 25 * @param targetUrl the target url on which sdch encoding will be used.
26 * @param contextAdapter the native context adapter to register the observer . 26 * @param contextAdapter the native context adapter to register the observer .
27 * @param isLegacyApi whether legacy api is used.
28 */ 27 */
29 public SdchObserver(String targetUrl, long contextAdapter, boolean isLegacyA PI) { 28 public SdchObserver(String targetUrl, long contextAdapter) {
30 if (isLegacyAPI) { 29 nativeAddSdchObserver(targetUrl, contextAdapter);
31 nativeAddSdchObserverLegacyAPI(targetUrl, contextAdapter);
32 } else {
33 nativeAddSdchObserver(targetUrl, contextAdapter);
34 }
35 mAddBlock.block(); 30 mAddBlock.block();
36 mAddBlock.close(); 31 mAddBlock.close();
37 } 32 }
38 33
39 /** 34 /**
40 * Called when a dictionary is added to the SdchManager for the target url. 35 * Called when a dictionary is added to the SdchManager for the target url.
41 * Override this method if caller would like to get notified. 36 * Override this method if caller would like to get notified.
42 */ 37 */
43 @CalledByNative 38 @CalledByNative
44 public void onDictionaryAdded() { 39 public void onDictionaryAdded() {
45 // Left blank; 40 // Left blank;
46 } 41 }
47 42
48 @CalledByNative 43 @CalledByNative
49 private void onAddSdchObserverCompleted() { 44 private void onAddSdchObserverCompleted() {
50 mAddBlock.open(); 45 mAddBlock.open();
51 } 46 }
52 47
53 @CalledByNative 48 @CalledByNative
54 private void onDictionarySetAlreadyPresent() { 49 private void onDictionarySetAlreadyPresent() {
55 mDictionaryAlreadyPresent = true; 50 mDictionaryAlreadyPresent = true;
56 mAddBlock.open(); 51 mAddBlock.open();
57 } 52 }
58 53
59 private native void nativeAddSdchObserver(String targetUrl, long contextAdap ter); 54 private native void nativeAddSdchObserver(String targetUrl, long contextAdap ter);
60 private native void nativeAddSdchObserverLegacyAPI(String targetUrl, long co ntextAdapter);
61 } 55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698