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

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 "mock_url_request_job_test.h"
11 12
12 namespace { 13 namespace {
13 14
14 const base::android::RegistrationMethod kCronetTestsRegisteredMethods[] = { 15 const base::android::RegistrationMethod kCronetTestsRegisteredMethods[] = {
15 {"BaseAndroid", base::android::RegisterJni}, 16 {"MockURLRequestJobTest", cronet::RegisterMockUrlRequestJobTest},
mmenke 2014/09/23 14:48:05 nit: 2 space indent is more common for initialize
xunjieli 2014/09/23 15:21:23 Done.
16 }; 17 };
17 18
18 } // namespace 19 } // namespace
19 20
20 // This is called by the VM when the shared library is first loaded. 21 // 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. 22 // Checks the available version of JNI. Also, caches Java reflection artifacts.
22 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) { 23 extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) {
23 JNIEnv* env; 24 JNIEnv* env;
24 if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) { 25 if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
25 return -1; 26 return -1;
26 } 27 }
27 28
28 jint cronet_onload = cronet::CronetOnLoad(vm, reserved); 29 jint cronet_onload = cronet::CronetOnLoad(vm, reserved);
29 if (cronet_onload == -1) 30 if (cronet_onload == -1)
30 return cronet_onload; 31 return cronet_onload;
31 32
32 if (!base::android::RegisterNativeMethods( 33 if (!base::android::RegisterNativeMethods(
33 env, 34 env,
34 kCronetTestsRegisteredMethods, 35 kCronetTestsRegisteredMethods,
35 arraysize(kCronetTestsRegisteredMethods))) { 36 arraysize(kCronetTestsRegisteredMethods))) {
36 return -1; 37 return -1;
37 } 38 }
38 return cronet_onload; 39 return cronet_onload;
39 } 40 }
40 41
41 extern "C" void JNI_OnUnLoad(JavaVM* vm, void* reserved) { 42 extern "C" void JNI_OnUnLoad(JavaVM* vm, void* reserved) {
42 cronet::CronetOnUnLoad(vm, reserved); 43 cronet::CronetOnUnLoad(vm, reserved);
43 } 44 }
44 45
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698