Implementation of Resume and Suspend function. 36/183836/5
authordeepti <d.saraswat@samsung.com>
Wed, 11 Jul 2018 10:39:49 +0000 (16:09 +0530)
committerjaekuk lee <juku1999@samsung.com>
Thu, 12 Jul 2018 00:19:56 +0000 (00:19 +0000)
Created IPC for Resume and Suspend operation to reach at Chromium level.

Change-Id: I2a38c77f225b102da14607b3a5dde787c78e697a
Signed-off-by: deepti <d.saraswat@samsung.com>
atom/browser/browser.cc
atom/common/api/api_messages.h
atom/renderer/atom_render_view_observer.cc
atom/renderer/atom_render_view_observer.h
tizen/browser/tizen_browser_parts.cc
tizen/browser/tizen_browser_parts.h

index dcfc6bc..0cd2e39 100644 (file)
@@ -18,6 +18,8 @@
 #include "base/threading/thread_task_runner_handle.h"
 #include "brightray/browser/brightray_paths.h"
 #include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/render_view_host.h"
+
 #if defined(OS_TIZEN)
 #include "tizen/common/command_line.h"
 #include "tizen/common/application_data.h"
@@ -264,14 +266,22 @@ void Browser::OnWindowAllClosed() {
 #if defined(OS_TIZEN)
 void Browser::Hide() {
   NativeWindow *last_window = WindowList::GetLastWindow();
-  if (last_window)
-    last_window->NotifySuspend();
+  if (!last_window)
+    return;
+
+  last_window->NotifySuspend();
+  auto rvh = last_window->web_contents()->GetRenderViewHost();
+  atom::Browser::Get()->Suspend(rvh);
 }
 
 void Browser::Show() {
   NativeWindow *last_window = WindowList::GetLastWindow();
-  if (last_window)
-    last_window->NotifyResume();
+  if (!last_window)
+    return;
+
+  last_window->NotifyResume();
+  auto rvh = last_window->web_contents()->GetRenderViewHost();
+  atom::Browser::Get()->Resume(rvh);
 }
 
 void Browser::AppControl(std::unique_ptr<common::AppControl> appcontrol) {
index 44e8ad6..8335a4e 100644 (file)
@@ -71,4 +71,9 @@ IPC_SYNC_MESSAGE_ROUTED0_2(WrtViewMsg_GetCSP,
                            std::string)
 
 IPC_MESSAGE_ROUTED1(WrtViewMsg_SetLongPolling,
-                    unsigned long)
\ No newline at end of file
+                    unsigned long)
+
+IPC_MESSAGE_ROUTED0(WrtViewMsg_SuspendScheduledTask)
+IPC_MESSAGE_ROUTED0(WrtViewMsg_ResumeScheduledTasks)
+
+
index 8923fdf..a608567 100644 (file)
@@ -139,12 +139,32 @@ bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
   IPC_BEGIN_MESSAGE_MAP(AtomRenderViewObserver, message)
     IPC_MESSAGE_HANDLER(AtomViewMsg_Message, OnBrowserMessage)
     IPC_MESSAGE_HANDLER(WrtViewMsg_SetLongPolling, OnSetLongPolling)
+    IPC_MESSAGE_HANDLER(WrtViewMsg_SuspendScheduledTask, OnSuspendScheduledTasks)
+    IPC_MESSAGE_HANDLER(WrtViewMsg_ResumeScheduledTasks, OnResumeScheduledTasks)
     IPC_MESSAGE_UNHANDLED(handled = false)
   IPC_END_MESSAGE_MAP()
 
   return handled;
 }
 
+void AtomRenderViewObserver::OnSuspendScheduledTasks() {
+  if (!document_created_)
+    return;
+
+  blink::WebView* view = render_view()->GetWebView();
+  if (view)
+    view->suspendScheduledTasks();
+}
+
+void AtomRenderViewObserver::OnResumeScheduledTasks() {
+  if (!document_created_)
+    return;
+
+  blink::WebView* view = render_view()->GetWebView();
+  if (view)
+    view->resumeScheduledTasks();
+}
+
 void AtomRenderViewObserver::OnDestruct() {
   delete this;
 }
index cd69e2a..00cfb3b 100644 (file)
@@ -21,7 +21,8 @@ class AtomRenderViewObserver : public content::RenderViewObserver {
  public:
   explicit AtomRenderViewObserver(content::RenderView* render_view,
                                   AtomRendererClient* renderer_client);
-
+  void OnSuspendScheduledTasks();
+  void OnResumeScheduledTasks();
  protected:
   virtual ~AtomRenderViewObserver();
 
index d037cfc..10dd2f6 100644 (file)
@@ -73,4 +73,18 @@ void TizenBrowserParts::RenderViewCreated(content::RenderViewHost* render_view_h
   SetLongPollingTimeout(render_view_host);
 }
 
-}
\ No newline at end of file
+void TizenBrowserParts::Suspend(content::RenderViewHost* rvh) {
+  if(!rvh)
+    return;
+
+  rvh->Send(new WrtViewMsg_SuspendScheduledTask(rvh->GetRoutingID()));
+}
+
+void TizenBrowserParts::Resume(content::RenderViewHost* rvh) {
+  if(!rvh)
+    return;
+
+  rvh->Send(new WrtViewMsg_ResumeScheduledTasks(rvh->GetRoutingID()));
+}
+
+}
index 4f6d552..a280f2f 100644 (file)
@@ -32,6 +32,8 @@ class TizenBrowserParts {
   virtual void Launch(std::unique_ptr<common::AppControl> appcontrol) = 0;
   virtual bool launched() const = 0;
   void RenderViewCreated(content::RenderViewHost* render_view_host);
+  void Suspend(content::RenderViewHost* rvh);
+  void Resume(content::RenderViewHost* rvh);
   void GetCSP(std::string &csp_rule, std::string &csp_report_rule);
   void Initialize();
 
@@ -51,4 +53,4 @@ class TizenBrowserParts {
 
 } // namespace tizen
 
-#endif  // TIZEN_BROWSER_TIZEN_BROWSER_PARTS_H_
\ No newline at end of file
+#endif  // TIZEN_BROWSER_TIZEN_BROWSER_PARTS_H_