Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2421)

Unified Diff: Source/modules/notifications/Notification.cpp

Issue 73993003: Make Notification override hasPendingActivity() to prolong its lifetime while async op is running (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Call stop() Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/notifications/Notification.h ('k') | Source/platform/AsyncMethodRunner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/notifications/Notification.cpp
diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp
index c68f9cf47412d6d521b24590ee20cf47680830bb..f652d9af3cc4e3fc2cbcdad9c840d65606dd874c 100644
--- a/Source/modules/notifications/Notification.cpp
+++ b/Source/modules/notifications/Notification.cpp
@@ -147,7 +147,6 @@ void Notification::show()
}
if (m_notificationClient->show(this)) {
m_state = Showing;
- setPendingActivity(this);
}
}
}
@@ -165,34 +164,21 @@ void Notification::close()
}
}
+bool Notification::hasPendingActivity() const
+{
+ return m_state == Showing || (m_asyncRunner && m_asyncRunner->isActive());
+}
+
void Notification::stop()
{
if (m_notificationClient)
m_notificationClient->notificationObjectDestroyed(this);
m_notificationClient = 0;
- finalize();
-
- // Ensure m_notificationClient == 0 only when in Closed state.
- ASSERT(m_state == Closed);
-}
-
-void Notification::finalize()
-{
- if (m_state == Closed)
- return;
+ if (m_asyncRunner)
+ m_asyncRunner->stop();
- // To call unsetPendingActivity() at the end.
- NotificationState lastState = m_state;
m_state = Closed;
-
- // setPendingActivity() is called only when show() was successful, and only
- // in that case, m_state is set to Showing. So, if it's not Showing, do
- // nothing here.
- if (lastState != Showing)
- return;
-
- unsetPendingActivity(this);
}
void Notification::dispatchShowEvent()
@@ -213,7 +199,7 @@ void Notification::dispatchClickEvent()
void Notification::dispatchCloseEvent()
{
dispatchEvent(Event::create(EventTypeNames::close));
- finalize();
+ m_state = Closed;
}
void Notification::dispatchErrorEvent()
« no previous file with comments | « Source/modules/notifications/Notification.h ('k') | Source/platform/AsyncMethodRunner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698