aw_pac_processor.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2019 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.
  4. #ifndef ANDROID_WEBVIEW_BROWSER_AW_PAC_PROCESSOR_H_
  5. #define ANDROID_WEBVIEW_BROWSER_AW_PAC_PROCESSOR_H_
  6. #include <android/multinetwork.h>
  7. #include "base/android/scoped_java_ref.h"
  8. #include "base/task/single_thread_task_runner.h"
  9. #include "base/threading/thread.h"
  10. #include "net/log/net_log_with_source.h"
  11. #include "services/proxy_resolver/proxy_host_resolver.h"
  12. #include "services/proxy_resolver/proxy_resolver_v8_tracing.h"
  13. namespace android_webview {
  14. class Job;
  15. class HostResolver;
  16. class AwPacProcessor {
  17. public:
  18. AwPacProcessor();
  19. AwPacProcessor(const AwPacProcessor&) = delete;
  20. AwPacProcessor& operator=(const AwPacProcessor&) = delete;
  21. ~AwPacProcessor();
  22. void DestroyNative(JNIEnv* env,
  23. const base::android::JavaParamRef<jobject>& obj);
  24. jboolean SetProxyScript(JNIEnv* env,
  25. const base::android::JavaParamRef<jobject>& obj,
  26. const base::android::JavaParamRef<jstring>& jscript);
  27. bool SetProxyScript(std::string script);
  28. base::android::ScopedJavaLocalRef<jstring> MakeProxyRequest(
  29. JNIEnv* env,
  30. const base::android::JavaParamRef<jobject>& obj,
  31. const base::android::JavaParamRef<jstring>& jurl);
  32. bool MakeProxyRequest(std::string url, std::string* result);
  33. void SetNetworkAndLinkAddresses(
  34. JNIEnv* env,
  35. net_handle_t net_handle,
  36. const base::android::JavaParamRef<jobjectArray>& addresses);
  37. private:
  38. void Destroy(base::WaitableEvent* event);
  39. void SetProxyScriptNative(
  40. std::unique_ptr<net::ProxyResolverFactory::Request>* request,
  41. const std::string& script,
  42. net::CompletionOnceCallback complete);
  43. void MakeProxyRequestNative(
  44. std::unique_ptr<net::ProxyResolver::Request>* request,
  45. const std::string& url,
  46. net::ProxyInfo* proxy_info,
  47. net::CompletionOnceCallback complete);
  48. friend class Job;
  49. friend class SetProxyScriptJob;
  50. friend class MakeProxyRequestJob;
  51. std::unique_ptr<proxy_resolver::ProxyResolverV8Tracing> proxy_resolver_;
  52. std::unique_ptr<HostResolver> host_resolver_;
  53. std::set<Job*> jobs_;
  54. };
  55. } // namespace android_webview
  56. #endif // ANDROID_WEBVIEW_BROWSER_AW_PAC_PROCESSOR_H_