[M130] Fixing geolocation crash 68/319668/8
authorAvinash Bhojwani <avinash.b@samsung.com>
Fri, 14 Feb 2025 11:07:44 +0000 (16:37 +0530)
committerAvinash Bhojwani <avinash.b@samsung.com>
Tue, 25 Feb 2025 00:01:13 +0000 (00:01 +0000)
This commit fixes the crash that was being observed
while running geolocation WebTCTs. network_context_
was not initialized and GetContext was returning NULL.

Change-Id: I6f4b91054d4346ae6d112f59f132ada100aac389
Signed-off-by: Avinash Bhojwani <avinash.b@samsung.com>
tizen_src/ewk/efl_integration/shared_url_loader_factory_efl.cc
tizen_src/ewk/efl_integration/shared_url_loader_factory_efl.h

index ab9e2a8a0e235be882b495a8896629e78ee55f1b..f1c5b9c150c68302e0aeefe65e63b99cd7fc9ad5 100644 (file)
@@ -6,14 +6,24 @@
 #include "shared_url_loader_factory_efl.h"
 
 #include "content/public/browser/browser_thread.h"
+#include "content/public/browser/network_context_client_base.h"
 #include "content/public/browser/network_service_instance.h"
+#include "mojo/public/cpp/bindings/pending_receiver.h"
+#include "mojo/public/cpp/bindings/pending_remote.h"
+#include "mojo/public/cpp/bindings/remote.h"
+#include "mojo/public/cpp/bindings/self_owned_receiver.h"
+#include "services/cert_verifier/public/mojom/cert_verifier_service_factory.mojom.h"
 #include "services/network/public/cpp/cross_thread_pending_shared_url_loader_factory.h"
 
 namespace content {
 
 /* LCOV_EXCL_START */
 network::mojom::NetworkContextParamsPtr CreateNetworkContextParams() {
-  return network::mojom::NetworkContextParams::New();
+  auto context_params = network::mojom::NetworkContextParams::New();
+  context_params->file_paths = network::mojom::NetworkContextFilePaths::New();
+  context_params->cert_verifier_params = GetCertVerifierParams(
+      cert_verifier::mojom::CertVerifierCreationParams::New());
+  return context_params;
 }
 
 void SharedURLLoaderFactoryEfl::CreateLoaderAndStart(
@@ -42,18 +52,22 @@ SharedURLLoaderFactoryEfl::Clone() {
 }
 
 network::mojom::NetworkContext* SharedURLLoaderFactoryEfl::GetContext() {
-  if (!network_service_network_context_ ||
-      !network_service_network_context_.is_connected()) {
-    // This should call into OnNetworkServiceCreated(), which will re-create
-    // the network service, if needed. There's a chance that it won't be
-    // invoked, if the NetworkContext has encountered an error but the
-    // NetworkService has not yet noticed its pipe was closed. In that case,
-    // trying to create a new NetworkContext would fail, anyways, and hopefully
-    // a new NetworkContext will be created on the next GetContext() call.
-    content::GetNetworkService();
-    DCHECK(network_service_network_context_);
+  DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+  if (!network_context_ || !network_context_.is_connected()) {
+    network_context_.reset();
+
+    content::CreateNetworkContextInNetworkService(
+        network_context_.BindNewPipeAndPassReceiver(),
+        CreateNetworkContextParams());
+
+    mojo::PendingRemote<network::mojom::NetworkContextClient> client_remote;
+    mojo::MakeSelfOwnedReceiver(
+        std::make_unique<content::NetworkContextClientBase>(),
+        client_remote.InitWithNewPipeAndPassReceiver());
+    network_context_->SetClient(std::move(client_remote));
   }
-  return network_service_network_context_.get();
+
+  return network_context_.get();
 }
 
 network::mojom::URLLoaderFactory*
index 2190f687907242cf61c903f36ca87a6be6a1e163..a117df240c7451d59bc75456e706c703ad07a17b 100644 (file)
@@ -17,12 +17,11 @@ class PendingSharedURLLoaderFactory;
 namespace content {
 
 /* LCOV_EXCL_START */
-// SharedURLLoaderFactory its network context. Transparently handles crashes.
 class SharedURLLoaderFactoryEfl : public network::SharedURLLoaderFactory {
  public:
-  SharedURLLoaderFactoryEfl() {}
+  SharedURLLoaderFactoryEfl() = default;
 
-  // network::mojom::URLLoaderFactory implementation
+  // network::URLLoaderFactory implementation:
   void CreateLoaderAndStart(mojo::PendingReceiver<network::mojom::URLLoader> receiver,
                             int32_t request_id,
                             uint32_t options,
@@ -32,7 +31,7 @@ class SharedURLLoaderFactoryEfl : public network::SharedURLLoaderFactory {
                                 traffic_annotation) override;
   void Clone(mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver) override;
 
-  // network::SharedURLLoaderFactory implementation
+  // network::SharedURLLoaderFactory implementation:
   std::unique_ptr<network::PendingSharedURLLoaderFactory> Clone() override;
 
   // Returns the System NetworkContext. May only be called after SetUp(). Does
@@ -56,7 +55,7 @@ class SharedURLLoaderFactoryEfl : public network::SharedURLLoaderFactory {
 
   // NetworkContext using the network service, if the network service is
   // enabled. mojo::NullRemote(), otherwise.
-  mojo::Remote<network::mojom::NetworkContext> network_service_network_context_;
+  mojo::Remote<network::mojom::NetworkContext> network_context_;
 
   mojo::Remote<network::mojom::URLLoaderFactory> url_loader_factory_;
 };