Bug 1878930 - s/RawBuffer/Span/: TexImage: GetRangeFromData. r=gfx-reviewers,lsalzman
[gecko.git] / netwerk / ipc / ProxyAutoConfigChild.h
blob19d757d6469c113db88fab0151a09913eeb0fd60
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef ProxyAutoConfigChild_h__
7 #define ProxyAutoConfigChild_h__
9 #include "mozilla/LinkedList.h"
10 #include "mozilla/net/PProxyAutoConfigChild.h"
11 #include "mozilla/StaticPtr.h"
12 #include "mozilla/UniquePtr.h"
14 namespace mozilla {
15 namespace net {
17 class ProxyAutoConfig;
19 class ProxyAutoConfigChild final : public PProxyAutoConfigChild {
20 public:
21 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ProxyAutoConfigChild, final)
23 static bool Create(Endpoint<PProxyAutoConfigChild>&& aEndpoint);
24 static bool CreatePACThread();
25 static void ShutdownPACThread();
27 ProxyAutoConfigChild();
29 void ActorDestroy(ActorDestroyReason aWhy) override;
30 mozilla::ipc::IPCResult RecvConfigurePAC(const nsACString& aPACURI,
31 const nsACString& aPACScriptData,
32 const bool& aIncludePath,
33 const uint32_t& aExtraHeapSize);
34 mozilla::ipc::IPCResult RecvGetProxyForURI(
35 const nsACString& aTestURI, const nsACString& aTestHost,
36 GetProxyForURIResolver&& aResolver);
38 void Destroy();
40 private:
41 virtual ~ProxyAutoConfigChild();
42 void ProcessPendingQ();
43 bool ProcessPending();
44 static void BindProxyAutoConfigChild(
45 RefPtr<ProxyAutoConfigChild>&& aActor,
46 Endpoint<PProxyAutoConfigChild>&& aEndpoint);
48 UniquePtr<ProxyAutoConfig> mPAC;
49 bool mInProgress{false};
50 bool mPACLoaded{false};
51 bool mShutdown{false};
53 class PendingQuery final : public LinkedListElement<RefPtr<PendingQuery>> {
54 public:
55 NS_INLINE_DECL_REFCOUNTING(PendingQuery)
57 explicit PendingQuery(const nsACString& aTestURI,
58 const nsACString& aTestHost,
59 GetProxyForURIResolver&& aResolver)
60 : mURI(aTestURI), mHost(aTestHost), mResolver(std::move(aResolver)) {}
62 void Resolve(nsresult aStatus, const nsACString& aResult);
63 const nsCString& URI() const { return mURI; }
64 const nsCString& Host() const { return mHost; }
66 private:
67 ~PendingQuery() = default;
69 nsCString mURI;
70 nsCString mHost;
71 GetProxyForURIResolver mResolver;
74 LinkedList<RefPtr<PendingQuery>> mPendingQ;
76 static StaticRefPtr<nsIThread> sPACThread;
77 static bool sShutdownObserverRegistered;
78 static Atomic<uint32_t> sLiveActorCount;
81 } // namespace net
82 } // namespace mozilla
84 #endif // ProxyAutoConfigChild_h__