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
3 // found in the LICENSE file.
5 #include "mock_url_request_job_factory.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h"
9 #include "jni/MockUrlRequestJobFactory_jni.h"
10 #include "net/test/url_request/url_request_failed_job.h"
11 #include "net/test/url_request/url_request_mock_data_job.h"
15 void AddUrlInterceptors(JNIEnv
* env
, jclass jcaller
) {
16 net::URLRequestMockDataJob::AddUrlHandler();
17 net::URLRequestFailedJob::AddUrlHandler();
20 jstring
GetMockUrlWithFailure(JNIEnv
* jenv
,
24 GURL
url(net::URLRequestFailedJob::GetMockHttpUrlWithFailurePhase(
25 static_cast<net::URLRequestFailedJob::FailurePhase
>(jphase
),
26 static_cast<int>(jnet_error
)));
27 return base::android::ConvertUTF8ToJavaString(jenv
, url
.spec()).Release();
30 jstring
GetMockUrlForData(JNIEnv
* jenv
,
33 jint jdata_repeat_count
) {
34 std::string
data(base::android::ConvertJavaStringToUTF8(jenv
, jdata
));
35 GURL
url(net::URLRequestMockDataJob::GetMockHttpUrl(data
,
37 return base::android::ConvertUTF8ToJavaString(jenv
, url
.spec()).Release();
40 bool RegisterMockUrlRequestJobFactory(JNIEnv
* env
) {
41 return RegisterNativesImpl(env
);