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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "public/platform/WebURL.h" | 46 #include "public/platform/WebURL.h" |
47 | 47 |
48 namespace blink { | 48 namespace blink { |
49 | 49 |
50 PassOwnPtrWillBeRawPtr<StorageArea> StorageArea::create(PassOwnPtr<WebStorageAre
a> storageArea, StorageType storageType) | 50 PassOwnPtrWillBeRawPtr<StorageArea> StorageArea::create(PassOwnPtr<WebStorageAre
a> storageArea, StorageType storageType) |
51 { | 51 { |
52 return adoptPtrWillBeNoop(new StorageArea(storageArea, storageType)); | 52 return adoptPtrWillBeNoop(new StorageArea(storageArea, storageType)); |
53 } | 53 } |
54 | 54 |
55 StorageArea::StorageArea(PassOwnPtr<WebStorageArea> storageArea, StorageType sto
rageType) | 55 StorageArea::StorageArea(PassOwnPtr<WebStorageArea> storageArea, StorageType sto
rageType) |
56 : FrameDestructionObserver(nullptr) | 56 : LocalFrameLifecycleObserver(nullptr) |
57 , m_storageArea(storageArea) | 57 , m_storageArea(storageArea) |
58 , m_storageType(storageType) | 58 , m_storageType(storageType) |
59 , m_canAccessStorageCachedResult(false) | 59 , m_canAccessStorageCachedResult(false) |
60 { | 60 { |
61 } | 61 } |
62 | 62 |
63 StorageArea::~StorageArea() | 63 StorageArea::~StorageArea() |
64 { | 64 { |
65 } | 65 } |
66 | 66 |
67 DEFINE_TRACE(StorageArea) | 67 DEFINE_TRACE(StorageArea) |
68 { | 68 { |
69 FrameDestructionObserver::trace(visitor); | 69 LocalFrameLifecycleObserver::trace(visitor); |
70 } | 70 } |
71 | 71 |
72 unsigned StorageArea::length(ExceptionState& exceptionState, LocalFrame* frame) | 72 unsigned StorageArea::length(ExceptionState& exceptionState, LocalFrame* frame) |
73 { | 73 { |
74 if (!canAccessStorage(frame)) { | 74 if (!canAccessStorage(frame)) { |
75 exceptionState.throwSecurityError("access is denied for this document.")
; | 75 exceptionState.throwSecurityError("access is denied for this document.")
; |
76 return 0; | 76 return 0; |
77 } | 77 } |
78 return m_storageArea->length(); | 78 return m_storageArea->length(); |
79 } | 79 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 return false; | 133 return false; |
134 } | 134 } |
135 return !getItem(key, exceptionState, frame).isNull(); | 135 return !getItem(key, exceptionState, frame).isNull(); |
136 } | 136 } |
137 | 137 |
138 bool StorageArea::canAccessStorage(LocalFrame* frame) | 138 bool StorageArea::canAccessStorage(LocalFrame* frame) |
139 { | 139 { |
140 if (!frame || !frame->page()) | 140 if (!frame || !frame->page()) |
141 return false; | 141 return false; |
142 | 142 |
143 // FrameDestructionObserver is used to safely keep the cached | 143 // LocalFrameLifecycleObserver is used to safely keep the cached |
144 // reference to the LocalFrame. Should the LocalFrame die before | 144 // reference to the LocalFrame. Should the LocalFrame die before |
145 // this StorageArea does, that cached reference will be cleared. | 145 // this StorageArea does, that cached reference will be cleared. |
146 if (this->frame() == frame) | 146 if (this->frame() == frame) |
147 return m_canAccessStorageCachedResult; | 147 return m_canAccessStorageCachedResult; |
148 StorageNamespaceController* controller = StorageNamespaceController::from(fr
ame->page()); | 148 StorageNamespaceController* controller = StorageNamespaceController::from(fr
ame->page()); |
149 if (!controller) | 149 if (!controller) |
150 return false; | 150 return false; |
151 bool result = controller->storageClient()->canAccessStorage(frame, m_storage
Type); | 151 bool result = controller->storageClient()->canAccessStorage(frame, m_storage
Type); |
152 // Move attention to the new LocalFrame. | 152 // Move attention to the new LocalFrame. |
153 FrameDestructionObserver::setContext(frame); | 153 LocalFrameLifecycleObserver::setContext(frame); |
154 m_canAccessStorageCachedResult = result; | 154 m_canAccessStorageCachedResult = result; |
155 return result; | 155 return result; |
156 } | 156 } |
157 | 157 |
158 size_t StorageArea::memoryBytesUsedByCache() | 158 size_t StorageArea::memoryBytesUsedByCache() |
159 { | 159 { |
160 return m_storageArea->memoryBytesUsedByCache(); | 160 return m_storageArea->memoryBytesUsedByCache(); |
161 } | 161 } |
162 | 162 |
163 void StorageArea::dispatchLocalStorageEvent(const String& key, const String& old
Value, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pageU
RL, WebStorageArea* sourceAreaInstance, bool originatedInProcess) | 163 void StorageArea::dispatchLocalStorageEvent(const String& key, const String& old
Value, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pageU
RL, WebStorageArea* sourceAreaInstance, bool originatedInProcess) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 214 } |
215 | 215 |
216 bool StorageArea::isEventSource(Storage* storage, WebStorageArea* sourceAreaInst
ance) | 216 bool StorageArea::isEventSource(Storage* storage, WebStorageArea* sourceAreaInst
ance) |
217 { | 217 { |
218 ASSERT(storage); | 218 ASSERT(storage); |
219 StorageArea* area = storage->area(); | 219 StorageArea* area = storage->area(); |
220 return area->m_storageArea == sourceAreaInstance; | 220 return area->m_storageArea == sourceAreaInstance; |
221 } | 221 } |
222 | 222 |
223 } // namespace blink | 223 } // namespace blink |
OLD | NEW |