Fix not web liveboxes of other tabs to be rendered when web-provider goes to foreground
authorYunchan Cho <yunchan.cho@samsung.com>
Tue, 30 Apr 2013 14:58:01 +0000 (23:58 +0900)
committerGerrit Code Review <gerrit2@kim11>
Wed, 1 May 2013 02:46:58 +0000 (11:46 +0900)
[Issue#] N/A
[Problem] web-provider is crashed sometimes when some liveboxes are rendered on other pages
[Cause] web-provider are missing regarding some scenario of entering background and foreground
[Solution] web-provider does not render web liveboxes of other tabs when web-provider goes to foreground

Change-Id: Ie104f85d591ef900f590adc411ac04e40722c90c

src/Core/Box.cpp
src/Core/Box.h
src/Core/BoxManager.cpp
src/Core/IBox.h

index 190a903..2e51dab 100644 (file)
@@ -39,6 +39,7 @@ static const std::string renderTypeUpdate("update");
 Box::Box(BoxInfoPtr boxInfo, IBoxPluginFactoryPtr factory, EwkContextPtr ewkContext)
     : m_boxInfo(boxInfo)
     , m_factory(factory)
+    , m_currentTab(true)
 {
     LogD("enter");
     try {
@@ -138,6 +139,7 @@ bool Box::resume()
     CHECK_BOX_STATE(m_state, permitResume);
 
     try {
+        m_currentTab = true;
         m_updateTimer->start();
         m_view->resumeBox();
     } catch (...) {
@@ -148,12 +150,15 @@ bool Box::resume()
     return true;
 }
 
-bool Box::pause()
+bool Box::pause(bool background)
 {
     LogD("enter");
     CHECK_BOX_STATE(m_state, permitPause);
 
     try {
+        if (!background) {
+            m_currentTab = false;
+        }
         m_updateTimer->stop();
         m_view->pauseBox();
     } catch (...) {
@@ -214,6 +219,9 @@ bool Box::update()
 {
     LogD("enter");
 
+    if (!m_currentTab) {
+        return false;
+    }
     // reload box
     m_boxBuffer->startCanvasUpdate();
     RenderInfoPtr renderInfo = makeRenderInfo(renderTypeUpdate);
@@ -233,6 +241,11 @@ bool Box::changePeriod(float period)
     return true;
 }
 
+bool Box::isCurrentTab()
+{
+    return m_currentTab;
+}
+
 RenderInfoPtr Box::makeRenderInfo(const std::string& renderType) const
 {
     LogD("enter");
index 12e1418..0ab2f18 100644 (file)
@@ -46,11 +46,12 @@ class Box: public IBox, public IBoxContext {
         bool hide();
         bool resize(int width, int height);
         bool resume();
-        bool pause();
+        bool pause(bool background);
         bool openPd(int width, int height, double x, double y);
         bool closePd();
         bool update();
         bool changePeriod(float period);
+        bool isCurrentTab();
         ~Box();
 
     private:
@@ -74,6 +75,7 @@ class Box: public IBox, public IBoxContext {
         IRenderBufferPtr m_pdBuffer;
         IRenderViewPtr m_view;
         ITimerPtr m_updateTimer;
+        bool m_currentTab;
         //IBoxStatePtr m_state;
 
         friend class BoxSchemeHandler;
index fe4256a..28efcca 100644 (file)
@@ -159,14 +159,17 @@ bool BoxManager::requestPauseBox(std::string& instanceId)
         return false;
     }
     
-    return box->pause();
+    // paused by switching other page
+    return box->pause(false);
 }
 
 bool BoxManager::requestResumeAll()
 {
     LogD("enter");
     for (auto it = m_boxMap.begin(); it != m_boxMap.end(); it++) {
-        it->second->resume();
+        if (it->second->isCurrentTab()) {
+            it->second->resume();
+        }
     }
 
     return true;
@@ -176,7 +179,10 @@ bool BoxManager::requestPauseAll()
 {
     LogD("enter");
     for (auto it = m_boxMap.begin(); it != m_boxMap.end(); it++) {
-        it->second->pause();
+        if (it->second->isCurrentTab()) {
+            // paused by entering background
+            it->second->pause(true);
+        }
     }
 
     return true;
index 5feee10..4452f9d 100644 (file)
@@ -30,13 +30,12 @@ class IBox {
         virtual bool hide() = 0;
         virtual bool resize(int width, int height) = 0;
         virtual bool resume() = 0;
-        virtual bool pause() = 0;
+        virtual bool pause(bool background) = 0;
         virtual bool openPd(int width, int height, double x, double y) = 0;
         virtual bool closePd() = 0;
         virtual bool update() = 0;
-
-        // functions for specific service
         virtual bool changePeriod(float period) = 0;
+        virtual bool isCurrentTab() = 0;
 
         //virtual IBox& operator=(const IBox& rhs) = 0;
         //virtual bool operator==(const IBox& rhs) const = 0;