Index: components/cronet/android/chromium_url_request_context.cc |
diff --git a/components/cronet/android/chromium_url_request_context.cc b/components/cronet/android/chromium_url_request_context.cc |
index 3969ec0cfd99d48b7d797f780afad294b4db1e98..247077d3b36a57bbb54e0b951607b3ac0884322a 100644 |
--- a/components/cronet/android/chromium_url_request_context.cc |
+++ b/components/cronet/android/chromium_url_request_context.cc |
@@ -66,11 +66,24 @@ |
const JavaParamRef<jobject>& jcaller, |
const JavaParamRef<jstring>& juser_agent, |
jint jlog_level, |
- jlong jconfig) { |
+ const JavaParamRef<jstring>& jconfig) { |
std::string user_agent = ConvertJavaStringToUTF8(env, juser_agent); |
+ std::string config = ConvertJavaStringToUTF8(env, jconfig); |
+ |
+ scoped_ptr<base::Value> config_value = base::JSONReader::Read(config); |
+ if (!config_value || !config_value->IsType(base::Value::TYPE_DICTIONARY)) { |
+ DLOG(ERROR) << "Bad JSON: " << config; |
+ return 0; |
+ } |
+ |
scoped_ptr<URLRequestContextConfig> context_config( |
- reinterpret_cast<URLRequestContextConfig*>(jconfig)); |
+ new URLRequestContextConfig()); |
+ base::JSONValueConverter<URLRequestContextConfig> converter; |
+ if (!converter.Convert(*config_value, context_config.get())) { |
+ DLOG(ERROR) << "Bad Config: " << config_value; |
+ return 0; |
+ } |
// TODO(mef): MinLogLevel is global, shared by all URLRequestContexts. |
// Revisit this if each URLRequestContext would need an individual log level. |