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

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

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 | « no previous file | Source/modules/notifications/Notification.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/notifications/Notification.h
diff --git a/Source/modules/notifications/Notification.h b/Source/modules/notifications/Notification.h
index ef50d83910a20677612ccfdb64cb926ae896e205..31ad6f36d06ebbad7a99b9c42318a39fb42ca587 100644
--- a/Source/modules/notifications/Notification.h
+++ b/Source/modules/notifications/Notification.h
@@ -71,6 +71,11 @@ public:
virtual ~Notification();
+ // Calling show() may start asynchronous operation. If this object has
+ // a V8 wrapper, hasPendingActivity() prevents the wrapper from being
+ // collected while m_state is Showing, and so this instance stays alive
+ // until the operation completes. Otherwise, you need to hold a ref on this
+ // instance until the operation completes.
void show();
#if ENABLE(LEGACY_NOTIFICATIONS)
void cancel() { close(); }
@@ -116,6 +121,8 @@ public:
virtual bool dispatchEvent(PassRefPtr<Event>) OVERRIDE;
// ActiveDOMObject interface
+ // Override to prevent this from being collected when in Showing state.
+ virtual bool hasPendingActivity() const OVERRIDE;
virtual void stop() OVERRIDE;
static const String& permission(ExecutionContext*);
@@ -128,8 +135,6 @@ private:
#endif
Notification(ExecutionContext*, const String& title);
- void finalize();
-
void setLang(const String& lang) { m_lang = lang; }
void setBody(const String& body) { m_body = body; }
void setIcon(const KURL& url) { m_icon = url; }
« no previous file with comments | « no previous file | Source/modules/notifications/Notification.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698