OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef COMPONENTS_CRONET_ANDROID_TEST_CRONET_TEST_UTIL_H_ | 5 #ifndef COMPONENTS_CRONET_ANDROID_TEST_CRONET_TEST_UTIL_H_ |
6 #define COMPONENTS_CRONET_ANDROID_TEST_CRONET_TEST_UTIL_H_ | 6 #define COMPONENTS_CRONET_ANDROID_TEST_CRONET_TEST_UTIL_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include "base/android/jni_android.h" | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/single_thread_task_runner.h" | |
12 | |
13 namespace net { | |
14 class URLRequest; | |
15 class URLRequestContext; | |
16 } // namespace net | |
9 | 17 |
10 namespace cronet { | 18 namespace cronet { |
11 | 19 |
12 bool RegisterCronetTestUtil(JNIEnv* env); | 20 // Various test utility functions for testing Cronet. |
21 class TestUtil { | |
xunjieli
2016/10/27 14:49:42
I guess it doesn't make sense for this to have a c
pauljensen
2016/10/28 15:24:42
I've gone one step further and used DISALLOW_IMPLI
| |
22 public: | |
23 // CronetURLRequestContextAdapter manipulation: | |
24 | |
25 // Returns SingleThreadTaskRunner for the network thread of the context | |
26 // adapter. | |
27 static scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner( | |
28 jlong jcontext_adapter); | |
29 // Returns underlying URLRequestContext. | |
30 static net::URLRequestContext* GetURLRequestContext(jlong jcontext_adapter); | |
31 // Run |task| after URLRequestContext is initialized. | |
32 static void RunAfterContextInit(jlong jcontext_adapter, | |
33 const base::Closure& task); | |
34 | |
35 // CronetURLRequestAdapter manipulation: | |
36 | |
37 // Returns underlying URLRequest. | |
38 static net::URLRequest* GetURLRequest(jlong jrequest_adapter); | |
39 | |
40 // Register JNI. | |
41 static bool Register(JNIEnv* env); | |
42 | |
43 private: | |
44 static void RunAfterContextInitOnNetworkThread(jlong jcontext_adapter, | |
xunjieli
2016/10/27 14:49:42
The style guide encourages making this file local,
pauljensen
2016/10/28 15:24:42
This function needs to be a member of TestUtil bec
| |
45 const base::Closure& task); | |
46 }; | |
13 | 47 |
14 } // namespace cronet | 48 } // namespace cronet |
15 | 49 |
16 #endif // COMPONENTS_CRONET_ANDROID_TEST_CRONET_TEST_UTIL_H_ | 50 #endif // COMPONENTS_CRONET_ANDROID_TEST_CRONET_TEST_UTIL_H_ |
OLD | NEW |