SharedPtr<WebRequest> Web::MakeWebRequest(const String& verb, const String& url, double requestContentSize) { PROFILE(MakeWebRequest); // The initialization of the request will take time, can not know at this point if it has an error or not SharedPtr<WebRequest> webRequest(new WebRequest(context_, verb, url, requestContentSize)); #ifndef EMSCRIPTEN webRequest->setup(&d->service, d->curlm); #endif return webRequest; }
static void JNICALL JniSetDefaultWebRequest(JNIEnv* env, jclass clazz, jlong ptr) { AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr>(ptr); try { AdblockPlus::WebRequestPtr webRequest(new AdblockPlus::DefaultWebRequest()); engine->SetWebRequest(webRequest); } CATCH_AND_THROW(env) }
TEST(NewJsEngineTest, CallbackGetSet) { AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New()); ASSERT_TRUE(jsEngine->GetLogSystem()); ASSERT_ANY_THROW(jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr())); AdblockPlus::LogSystemPtr logSystem(new AdblockPlus::DefaultLogSystem()); jsEngine->SetLogSystem(logSystem); ASSERT_EQ(logSystem, jsEngine->GetLogSystem()); ASSERT_TRUE(jsEngine->GetFileSystem()); ASSERT_ANY_THROW(jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr())); AdblockPlus::FileSystemPtr fileSystem(new AdblockPlus::DefaultFileSystem()); jsEngine->SetFileSystem(fileSystem); ASSERT_EQ(fileSystem, jsEngine->GetFileSystem()); ASSERT_TRUE(jsEngine->GetWebRequest()); ASSERT_ANY_THROW(jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr())); AdblockPlus::WebRequestPtr webRequest(new AdblockPlus::DefaultWebRequest()); jsEngine->SetWebRequest(webRequest); ASSERT_EQ(webRequest, jsEngine->GetWebRequest()); }