Index: components/cronet/android/test/experimental_options_test.cc |
diff --git a/components/cronet/android/test/experimental_options_test.cc b/components/cronet/android/test/experimental_options_test.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..af320150bd24f7bd762a2cea9c3c50441f064b4a |
--- /dev/null |
+++ b/components/cronet/android/test/experimental_options_test.cc |
@@ -0,0 +1,49 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/cronet/android/test/experimental_options_test.h" |
+ |
+#include <jni.h> |
+ |
+#include "base/android/jni_android.h" |
+#include "base/android/scoped_java_ref.h" |
+#include "base/time/time.h" |
+#include "components/cronet/android/test/cronet_test_util.h" |
+#include "jni/ExperimentalOptionsTest_jni.h" |
+#include "net/base/address_family.h" |
+#include "net/base/net_errors.h" |
+#include "net/dns/host_cache.h" |
+#include "net/dns/host_resolver.h" |
+#include "net/url_request/url_request_context.h" |
+ |
+using base::android::JavaParamRef; |
+ |
+namespace cronet { |
+ |
+namespace { |
+void WriteToHostCacheOnNetworkThread(jlong jcontext_adapter) { |
+ net::URLRequestContext* context = |
+ TestUtil::GetURLRequestContext(jcontext_adapter); |
+ net::HostCache* cache = context->host_resolver()->GetHostCache(); |
+ net::HostCache::Key key("host-cache-test-host", |
+ net::ADDRESS_FAMILY_UNSPECIFIED, 0); |
+ 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.
|
+ cache->Set(key, entry, base::TimeTicks::Now(), |
+ base::TimeDelta::FromSeconds(1)); |
+} |
+} // namespace |
+ |
+static void WriteToHostCache(JNIEnv* env, |
+ const JavaParamRef<jclass>& jcaller, |
+ jlong jcontext_adapter) { |
+ TestUtil::RunAfterContextInit( |
+ jcontext_adapter, |
+ base::Bind(&WriteToHostCacheOnNetworkThread, jcontext_adapter)); |
+} |
+ |
+bool RegisterExperimentalOptionsTest(JNIEnv* env) { |
+ return RegisterNativesImpl(env); |
+} |
+ |
+} // namespace cronet |