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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 { | 147 { |
148 return m_storageArea->memoryBytesUsedByCache(); | 148 return m_storageArea->memoryBytesUsedByCache(); |
149 } | 149 } |
150 | 150 |
151 void StorageAreaProxy::dispatchLocalStorageEvent(const String& key, const String
& oldValue, const String& newValue, | 151 void StorageAreaProxy::dispatchLocalStorageEvent(const String& key, const String
& oldValue, const String& newValue, |
152 SecurityOrigin* securityOrigin,
const KURL& pageURL, WebKit::WebStorageArea* sourceAreaInstance, bool originate
dInProcess) | 152 SecurityOrigin* securityOrigin,
const KURL& pageURL, WebKit::WebStorageArea* sourceAreaInstance, bool originate
dInProcess) |
153 { | 153 { |
154 // FIXME: This looks suspicious. Why doesn't this use allPages instead? | 154 // FIXME: This looks suspicious. Why doesn't this use allPages instead? |
155 const HashSet<Page*>& pages = PageGroup::sharedGroup()->pages(); | 155 const HashSet<Page*>& pages = PageGroup::sharedGroup()->pages(); |
156 for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); +
+it) { | 156 for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); +
+it) { |
157 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->tr
averseNext()) { | 157 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree().tra
verseNext()) { |
158 Storage* storage = frame->domWindow()->optionalLocalStorage(); | 158 Storage* storage = frame->domWindow()->optionalLocalStorage(); |
159 if (storage && frame->document()->securityOrigin()->equal(securityOr
igin) && !isEventSource(storage, sourceAreaInstance)) | 159 if (storage && frame->document()->securityOrigin()->equal(securityOr
igin) && !isEventSource(storage, sourceAreaInstance)) |
160 frame->document()->enqueueWindowEvent(StorageEvent::create(Event
TypeNames::storage, key, oldValue, newValue, pageURL, storage)); | 160 frame->document()->enqueueWindowEvent(StorageEvent::create(Event
TypeNames::storage, key, oldValue, newValue, pageURL, storage)); |
161 } | 161 } |
162 InspectorInstrumentation::didDispatchDOMStorageEvent(*it, key, oldValue,
newValue, LocalStorage, securityOrigin); | 162 InspectorInstrumentation::didDispatchDOMStorageEvent(*it, key, oldValue,
newValue, LocalStorage, securityOrigin); |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 static Page* findPageWithSessionStorageNamespace(const WebKit::WebStorageNamespa
ce& sessionNamespace) | 166 static Page* findPageWithSessionStorageNamespace(const WebKit::WebStorageNamespa
ce& sessionNamespace) |
167 { | 167 { |
168 // FIXME: This looks suspicious. Why doesn't this use allPages instead? | 168 // FIXME: This looks suspicious. Why doesn't this use allPages instead? |
169 const HashSet<Page*>& pages = PageGroup::sharedGroup()->pages(); | 169 const HashSet<Page*>& pages = PageGroup::sharedGroup()->pages(); |
170 for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); +
+it) { | 170 for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); +
+it) { |
171 const bool dontCreateIfMissing = false; | 171 const bool dontCreateIfMissing = false; |
172 StorageNamespaceProxy* proxy = static_cast<StorageNamespaceProxy*>((*it)
->sessionStorage(dontCreateIfMissing)); | 172 StorageNamespaceProxy* proxy = static_cast<StorageNamespaceProxy*>((*it)
->sessionStorage(dontCreateIfMissing)); |
173 if (proxy && proxy->isSameNamespace(sessionNamespace)) | 173 if (proxy && proxy->isSameNamespace(sessionNamespace)) |
174 return *it; | 174 return *it; |
175 } | 175 } |
176 return 0; | 176 return 0; |
177 } | 177 } |
178 | 178 |
179 void StorageAreaProxy::dispatchSessionStorageEvent(const String& key, const Stri
ng& oldValue, const String& newValue, | 179 void StorageAreaProxy::dispatchSessionStorageEvent(const String& key, const Stri
ng& oldValue, const String& newValue, |
180 SecurityOrigin* securityOrigi
n, const KURL& pageURL, const WebKit::WebStorageNamespace& sessionNamespace, | 180 SecurityOrigin* securityOrigi
n, const KURL& pageURL, const WebKit::WebStorageNamespace& sessionNamespace, |
181 WebKit::WebStorageArea* sourc
eAreaInstance, bool originatedInProcess) | 181 WebKit::WebStorageArea* sourc
eAreaInstance, bool originatedInProcess) |
182 { | 182 { |
183 Page* page = findPageWithSessionStorageNamespace(sessionNamespace); | 183 Page* page = findPageWithSessionStorageNamespace(sessionNamespace); |
184 if (!page) | 184 if (!page) |
185 return; | 185 return; |
186 | 186 |
187 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->travers
eNext()) { | 187 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverse
Next()) { |
188 Storage* storage = frame->domWindow()->optionalSessionStorage(); | 188 Storage* storage = frame->domWindow()->optionalSessionStorage(); |
189 if (storage && frame->document()->securityOrigin()->equal(securityOrigin
) && !isEventSource(storage, sourceAreaInstance)) | 189 if (storage && frame->document()->securityOrigin()->equal(securityOrigin
) && !isEventSource(storage, sourceAreaInstance)) |
190 frame->document()->enqueueWindowEvent(StorageEvent::create(EventType
Names::storage, key, oldValue, newValue, pageURL, storage)); | 190 frame->document()->enqueueWindowEvent(StorageEvent::create(EventType
Names::storage, key, oldValue, newValue, pageURL, storage)); |
191 } | 191 } |
192 InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, ne
wValue, SessionStorage, securityOrigin); | 192 InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, ne
wValue, SessionStorage, securityOrigin); |
193 } | 193 } |
194 | 194 |
195 bool StorageAreaProxy::isEventSource(Storage* storage, WebKit::WebStorageArea* s
ourceAreaInstance) | 195 bool StorageAreaProxy::isEventSource(Storage* storage, WebKit::WebStorageArea* s
ourceAreaInstance) |
196 { | 196 { |
197 ASSERT(storage); | 197 ASSERT(storage); |
198 StorageAreaProxy* areaProxy = static_cast<StorageAreaProxy*>(storage->area()
); | 198 StorageAreaProxy* areaProxy = static_cast<StorageAreaProxy*>(storage->area()
); |
199 return areaProxy->m_storageArea == sourceAreaInstance; | 199 return areaProxy->m_storageArea == sourceAreaInstance; |
200 } | 200 } |
201 | 201 |
202 } // namespace WebCore | 202 } // namespace WebCore |
OLD | NEW |