fix: crash when resolving proxy due to network service restart (#42878)

This commit is contained in:
Robo 2024-07-15 17:46:24 +09:00 committed by GitHub
parent bbd7f4a5ad
commit 1e1dc22e16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 12 deletions

View file

@ -12,19 +12,20 @@
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "services/network/public/mojom/proxy_lookup_client.mojom.h"
#include "url/gurl.h"
namespace electron {
class ElectronBrowserContext;
class ResolveProxyHelper
: public base::RefCountedThreadSafe<ResolveProxyHelper>,
network::mojom::ProxyLookupClient {
public:
using ResolveProxyCallback = base::OnceCallback<void(std::string)>;
explicit ResolveProxyHelper(network::mojom::NetworkContext* network_context);
explicit ResolveProxyHelper(ElectronBrowserContext* browser_context);
void ResolveProxy(const GURL& url, ResolveProxyCallback callback);
@ -70,7 +71,7 @@ class ResolveProxyHelper
mojo::Receiver<network::mojom::ProxyLookupClient> receiver_{this};
// Weak Ref
raw_ptr<network::mojom::NetworkContext> network_context_ = nullptr;
raw_ptr<ElectronBrowserContext> browser_context_;
};
} // namespace electron