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

Unified Diff: Source/core/storage/DOMWindowStorageController.cpp

Issue 805773004: Create DOMWindowStorage as a DOMWindowLifecycleObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rename Created 6 years 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/core/storage/DOMWindowStorageController.h ('k') | Source/web/FrameLoaderClientImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/storage/DOMWindowStorageController.cpp
diff --git a/Source/core/storage/DOMWindowStorageController.cpp b/Source/core/storage/DOMWindowStorageController.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1a2363c89e0510e9d46bf09509003136bef2d608
--- /dev/null
+++ b/Source/core/storage/DOMWindowStorageController.cpp
@@ -0,0 +1,54 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/storage/DOMWindowStorageController.h"
+
+#include "core/dom/Document.h"
+#include "core/events/Event.h"
+#include "core/frame/LocalDOMWindow.h"
+#include "core/page/Page.h"
+
+namespace blink {
+
+DOMWindowStorageController::DOMWindowStorageController(Document& document)
+ : DOMWindowLifecycleObserver(document.domWindow())
+ , m_document(document)
+{
+}
+
+DOMWindowStorageController::~DOMWindowStorageController()
+{
+}
+
+// static
+const char* DOMWindowStorageController::supplementName()
+{
+ return "DOMWindowStorageController";
+}
+
+// static
+DOMWindowStorageController& DOMWindowStorageController::from(Document& document)
+{
+ DOMWindowStorageController* controller = static_cast<DOMWindowStorageController*>(WillBeHeapSupplement<Document>::from(document, supplementName()));
+ if (!controller) {
+ controller = new DOMWindowStorageController(document);
+ DocumentSupplement::provideTo(document, supplementName(), adoptPtrWillBeNoop(controller));
+ }
+ return *controller;
+}
+
+void DOMWindowStorageController::didAddEventListener(LocalDOMWindow* window, const AtomicString& eventType)
+{
+ if (eventType == EventTypeNames::storage) {
+ // Creating these blink::Storage objects informs the system that we'd like to receive
+ // notifications about storage events that might be triggered in other processes. Rather
+ // than subscribe to these notifications explicitly, we subscribe to them implicitly to
+ // simplify the work done by the system.
+ window->localStorage(IGNORE_EXCEPTION);
+ window->sessionStorage(IGNORE_EXCEPTION);
+ }
+}
+
+} // namespace blink
« no previous file with comments | « Source/core/storage/DOMWindowStorageController.h ('k') | Source/web/FrameLoaderClientImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698