Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 #include "components/cronet/android/test/experimental_options_test.h" | |
| 6 | |
| 7 #include <jni.h> | |
| 8 | |
| 9 #include "base/android/jni_android.h" | |
| 10 #include "base/android/scoped_java_ref.h" | |
| 11 #include "base/time/time.h" | |
| 12 #include "components/cronet/android/test/cronet_test_util.h" | |
| 13 #include "jni/ExperimentalOptionsTest_jni.h" | |
| 14 #include "net/base/address_family.h" | |
| 15 #include "net/base/net_errors.h" | |
| 16 #include "net/dns/host_cache.h" | |
| 17 #include "net/dns/host_resolver.h" | |
| 18 #include "net/url_request/url_request_context.h" | |
| 19 | |
| 20 using base::android::JavaParamRef; | |
| 21 | |
| 22 namespace cronet { | |
| 23 | |
| 24 namespace { | |
| 25 void WriteToHostCacheOnNetworkThread(jlong jcontext_adapter) { | |
| 26 net::URLRequestContext* context = | |
| 27 TestUtil::GetURLRequestContext(jcontext_adapter); | |
| 28 net::HostCache* cache = context->host_resolver()->GetHostCache(); | |
| 29 net::HostCache::Key key("host-cache-test-host", | |
| 30 net::ADDRESS_FAMILY_UNSPECIFIED, 0); | |
| 31 net::HostCache::Entry entry(net::OK, net::AddressList()); | |
|
pauljensen
2017/06/26 16:37:17
can we put in a legitimate IP address? like the on
mgersh
2017/06/26 23:21:45
I like that idea. Thanks! Done.
| |
| 32 cache->Set(key, entry, base::TimeTicks::Now(), | |
| 33 base::TimeDelta::FromSeconds(1)); | |
| 34 } | |
| 35 } // namespace | |
| 36 | |
| 37 static void WriteToHostCache(JNIEnv* env, | |
| 38 const JavaParamRef<jclass>& jcaller, | |
| 39 jlong jcontext_adapter) { | |
| 40 TestUtil::RunAfterContextInit( | |
| 41 jcontext_adapter, | |
| 42 base::Bind(&WriteToHostCacheOnNetworkThread, jcontext_adapter)); | |
| 43 } | |
| 44 | |
| 45 bool RegisterExperimentalOptionsTest(JNIEnv* env) { | |
| 46 return RegisterNativesImpl(env); | |
| 47 } | |
| 48 | |
| 49 } // namespace cronet | |
| OLD | NEW |