[M108 Migration][API] Implement ewk_view_session_timeout_set internal API 57/287657/3
authorayush.k123 <ayush.k123@samsung.com>
Wed, 1 Feb 2023 10:31:49 +0000 (16:01 +0530)
committerAyush Kumar <ayush.k123@samsung.com>
Thu, 2 Feb 2023 06:16:29 +0000 (11:46 +0530)
XHR request can specify a timeout value which will be used to break a
connection after some time. Default value is 0 which means that no
limit is set. Additionally, a new API is defined to set a maximum timeout
value (0 is default). Using this API one can set a maximum timeout value
which will be used during XHR request - the request will not take longer
time that specified value.

Based on the upstream changes in threadable_loader.h, consequent changes have
been made in this patch to enable timeout.

References: https://review.tizen.org/gerrit/279488/

Change-Id: I50efed39e4403b45a80aca44f57b83195187a910
Signed-off-by: ayush.k123 <ayush.k123@samsung.com>
17 files changed:
content/browser/renderer_host/render_widget_host_impl.cc
content/browser/renderer_host/render_widget_host_impl.h
third_party/blink/public/mojom/widget/platform_widget.mojom
third_party/blink/public/web/web_view.h
third_party/blink/renderer/core/exported/web_view_impl.cc
third_party/blink/renderer/core/exported/web_view_impl.h
third_party/blink/renderer/core/frame/web_frame_widget_impl.cc
third_party/blink/renderer/core/frame/web_frame_widget_impl.h
third_party/blink/renderer/core/page/page.cc
third_party/blink/renderer/core/page/page.h
third_party/blink/renderer/core/xmlhttprequest/xml_http_request.cc
third_party/blink/renderer/platform/widget/widget_base.cc
third_party/blink/renderer/platform/widget/widget_base.h
third_party/blink/renderer/platform/widget/widget_base_client.h
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/eweb_view.h
tizen_src/ewk/efl_integration/public/ewk_view.cc

index bb004e7..4270ae9 100644 (file)
@@ -1000,6 +1000,10 @@ void RenderWidgetHostImpl::OnGetFocusedNodeBounds(const gfx::RectF& rect) {
     return;
   view_->OnGetFocusedNodeBounds(rect);
 }
+
+void RenderWidgetHostImpl::SetLongPollingGlobalTimeout(uint64_t timeout) {
+  blink_widget_->SetLongPollingGlobalTimeout(timeout);
+}
 #endif
 
 blink::VisualProperties RenderWidgetHostImpl::GetInitialVisualProperties() {
index 9e17ce7..5ac08aa 100644 (file)
@@ -446,6 +446,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl
   void OnGetContentSnapshot(int request_id, const SkBitmap& bitmap);
   void UpdateFocusedNodeBounds();
   void OnGetFocusedNodeBounds(const gfx::RectF& rect);
+  void SetLongPollingGlobalTimeout(uint64_t timeout);
 #endif
 
   // Returns true if the RenderWidget is hidden.
index 428275c..1c524bd 100644 (file)
@@ -117,6 +117,9 @@ interface Widget {
   [EnableIf=is_efl]
   UpdateFocusedNodeBounds() => (gfx.mojom.RectF rect);
 
+  [EnableIf=is_efl]
+  SetLongPollingGlobalTimeout(uint64 timeout);
+
   // Informs the widget that it was hidden. This allows it to reduce its
   // resource utilization, and will cancel any pending
   // RecordContentToVisibleTimeRequest that was set with WasShown or
index 454da39..e07d0eb 100644 (file)
@@ -479,6 +479,7 @@ class BLINK_EXPORT WebView {
   // onto the specified canvas, when the page is not having any 3D content.
   virtual bool PaintSoftBitmap(SkCanvas*, const gfx::Rect&) = 0;
   virtual bool HasAcceleratedCanvasWithinViewport() const = 0;
+  virtual void SetLongPollingGlobalTimeout(uint64_t timeout) = 0;
 #endif
 
  protected:
index 00f7e7f..4a19946 100644 (file)
@@ -3992,6 +3992,12 @@ bool WebViewImpl::HasAcceleratedCanvasWithinViewport() const {
   }
   return false;
 }
+
+void WebViewImpl::SetLongPollingGlobalTimeout(uint64_t timeout) {
+  if (!GetPage())
+    return;
+  GetPage()->SetLongPollingGlobalTimeout(timeout);
+}
 #endif
 
 }  // namespace blink
index ebf4292..9e84b09 100644 (file)
@@ -225,6 +225,7 @@ class CORE_EXPORT WebViewImpl final : public WebView,
 #if BUILDFLAG(IS_EFL)
   bool PaintSoftBitmap(SkCanvas*, const gfx::Rect&) override;
   bool HasAcceleratedCanvasWithinViewport() const override;
+  void SetLongPollingGlobalTimeout(uint64_t timeout) override;
 #endif
 
   // Functions to add and remove observers for this object.
index 9737478..f7570da 100644 (file)
@@ -4168,6 +4168,12 @@ gfx::RectF WebFrameWidgetImpl::UpdateFocusedNodeBounds() {
   }
   return gfx::RectF();
 }
+
+void WebFrameWidgetImpl::SetLongPollingGlobalTimeout(uint64_t timeout) {
+  WebView* view = View();
+  if (view)
+    view->SetLongPollingGlobalTimeout(timeout);
+}
 #endif
 
 void WebFrameWidgetImpl::OrientationChanged() {
index cffaa63..be71baa 100644 (file)
@@ -708,6 +708,7 @@ class CORE_EXPORT WebFrameWidgetImpl
                           SkBitmap* snapshot) override;
 
   gfx::RectF UpdateFocusedNodeBounds() override;
+  void SetLongPollingGlobalTimeout(uint64_t timeout) override;
 #endif
   void OrientationChanged() override;
   void DidUpdateSurfaceAndScreen(
index 4e729cd..28e6d7a 100644 (file)
@@ -1154,6 +1154,12 @@ void Page::UpdateLifecycle(LocalFrame& root,
   }
 }
 
+#if BUILDFLAG(IS_EFL)
+void Page::SetLongPollingGlobalTimeout(uint64_t timeout) {
+  long_polling_global_timeout_ = timeout;
+}
+#endif
+
 template class CORE_TEMPLATE_EXPORT Supplement<Page>;
 
 const char InternalSettingsPageSupplementBase::kSupplementName[] =
index f5cc0f4..3d0597b 100644 (file)
@@ -337,6 +337,13 @@ class CORE_EXPORT Page final : public GarbageCollected<Page>,
   void OnSetPageFrozen(bool is_frozen) override;
   bool LocalMainFrameNetworkIsAlmostIdle() const override;
 
+#if BUILDFLAG(IS_EFL)
+  void SetLongPollingGlobalTimeout(uint64_t timeout);
+  uint64_t GetLongPollingGlobalTimeout() {
+    return long_polling_global_timeout_;
+  }
+#endif
+
   void AddAutoplayFlags(int32_t flags);
   void ClearAutoplayFlags();
 
@@ -548,6 +555,9 @@ class CORE_EXPORT Page final : public GarbageCollected<Page>,
   mojom::blink::TextAutosizerPageInfo web_text_autosizer_page_info_;
 
   WebScopedVirtualTimePauser history_navigation_virtual_time_pauser_;
+#if BUILDFLAG(IS_EFL)
+  uint64_t long_polling_global_timeout_ = 0;
+#endif // IS_EFL
 };
 
 extern template class CORE_EXTERN_TEMPLATE_EXPORT Supplement<Page>;
index 6be9820..6185b12 100644 (file)
@@ -1143,7 +1143,26 @@ void XMLHttpRequest::CreateRequest(scoped_refptr<EncodedFormData> http_body,
 
   loader_ = MakeGarbageCollected<ThreadableLoader>(execution_context, this,
                                                    resource_loader_options);
+#if defined(USE_EFL)
+  uint64_t timeout_milliseconds_global = 0;
+  auto* document = To<LocalDOMWindow>(GetExecutionContext())->document();
+  if (execution_context.IsWindow() && document && document->GetPage()) {
+    timeout_milliseconds_global =
+        document->GetPage()->GetLongPollingGlobalTimeout() * 1000;
+  }
+
+  uint64_t timeout_to_set = timeout();
+  if (timeout_milliseconds_global > 0 &&
+      timeout_milliseconds_global < timeout_to_set) {
+    timeout_to_set = timeout_milliseconds_global;
+  }
+
+  uint64_t timeout =
+      (timeout_to_set == 0) ? timeout_milliseconds_global : timeout_to_set;
+  loader_->SetTimeout(base::Milliseconds(timeout));
+#else
   loader_->SetTimeout(timeout_);
+#endif
   base::TimeTicks start_time = base::TimeTicks::Now();
   loader_->Start(std::move(request));
 
index 59a7ed3..8eef0d5 100644 (file)
@@ -468,6 +468,10 @@ void WidgetBase::UpdateFocusedNodeBounds(
     UpdateFocusedNodeBoundsCallback callback) {
   std::move(callback).Run(client_->UpdateFocusedNodeBounds());
 }
+
+void WidgetBase::SetLongPollingGlobalTimeout(uint64_t timeout) {
+  client_->SetLongPollingGlobalTimeout(timeout);
+}
 #endif
 
 void WidgetBase::WasHidden() {
index e175340..0bee8c2 100644 (file)
@@ -143,6 +143,7 @@ class PLATFORM_EXPORT WidgetBase : public mojom::blink::Widget,
 
   void UpdateFocusedNodeBounds(
       UpdateFocusedNodeBoundsCallback callback) override;
+  void SetLongPollingGlobalTimeout(uint64_t timeout) override;
 #endif
   void WasHidden() override;
   void WasShown(bool was_evicted,
index 7fc0466..8e203a2 100644 (file)
@@ -175,6 +175,7 @@ class WidgetBaseClient {
                                   SkBitmap* snapshot) {}
 
   virtual gfx::RectF UpdateFocusedNodeBounds() { return gfx::RectF(); }
+  virtual void SetLongPollingGlobalTimeout(uint64_t timeout) {}
 #endif
 
   // Convert screen coordinates to device emulated coordinates (scaled
index 363fc93..a3f0cc3 100644 (file)
@@ -2592,6 +2592,11 @@ void EWebView::DidRespondRequestManifest(
   callback(evas_object_, manifest, user_data);
 }
 
+void EWebView::SetSessionTimeout(uint64_t timeout) {
+  if (web_contents_->GetPrimaryMainFrame()->IsRenderFrameLive() && rwhva())
+    rwhva()->host()->SetLongPollingGlobalTimeout(timeout);
+}
+
 void EWebView::SetExceededIndexedDatabaseQuotaCallback(
     Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback,
     void* user_data) {
index 111407f..f193ff5 100755 (executable)
@@ -247,6 +247,7 @@ class EWebView {
   void Suspend();
   void Resume();
   void Stop();
+  void SetSessionTimeout(uint64_t timeout);
   double GetTextZoomFactor() const;
   void SetTextZoomFactor(double text_zoom_factor);
   double GetPageZoomFactor() const;
index 8ee0632..b274520 100644 (file)
@@ -1143,7 +1143,8 @@ Eina_Bool ewk_view_page_close(Evas_Object* o)
 
 void ewk_view_session_timeout_set(Evas_Object* o, unsigned long timeout)
 {
-  LOG_EWK_API_MOCKUP();
+  EWK_VIEW_IMPL_GET_OR_RETURN(o, impl);
+  impl->SetSessionTimeout(timeout);
 }
 
 Evas_Object* ewk_view_widget_get(Evas_Object* view)