Chromium Code Reviews| Index: Source/core/storage/DOMWindowStorage.cpp |
| diff --git a/Source/core/storage/DOMWindowStorage.cpp b/Source/core/storage/DOMWindowStorage.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9f47be9c0c208107de253277e8fad8a3ffdc85db |
| --- /dev/null |
| +++ b/Source/core/storage/DOMWindowStorage.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/DOMWindowStorage.h" |
| + |
| +#include "core/dom/Document.h" |
| +#include "core/events/Event.h" |
| +#include "core/frame/LocalDOMWindow.h" |
| +#include "core/page/Page.h" |
| + |
| +namespace blink { |
| + |
| +DOMWindowStorage::DOMWindowStorage(Document& document) |
| + : DOMWindowLifecycleObserver(document.domWindow()) |
| + , m_document(document) |
| +{ |
| +} |
| + |
| +DOMWindowStorage::~DOMWindowStorage() |
| +{ |
| +} |
| + |
| +// static |
| +const char* DOMWindowStorage::supplementName() |
| +{ |
| + return "DOMWindowStorage"; |
| +} |
| + |
| +// static |
| +DOMWindowStorage& DOMWindowStorage::from(Document& document) |
| +{ |
| + DOMWindowStorage* controller = static_cast<DOMWindowStorage*>(WillBeHeapSupplement<Document>::from(document, supplementName())); |
|
michaeln
2014/12/16 00:12:11
I'm not familiar with how 'supplements' are typica
|
| + if (!controller) { |
| + controller = new DOMWindowStorage(document); |
| + DocumentSupplement::provideTo(document, supplementName(), adoptPtrWillBeNoop(controller)); |
| + } |
| + return *controller; |
| +} |
| + |
| +void DOMWindowStorage::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 |