OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2009 Google Inc. All Rights Reserved. |
3 * (C) 2008 Apple Inc. | 3 * (C) 2008 Apple Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 size_t StorageArea::memoryBytesUsedByCache() | 138 size_t StorageArea::memoryBytesUsedByCache() |
139 { | 139 { |
140 return m_storageArea->memoryBytesUsedByCache(); | 140 return m_storageArea->memoryBytesUsedByCache(); |
141 } | 141 } |
142 | 142 |
143 void StorageArea::dispatchLocalStorageEvent(const String& key, const String& old
Value, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pageU
RL, blink::WebStorageArea* sourceAreaInstance, bool originatedInProcess) | 143 void StorageArea::dispatchLocalStorageEvent(const String& key, const String& old
Value, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pageU
RL, blink::WebStorageArea* sourceAreaInstance, bool originatedInProcess) |
144 { | 144 { |
145 // FIXME: This looks suspicious. Why doesn't this use allPages instead? | 145 // FIXME: This looks suspicious. Why doesn't this use allPages instead? |
146 const HashSet<Page*>& pages = Page::ordinaryPages(); | 146 const HashSet<Page*>& pages = Page::ordinaryPages(); |
147 for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); +
+it) { | 147 for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); +
+it) { |
148 for (LocalFrame* frame = (*it)->mainFrame(); frame; frame = frame->tree(
).traverseNext()) { | 148 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree().tra
verseNext()) { |
| 149 // FIXME: We do not yet have a way to dispatch events to out-of-proc
ess frames. |
| 150 if (!frame->isLocalFrame()) |
| 151 continue; |
149 Storage* storage = frame->domWindow()->optionalLocalStorage(); | 152 Storage* storage = frame->domWindow()->optionalLocalStorage(); |
150 if (storage && frame->document()->securityOrigin()->canAccess(securi
tyOrigin) && !isEventSource(storage, sourceAreaInstance)) | 153 if (storage && toLocalFrame(frame)->document()->securityOrigin()->ca
nAccess(securityOrigin) && !isEventSource(storage, sourceAreaInstance)) |
151 frame->domWindow()->enqueueWindowEvent(StorageEvent::create(Even
tTypeNames::storage, key, oldValue, newValue, pageURL, storage)); | 154 frame->domWindow()->enqueueWindowEvent(StorageEvent::create(Even
tTypeNames::storage, key, oldValue, newValue, pageURL, storage)); |
152 } | 155 } |
153 InspectorInstrumentation::didDispatchDOMStorageEvent(*it, key, oldValue,
newValue, LocalStorage, securityOrigin); | 156 InspectorInstrumentation::didDispatchDOMStorageEvent(*it, key, oldValue,
newValue, LocalStorage, securityOrigin); |
154 } | 157 } |
155 } | 158 } |
156 | 159 |
157 static Page* findPageWithSessionStorageNamespace(const blink::WebStorageNamespac
e& sessionNamespace) | 160 static Page* findPageWithSessionStorageNamespace(const blink::WebStorageNamespac
e& sessionNamespace) |
158 { | 161 { |
159 // FIXME: This looks suspicious. Why doesn't this use allPages instead? | 162 // FIXME: This looks suspicious. Why doesn't this use allPages instead? |
160 const HashSet<Page*>& pages = Page::ordinaryPages(); | 163 const HashSet<Page*>& pages = Page::ordinaryPages(); |
161 for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); +
+it) { | 164 for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); +
+it) { |
162 const bool dontCreateIfMissing = false; | 165 const bool dontCreateIfMissing = false; |
163 StorageNamespace* storageNamespace = (*it)->sessionStorage(dontCreateIfM
issing); | 166 StorageNamespace* storageNamespace = (*it)->sessionStorage(dontCreateIfM
issing); |
164 if (storageNamespace && storageNamespace->isSameNamespace(sessionNamespa
ce)) | 167 if (storageNamespace && storageNamespace->isSameNamespace(sessionNamespa
ce)) |
165 return *it; | 168 return *it; |
166 } | 169 } |
167 return 0; | 170 return 0; |
168 } | 171 } |
169 | 172 |
170 void StorageArea::dispatchSessionStorageEvent(const String& key, const String& o
ldValue, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pag
eURL, const blink::WebStorageNamespace& sessionNamespace, blink::WebStorageArea*
sourceAreaInstance, bool originatedInProcess) | 173 void StorageArea::dispatchSessionStorageEvent(const String& key, const String& o
ldValue, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pag
eURL, const blink::WebStorageNamespace& sessionNamespace, blink::WebStorageArea*
sourceAreaInstance, bool originatedInProcess) |
171 { | 174 { |
172 Page* page = findPageWithSessionStorageNamespace(sessionNamespace); | 175 Page* page = findPageWithSessionStorageNamespace(sessionNamespace); |
173 if (!page) | 176 if (!page) |
174 return; | 177 return; |
175 | 178 |
176 for (LocalFrame* frame = page->mainFrame(); frame; frame = frame->tree().tra
verseNext()) { | 179 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverse
Next()) { |
| 180 // FIXME: We do not yet have a way to dispatch events to out-of-process
frames. |
| 181 if (!frame->isLocalFrame()) |
| 182 continue; |
177 Storage* storage = frame->domWindow()->optionalSessionStorage(); | 183 Storage* storage = frame->domWindow()->optionalSessionStorage(); |
178 if (storage && frame->document()->securityOrigin()->canAccess(securityOr
igin) && !isEventSource(storage, sourceAreaInstance)) | 184 if (storage && toLocalFrame(frame)->document()->securityOrigin()->canAcc
ess(securityOrigin) && !isEventSource(storage, sourceAreaInstance)) |
179 frame->domWindow()->enqueueWindowEvent(StorageEvent::create(EventTyp
eNames::storage, key, oldValue, newValue, pageURL, storage)); | 185 frame->domWindow()->enqueueWindowEvent(StorageEvent::create(EventTyp
eNames::storage, key, oldValue, newValue, pageURL, storage)); |
180 } | 186 } |
181 InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, ne
wValue, SessionStorage, securityOrigin); | 187 InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, ne
wValue, SessionStorage, securityOrigin); |
182 } | 188 } |
183 | 189 |
184 bool StorageArea::isEventSource(Storage* storage, blink::WebStorageArea* sourceA
reaInstance) | 190 bool StorageArea::isEventSource(Storage* storage, blink::WebStorageArea* sourceA
reaInstance) |
185 { | 191 { |
186 ASSERT(storage); | 192 ASSERT(storage); |
187 StorageArea* area = storage->area(); | 193 StorageArea* area = storage->area(); |
188 return area->m_storageArea == sourceAreaInstance; | 194 return area->m_storageArea == sourceAreaInstance; |
189 } | 195 } |
190 | 196 |
191 } // namespace WebCore | 197 } // namespace WebCore |
OLD | NEW |