blob: 64f16ca05e64890f469cee0455196f1e12433684 [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ANDROID_WEBVIEW_BROWSER_AW_PAC_PROCESSOR_H_
#define ANDROID_WEBVIEW_BROWSER_AW_PAC_PROCESSOR_H_
#include "base/android/scoped_java_ref.h"
#include "base/no_destructor.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread.h"
#include "net/log/net_log_with_source.h"
#include "services/proxy_resolver/proxy_host_resolver.h"
#include "services/proxy_resolver/proxy_resolver_v8_tracing.h"
namespace android_webview {
class AwPacProcessor {
public:
AwPacProcessor();
AwPacProcessor(const AwPacProcessor&) = delete;
AwPacProcessor& operator=(const AwPacProcessor&) = delete;
jboolean SetProxyScript(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
const base::android::JavaParamRef<jstring>& jscript);
bool SetProxyScript(std::string script);
base::android::ScopedJavaLocalRef<jstring> MakeProxyRequest(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
const base::android::JavaParamRef<jstring>& jurl);
std::string MakeProxyRequest(std::string url);
proxy_resolver::ProxyHostResolver* host_resolver() {
return host_resolver_.get();
}
private:
~AwPacProcessor();
void SetProxyScriptNative(
std::unique_ptr<net::ProxyResolverFactory::Request>* request,
const std::string& script,
net::CompletionOnceCallback complete);
void MakeProxyRequestNative(
std::unique_ptr<net::ProxyResolver::Request>* request,
const std::string& url,
net::ProxyInfo* proxy_info,
net::CompletionOnceCallback complete);
std::unique_ptr<proxy_resolver::ProxyResolverV8TracingFactory>
proxy_resolver_factory_;
std::unique_ptr<proxy_resolver::ProxyResolverV8Tracing> proxy_resolver_;
std::unique_ptr<proxy_resolver::ProxyHostResolver> host_resolver_;
friend class Job;
friend class SetProxyScriptJob;
friend class MakeProxyRequestJob;
};
} // namespace android_webview
#endif // ANDROID_WEBVIEW_BROWSER_AW_PAC_PROCESSOR_H_