OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/storage/DOMWindowStorageController.h" | 5 #include "modules/storage/DOMWindowStorageController.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/events/Event.h" | 8 #include "core/events/Event.h" |
9 #include "core/frame/LocalDOMWindow.h" | 9 #include "core/frame/LocalDOMWindow.h" |
10 #include "core/page/Page.h" | 10 #include "core/page/Page.h" |
11 #include "modules/storage/DOMWindowStorage.h" | 11 #include "modules/storage/DOMWindowStorage.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 DOMWindowStorageController::DOMWindowStorageController(Document& document) | 15 DOMWindowStorageController::DOMWindowStorageController(Document& document) |
16 : DOMWindowLifecycleObserver(document.domWindow()) | 16 : DOMWindowLifecycleObserver(document.domWindow()) |
17 , m_document(document) | 17 , m_document(document) |
18 { | 18 { |
19 } | 19 } |
20 | 20 |
21 DEFINE_TRACE(DOMWindowStorageController) | 21 DEFINE_TRACE(DOMWindowStorageController) |
22 { | 22 { |
23 visitor->trace(m_document); | 23 visitor->trace(m_document); |
24 HeapSupplement<Document>::trace(visitor); | 24 Supplement<Document>::trace(visitor); |
25 DOMWindowLifecycleObserver::trace(visitor); | 25 DOMWindowLifecycleObserver::trace(visitor); |
26 } | 26 } |
27 | 27 |
28 // static | 28 // static |
29 const char* DOMWindowStorageController::supplementName() | 29 const char* DOMWindowStorageController::supplementName() |
30 { | 30 { |
31 return "DOMWindowStorageController"; | 31 return "DOMWindowStorageController"; |
32 } | 32 } |
33 | 33 |
34 // static | 34 // static |
35 DOMWindowStorageController& DOMWindowStorageController::from(Document& document) | 35 DOMWindowStorageController& DOMWindowStorageController::from(Document& document) |
36 { | 36 { |
37 DOMWindowStorageController* controller = static_cast<DOMWindowStorageControl
ler*>(HeapSupplement<Document>::from(document, supplementName())); | 37 DOMWindowStorageController* controller = static_cast<DOMWindowStorageControl
ler*>(Supplement<Document>::from(document, supplementName())); |
38 if (!controller) { | 38 if (!controller) { |
39 controller = new DOMWindowStorageController(document); | 39 controller = new DOMWindowStorageController(document); |
40 HeapSupplement<Document>::provideTo(document, supplementName(), controll
er); | 40 Supplement<Document>::provideTo(document, supplementName(), controller); |
41 } | 41 } |
42 return *controller; | 42 return *controller; |
43 } | 43 } |
44 | 44 |
45 void DOMWindowStorageController::didAddEventListener(LocalDOMWindow* window, con
st AtomicString& eventType) | 45 void DOMWindowStorageController::didAddEventListener(LocalDOMWindow* window, con
st AtomicString& eventType) |
46 { | 46 { |
47 if (eventType == EventTypeNames::storage) { | 47 if (eventType == EventTypeNames::storage) { |
48 // Creating these blink::Storage objects informs the system that we'd li
ke to receive | 48 // Creating these blink::Storage objects informs the system that we'd li
ke to receive |
49 // notifications about storage events that might be triggered in other p
rocesses. Rather | 49 // notifications about storage events that might be triggered in other p
rocesses. Rather |
50 // than subscribe to these notifications explicitly, we subscribe to the
m implicitly to | 50 // than subscribe to these notifications explicitly, we subscribe to the
m implicitly to |
51 // simplify the work done by the system. | 51 // simplify the work done by the system. |
52 DOMWindowStorage::from(*window).localStorage(IGNORE_EXCEPTION); | 52 DOMWindowStorage::from(*window).localStorage(IGNORE_EXCEPTION); |
53 DOMWindowStorage::from(*window).sessionStorage(IGNORE_EXCEPTION); | 53 DOMWindowStorage::from(*window).sessionStorage(IGNORE_EXCEPTION); |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 } // namespace blink | 57 } // namespace blink |
OLD | NEW |