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

Side by Side Diff: components/cronet/android/test/cronet_tests_jni.cc

Issue 558333007: Setup initial mock url request job tests for Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Misha's comments Created 6 years, 3 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 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 #include <jni.h> 5 #include <jni.h>
6 6
7 #include "base/android/base_jni_registrar.h" 7 #include "base/android/base_jni_registrar.h"
8 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "base/android/jni_registrar.h" 9 #include "base/android/jni_registrar.h"
10 #include "components/cronet/android/cronet_loader.h" 10 #include "components/cronet/android/cronet_loader.h"
11 #include "cronet_mock_job_interceptor.h"
12 #include "net/url_request/url_request_filter.h"
11 13
12 namespace { 14 namespace {
13 15
14 const base::android::RegistrationMethod kCronetTestsRegisteredMethods[] = { 16 const base::android::RegistrationMethod kCronetTestsRegisteredMethods[] = {
15 {"BaseAndroid", base::android::RegisterJni}, 17 {"BaseAndroid", base::android::RegisterJni},
16 }; 18 };
17 19
18 } // namespace 20 } // namespace
19 21
20 // This is called by the VM when the shared library is first loaded. 22 // This is called by the VM when the shared library is first loaded.
21 // Checks the available version of JNI. Also, caches Java reflection artifacts. 23 // Checks the available version of JNI. Also, caches Java reflection artifacts.
22 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) { 24 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) {
23 JNIEnv* env; 25 JNIEnv* env;
24 if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) { 26 if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
25 return -1; 27 return -1;
26 } 28 }
27 29
28 jint cronet_onload = cronet::CronetOnLoad(vm, reserved); 30 jint cronet_onload = cronet::CronetOnLoad(vm, reserved);
29 if (cronet_onload == -1) 31 if (cronet_onload == -1)
30 return cronet_onload; 32 return cronet_onload;
31 33
32 if (!base::android::RegisterNativeMethods( 34 if (!base::android::RegisterNativeMethods(
33 env, 35 env,
34 kCronetTestsRegisteredMethods, 36 kCronetTestsRegisteredMethods,
35 arraysize(kCronetTestsRegisteredMethods))) { 37 arraysize(kCronetTestsRegisteredMethods))) {
36 return -1; 38 return -1;
37 } 39 }
40
41 if (!cronet::AddUrlInterceptors())
42 return -1;
38 return cronet_onload; 43 return cronet_onload;
39 } 44 }
40 45
41 extern "C" void JNI_OnUnLoad(JavaVM* vm, void* reserved) { 46 extern "C" void JNI_OnUnLoad(JavaVM* vm, void* reserved) {
47 net::URLRequestFilter::GetInstance()->ClearHandlers();
42 cronet::CronetOnUnLoad(vm, reserved); 48 cronet::CronetOnUnLoad(vm, reserved);
43 } 49 }
44 50
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698