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

Side by Side Diff: components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java

Issue 2909663002: [Cronet] Add API to set DNS cache entry
Patch Set: Created 3 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/cronet_url_request_context_adapter.cc ('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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.impl; 5 package org.chromium.net.impl;
6 6
7 import android.os.ConditionVariable; 7 import android.os.ConditionVariable;
8 import android.os.Process; 8 import android.os.Process;
9 9
10 import org.chromium.base.Log; 10 import org.chromium.base.Log;
11 import org.chromium.base.ObserverList; 11 import org.chromium.base.ObserverList;
12 import org.chromium.base.VisibleForTesting; 12 import org.chromium.base.VisibleForTesting;
13 import org.chromium.base.annotations.CalledByNative; 13 import org.chromium.base.annotations.CalledByNative;
14 import org.chromium.base.annotations.JNINamespace; 14 import org.chromium.base.annotations.JNINamespace;
15 import org.chromium.base.annotations.NativeClassQualifiedName; 15 import org.chromium.base.annotations.NativeClassQualifiedName;
16 import org.chromium.base.annotations.UsedByReflection; 16 import org.chromium.base.annotations.UsedByReflection;
17 import org.chromium.net.BidirectionalStream; 17 import org.chromium.net.BidirectionalStream;
18 import org.chromium.net.EffectiveConnectionType; 18 import org.chromium.net.EffectiveConnectionType;
19 import org.chromium.net.ExperimentalBidirectionalStream; 19 import org.chromium.net.ExperimentalBidirectionalStream;
20 import org.chromium.net.NetworkQualityRttListener; 20 import org.chromium.net.NetworkQualityRttListener;
21 import org.chromium.net.NetworkQualityThroughputListener; 21 import org.chromium.net.NetworkQualityThroughputListener;
22 import org.chromium.net.RequestFinishedInfo; 22 import org.chromium.net.RequestFinishedInfo;
23 import org.chromium.net.RttThroughputValues; 23 import org.chromium.net.RttThroughputValues;
24 import org.chromium.net.UrlRequest; 24 import org.chromium.net.UrlRequest;
25 import org.chromium.net.urlconnection.CronetHttpURLConnection; 25 import org.chromium.net.urlconnection.CronetHttpURLConnection;
26 import org.chromium.net.urlconnection.CronetURLStreamHandlerFactory; 26 import org.chromium.net.urlconnection.CronetURLStreamHandlerFactory;
27 27
28 import java.net.InetAddress;
28 import java.net.Proxy; 29 import java.net.Proxy;
29 import java.net.URL; 30 import java.net.URL;
30 import java.net.URLConnection; 31 import java.net.URLConnection;
31 import java.net.URLStreamHandlerFactory; 32 import java.net.URLStreamHandlerFactory;
32 import java.util.ArrayList; 33 import java.util.ArrayList;
33 import java.util.Collection; 34 import java.util.Collection;
34 import java.util.HashMap; 35 import java.util.HashMap;
35 import java.util.List; 36 import java.util.List;
36 import java.util.Map; 37 import java.util.Map;
37 import java.util.concurrent.Executor; 38 import java.util.concurrent.Executor;
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 return new CronetHttpURLConnection(url, this); 492 return new CronetHttpURLConnection(url, this);
492 } 493 }
493 throw new UnsupportedOperationException("Unexpected protocol:" + protoco l); 494 throw new UnsupportedOperationException("Unexpected protocol:" + protoco l);
494 } 495 }
495 496
496 @Override 497 @Override
497 public URLStreamHandlerFactory createURLStreamHandlerFactory() { 498 public URLStreamHandlerFactory createURLStreamHandlerFactory() {
498 return new CronetURLStreamHandlerFactory(this); 499 return new CronetURLStreamHandlerFactory(this);
499 } 500 }
500 501
502 @Override
503 public void putHostCache(String hostName, InetAddress[] ipAddresses, int sec ondsToLive) {
504 byte[][] addresses = new byte[ipAddresses.length][];
505 for (int i = 0; i < ipAddresses.length; i++) {
506 addresses[i] = ipAddresses[i].getAddress();
507 }
508 synchronized (mLock) {
509 checkHaveAdapter();
510 nativePutHostCache(mUrlRequestContextAdapter, hostName, addresses, s econdsToLive);
511 }
512 }
513
501 /** 514 /**
502 * Mark request as started to prevent shutdown when there are active 515 * Mark request as started to prevent shutdown when there are active
503 * requests. 516 * requests.
504 */ 517 */
505 void onRequestStarted() { 518 void onRequestStarted() {
506 mActiveRequestCount.incrementAndGet(); 519 mActiveRequestCount.incrementAndGet();
507 } 520 }
508 521
509 /** 522 /**
510 * Mark request as finished to allow shutdown when there are no active 523 * Mark request as finished to allow shutdown when there are no active
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 @NativeClassQualifiedName("CronetURLRequestContextAdapter") 723 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
711 private native void nativeConfigureNetworkQualityEstimatorForTesting(long na tivePtr, 724 private native void nativeConfigureNetworkQualityEstimatorForTesting(long na tivePtr,
712 boolean useLocalHostRequests, boolean useSmallerResponses, boolean d isableOfflineCheck); 725 boolean useLocalHostRequests, boolean useSmallerResponses, boolean d isableOfflineCheck);
713 726
714 @NativeClassQualifiedName("CronetURLRequestContextAdapter") 727 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
715 private native void nativeProvideRTTObservations(long nativePtr, boolean sho uld); 728 private native void nativeProvideRTTObservations(long nativePtr, boolean sho uld);
716 729
717 @NativeClassQualifiedName("CronetURLRequestContextAdapter") 730 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
718 private native void nativeProvideThroughputObservations(long nativePtr, bool ean should); 731 private native void nativeProvideThroughputObservations(long nativePtr, bool ean should);
719 732
733 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
734 private native void nativePutHostCache(
735 long nativePtr, String hostName, byte[][] addresses, int secondsToLi ve);
736
720 public boolean isNetworkThread(Thread thread) { 737 public boolean isNetworkThread(Thread thread) {
721 return thread == mNetworkThread; 738 return thread == mNetworkThread;
722 } 739 }
723 } 740 }
OLDNEW
« no previous file with comments | « components/cronet/android/cronet_url_request_context_adapter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698