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

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

Issue 1847863002: Move notification resource loading from content/child to blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address peter's comments. Created 4 years, 8 months 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
Index: third_party/WebKit/Source/modules/notifications/Notification.cpp
diff --git a/third_party/WebKit/Source/modules/notifications/Notification.cpp b/third_party/WebKit/Source/modules/notifications/Notification.cpp
index 571912ded3ddb32035f64812da5fa4061b0fe21e..2179de0ac991c82fb271161206d2c4d1a8aadec6 100644
--- a/third_party/WebKit/Source/modules/notifications/Notification.cpp
+++ b/third_party/WebKit/Source/modules/notifications/Notification.cpp
@@ -43,6 +43,7 @@
#include "modules/notifications/NotificationData.h"
#include "modules/notifications/NotificationOptions.h"
#include "modules/notifications/NotificationPermissionClient.h"
+#include "modules/notifications/NotificationResourcesLoader.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/UserGestureIndicator.h"
#include "public/platform/Platform.h"
@@ -50,6 +51,7 @@
#include "public/platform/WebString.h"
#include "public/platform/modules/notifications/WebNotificationAction.h"
#include "public/platform/modules/notifications/WebNotificationManager.h"
+#include "wtf/Functional.h"
namespace blink {
namespace {
@@ -99,7 +101,7 @@ Notification* Notification::create(ExecutionContext* context, const String& titl
return nullptr;
Notification* notification = new Notification(context, data);
- notification->scheduleShow();
+ notification->schedulePrepareShow();
notification->suspendIfNeeded();
return notification;
@@ -121,7 +123,7 @@ Notification::Notification(ExecutionContext* context, const WebNotificationData&
, m_data(data)
, m_persistentId(kInvalidPersistentId)
, m_state(NotificationStateIdle)
- , m_asyncRunner(AsyncMethodRunner<Notification>::create(this, &Notification::show))
+ , m_prepareShowMethodRunner(AsyncMethodRunner<Notification>::create(this, &Notification::prepareShow))
{
ASSERT(notificationManager());
}
@@ -130,15 +132,15 @@ Notification::~Notification()
{
}
-void Notification::scheduleShow()
+void Notification::schedulePrepareShow()
{
ASSERT(m_state == NotificationStateIdle);
- ASSERT(!m_asyncRunner->isActive());
+ ASSERT(!m_prepareShowMethodRunner->isActive());
- m_asyncRunner->runAsync();
+ m_prepareShowMethodRunner->runAsync();
}
-void Notification::show()
+void Notification::prepareShow()
{
ASSERT(m_state == NotificationStateIdle);
if (Notification::checkPermission(getExecutionContext()) != WebNotificationPermissionAllowed) {
@@ -146,10 +148,19 @@ void Notification::show()
return;
}
+ m_loader = new NotificationResourcesLoader(bind<NotificationResourcesLoader*>(&Notification::didLoadResources, WeakPersistentThisPointer<Notification>(this)));
+ m_loader->start(getExecutionContext(), m_data);
+}
+
+void Notification::didLoadResources(NotificationResourcesLoader* loader)
+{
+ DCHECK_EQ(loader, m_loader.get());
+
SecurityOrigin* origin = getExecutionContext()->getSecurityOrigin();
ASSERT(origin);
- notificationManager()->show(WebSecurityOrigin(origin), m_data, this);
+ notificationManager()->show(WebSecurityOrigin(origin), m_data, loader->getResources(), this);
+ m_loader.clear();
m_state = NotificationStateShowing;
}
@@ -386,17 +397,21 @@ void Notification::stop()
m_state = NotificationStateClosed;
- m_asyncRunner->stop();
+ m_prepareShowMethodRunner->stop();
+
+ if (m_loader)
+ m_loader->stop();
}
bool Notification::hasPendingActivity() const
{
- return m_state == NotificationStateShowing || m_asyncRunner->isActive();
+ return m_state == NotificationStateShowing || m_prepareShowMethodRunner->isActive() || m_loader;
}
DEFINE_TRACE(Notification)
{
- visitor->trace(m_asyncRunner);
+ visitor->trace(m_prepareShowMethodRunner);
+ visitor->trace(m_loader);
EventTargetWithInlineData::trace(visitor);
ActiveDOMObject::trace(visitor);
}

Powered by Google App Engine
This is Rietveld 408576698