[M94 Migration] Fix AssertNoURLRequests crash issue 72/267372/1
authorGajendra N <gajendra.n@samsung.com>
Fri, 6 Nov 2020 10:56:42 +0000 (16:26 +0530)
committerGajendra N <gajendra.n@samsung.com>
Thu, 2 Dec 2021 08:57:30 +0000 (14:27 +0530)
This patch fixes the crash by AssertNoURLRequests().

Reference: https://review.tizen.org/gerrit/247190

Change-Id: Ibe1ab1c7b2360dd795211fe991cd6be2dd9f1409
Signed-off-by: Gajendra N <gajendra.n@samsung.com>
tizen_src/ewk/efl_integration/browser_context_efl.cc
tizen_src/ewk/efl_integration/url_request_context_getter_efl.cc
tizen_src/ewk/efl_integration/url_request_context_getter_efl.h

index cb767e5..ed97268 100644 (file)
@@ -59,14 +59,19 @@ BrowserContextEfl::~BrowserContextEfl() {
   autofill::PersonalDataManagerFactory::GetInstance()
       ->PersonalDataManagerRemove(this);
 #endif
-
-  if (resource_context_) {
-    resource_context_->set_url_request_context_getter(NULL);
+  ShutdownStoragePartitions();
+  if (resource_context_)
     BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, resource_context_);
-  }
 }
 
-BrowserContextEfl::ResourceContextEfl::~ResourceContextEfl() {}
+BrowserContextEfl::ResourceContextEfl::~ResourceContextEfl() {
+  // |cookie_manager_| has access to
+  // |URLRequestContextGetterEfl::GetURLRequestContext()|. So it should be
+  // released before NotifyContextShuttingDown()
+  cookie_manager_ = nullptr;
+  if (getter_.get())
+    getter_->NotifyContextShuttingDown();
+}
 
 bool BrowserContextEfl::ResourceContextEfl::HTTPCustomHeaderAdd(
     const std::string& name,
index e769f59..437244b 100644 (file)
@@ -62,11 +62,24 @@ URLRequestContextGetterEfl::URLRequestContextGetterEfl(
           io_task_runner);
 }
 
-URLRequestContextGetterEfl::~URLRequestContextGetterEfl() {}
+URLRequestContextGetterEfl::~URLRequestContextGetterEfl() {
+  // NotifyContextShuttingDown() must have been called.
+  DCHECK_CURRENTLY_ON(BrowserThread::IO);
+  DCHECK(shut_down_);
+}
+
+void URLRequestContextGetterEfl::NotifyContextShuttingDown() {
+  DCHECK_CURRENTLY_ON(BrowserThread::IO);
+  shut_down_ = true;
+  URLRequestContextGetter::NotifyContextShuttingDown();
+}
 
 net::URLRequestContext* URLRequestContextGetterEfl::GetURLRequestContext() {
   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
 
+  if (shut_down_)
+    return nullptr;
+
   if (!url_request_context_) {
     const base::CommandLine& command_line =
         *base::CommandLine::ForCurrentProcess();
index 86c2a27..97464f4 100644 (file)
@@ -53,6 +53,8 @@ class URLRequestContextGetterEfl : public net::URLRequestContextGetter {
     return weak_ptr_factory_.GetWeakPtr();
   }
 
+  void NotifyContextShuttingDown();
+
  protected:
   virtual ~URLRequestContextGetterEfl();
 
@@ -66,6 +68,7 @@ class URLRequestContextGetterEfl : public net::URLRequestContextGetter {
 
   bool ignore_certificate_errors_;
   base::FilePath base_path_;
+  bool shut_down_ = false;
   const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner_;
   const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner_;
   net::NetLog* net_log_;