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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 return result; | 154 return result; |
155 } | 155 } |
156 | 156 |
157 size_t StorageArea::memoryBytesUsedByCache() | 157 size_t StorageArea::memoryBytesUsedByCache() |
158 { | 158 { |
159 return m_storageArea->memoryBytesUsedByCache(); | 159 return m_storageArea->memoryBytesUsedByCache(); |
160 } | 160 } |
161 | 161 |
162 void StorageArea::dispatchLocalStorageEvent(const String& key, const String& old
Value, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pageU
RL, WebStorageArea* sourceAreaInstance, bool originatedInProcess) | 162 void StorageArea::dispatchLocalStorageEvent(const String& key, const String& old
Value, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pageU
RL, WebStorageArea* sourceAreaInstance, bool originatedInProcess) |
163 { | 163 { |
164 // FIXME: This looks suspicious. Why doesn't this use allPages instead? | 164 // Iterate over all pages that have a StorageNamespaceController supplement. |
165 const WillBePersistentHeapHashSet<RawPtrWillBeWeakMember<Page>>& pages = Pag
e::ordinaryPages(); | 165 for (Page* page : Page::ordinaryPages()) { |
166 for (Page* page : pages) { | |
167 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().trav
erseNext()) { | 166 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().trav
erseNext()) { |
168 // FIXME: We do not yet have a way to dispatch events to out-of-proc
ess frames. | 167 // FIXME: We do not yet have a way to dispatch events to out-of-proc
ess frames. |
169 if (!frame->isLocalFrame()) | 168 if (!frame->isLocalFrame()) |
170 continue; | 169 continue; |
171 LocalFrame* localFrame = toLocalFrame(frame); | 170 LocalFrame* localFrame = toLocalFrame(frame); |
172 LocalDOMWindow* localWindow = localFrame->localDOMWindow(); | 171 LocalDOMWindow* localWindow = localFrame->localDOMWindow(); |
173 Storage* storage = DOMWindowStorage::from(*localWindow).optionalLoca
lStorage(); | 172 Storage* storage = DOMWindowStorage::from(*localWindow).optionalLoca
lStorage(); |
174 if (storage && localFrame->document()->securityOrigin()->canAccess(s
ecurityOrigin) && !isEventSource(storage, sourceAreaInstance)) | 173 if (storage && localFrame->document()->securityOrigin()->canAccess(s
ecurityOrigin) && !isEventSource(storage, sourceAreaInstance)) |
175 localFrame->localDOMWindow()->enqueueWindowEvent(StorageEvent::c
reate(EventTypeNames::storage, key, oldValue, newValue, pageURL, storage)); | 174 localFrame->localDOMWindow()->enqueueWindowEvent(StorageEvent::c
reate(EventTypeNames::storage, key, oldValue, newValue, pageURL, storage)); |
176 } | 175 } |
177 if (InspectorDOMStorageAgent* agent = StorageNamespaceController::from(p
age)->inspectorAgent()) | 176 if (InspectorDOMStorageAgent* agent = StorageNamespaceController::from(p
age)->inspectorAgent()) |
178 agent->didDispatchDOMStorageEvent(key, oldValue, newValue, LocalStor
age, securityOrigin); | 177 agent->didDispatchDOMStorageEvent(key, oldValue, newValue, LocalStor
age, securityOrigin); |
179 } | 178 } |
180 } | 179 } |
181 | 180 |
182 static Page* findPageWithSessionStorageNamespace(const WebStorageNamespace& sess
ionNamespace) | 181 static Page* findPageWithSessionStorageNamespace(const WebStorageNamespace& sess
ionNamespace) |
183 { | 182 { |
184 // FIXME: This looks suspicious. Why doesn't this use allPages instead? | 183 // Iterate over all pages that have a StorageNamespaceController supplement. |
185 const WillBePersistentHeapHashSet<RawPtrWillBeWeakMember<Page>>& pages = Pag
e::ordinaryPages(); | 184 for (Page* page : Page::ordinaryPages()) { |
186 for (Page* page : pages) { | |
187 const bool dontCreateIfMissing = false; | 185 const bool dontCreateIfMissing = false; |
188 StorageNamespace* storageNamespace = StorageNamespaceController::from(pa
ge)->sessionStorage(dontCreateIfMissing); | 186 StorageNamespace* storageNamespace = StorageNamespaceController::from(pa
ge)->sessionStorage(dontCreateIfMissing); |
189 if (storageNamespace && storageNamespace->isSameNamespace(sessionNamespa
ce)) | 187 if (storageNamespace && storageNamespace->isSameNamespace(sessionNamespa
ce)) |
190 return page; | 188 return page; |
191 } | 189 } |
192 return nullptr; | 190 return nullptr; |
193 } | 191 } |
194 | 192 |
195 void StorageArea::dispatchSessionStorageEvent(const String& key, const String& o
ldValue, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pag
eURL, const WebStorageNamespace& sessionNamespace, WebStorageArea* sourceAreaIns
tance, bool originatedInProcess) | 193 void StorageArea::dispatchSessionStorageEvent(const String& key, const String& o
ldValue, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pag
eURL, const WebStorageNamespace& sessionNamespace, WebStorageArea* sourceAreaIns
tance, bool originatedInProcess) |
196 { | 194 { |
(...skipping 16 matching lines...) Expand all Loading... |
213 } | 211 } |
214 | 212 |
215 bool StorageArea::isEventSource(Storage* storage, WebStorageArea* sourceAreaInst
ance) | 213 bool StorageArea::isEventSource(Storage* storage, WebStorageArea* sourceAreaInst
ance) |
216 { | 214 { |
217 ASSERT(storage); | 215 ASSERT(storage); |
218 StorageArea* area = storage->area(); | 216 StorageArea* area = storage->area(); |
219 return area->m_storageArea == sourceAreaInstance; | 217 return area->m_storageArea == sourceAreaInstance; |
220 } | 218 } |
221 | 219 |
222 } // namespace blink | 220 } // namespace blink |
OLD | NEW |