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

Unified Diff: Source/modules/serviceworkers/NavigatorServiceWorker.cpp

Issue 263143004: Add blink-side plumbing for ServiceWorker -> Document postMessage (1/3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: addressed comments Created 6 years, 7 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: Source/modules/serviceworkers/NavigatorServiceWorker.cpp
diff --git a/Source/modules/serviceworkers/NavigatorServiceWorker.cpp b/Source/modules/serviceworkers/NavigatorServiceWorker.cpp
index 57ef2a1511c27e672f5c163ede7eaf9076194398..7591f3bd345e56fb0ebee3f2e3d8d2ca4d0f6d61 100644
--- a/Source/modules/serviceworkers/NavigatorServiceWorker.cpp
+++ b/Source/modules/serviceworkers/NavigatorServiceWorker.cpp
@@ -5,6 +5,7 @@
#include "config.h"
#include "modules/serviceworkers/NavigatorServiceWorker.h"
+#include "core/dom/Document.h"
#include "core/frame/DOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Navigator.h"
@@ -21,12 +22,22 @@ NavigatorServiceWorker::~NavigatorServiceWorker()
{
}
+NavigatorServiceWorker* NavigatorServiceWorker::from(Document& document)
+{
+ if (!document.frame() || !document.frame()->domWindow())
+ return 0;
+ Navigator& navigator = document.frame()->domWindow()->navigator();
+ return &from(navigator);
+}
+
NavigatorServiceWorker& NavigatorServiceWorker::from(Navigator& navigator)
{
NavigatorServiceWorker* supplement = toNavigatorServiceWorker(navigator);
if (!supplement) {
supplement = new NavigatorServiceWorker(navigator);
provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement));
+ // Initialize ServiceWorkerContainer too.
+ supplement->serviceWorker();
}
return *supplement;
}
« no previous file with comments | « Source/modules/serviceworkers/NavigatorServiceWorker.h ('k') | Source/modules/serviceworkers/ServiceWorkerContainer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698