OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2009 Google Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 11 matching lines...) Expand all Loading... |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef StorageArea_h | 26 #ifndef StorageArea_h |
27 #define StorageArea_h | 27 #define StorageArea_h |
28 | 28 |
29 #include "core/frame/LocalFrameLifecycleObserver.h" | 29 #include "core/frame/LocalFrameLifecycleObserver.h" |
30 #include "modules/ModulesExport.h" | 30 #include "modules/ModulesExport.h" |
31 #include "platform/heap/Handle.h" | 31 #include "platform/heap/Handle.h" |
32 #include "wtf/OwnPtr.h" | |
33 #include "wtf/PassOwnPtr.h" | |
34 #include "wtf/text/WTFString.h" | 32 #include "wtf/text/WTFString.h" |
| 33 #include <memory> |
35 | 34 |
36 namespace blink { | 35 namespace blink { |
37 | 36 |
38 class ExceptionState; | 37 class ExceptionState; |
39 class LocalFrame; | 38 class LocalFrame; |
40 class KURL; | 39 class KURL; |
41 class SecurityOrigin; | 40 class SecurityOrigin; |
42 class Storage; | 41 class Storage; |
43 class WebStorageArea; | 42 class WebStorageArea; |
44 class WebStorageNamespace; | 43 class WebStorageNamespace; |
45 | 44 |
46 enum StorageType { | 45 enum StorageType { |
47 LocalStorage, | 46 LocalStorage, |
48 SessionStorage | 47 SessionStorage |
49 }; | 48 }; |
50 | 49 |
51 class MODULES_EXPORT StorageArea final : public GarbageCollectedFinalized<Storag
eArea>, public LocalFrameLifecycleObserver { | 50 class MODULES_EXPORT StorageArea final : public GarbageCollectedFinalized<Storag
eArea>, public LocalFrameLifecycleObserver { |
52 USING_GARBAGE_COLLECTED_MIXIN(StorageArea); | 51 USING_GARBAGE_COLLECTED_MIXIN(StorageArea); |
53 public: | 52 public: |
54 static StorageArea* create(PassOwnPtr<WebStorageArea>, StorageType); | 53 static StorageArea* create(std::unique_ptr<WebStorageArea>, StorageType); |
55 | 54 |
56 virtual ~StorageArea(); | 55 virtual ~StorageArea(); |
57 | 56 |
58 // The HTML5 DOM Storage API | 57 // The HTML5 DOM Storage API |
59 unsigned length(ExceptionState&, LocalFrame* sourceFrame); | 58 unsigned length(ExceptionState&, LocalFrame* sourceFrame); |
60 String key(unsigned index, ExceptionState&, LocalFrame* sourceFrame); | 59 String key(unsigned index, ExceptionState&, LocalFrame* sourceFrame); |
61 String getItem(const String& key, ExceptionState&, LocalFrame* sourceFrame); | 60 String getItem(const String& key, ExceptionState&, LocalFrame* sourceFrame); |
62 void setItem(const String& key, const String& value, ExceptionState&, LocalF
rame* sourceFrame); | 61 void setItem(const String& key, const String& value, ExceptionState&, LocalF
rame* sourceFrame); |
63 void removeItem(const String& key, ExceptionState&, LocalFrame* sourceFrame)
; | 62 void removeItem(const String& key, ExceptionState&, LocalFrame* sourceFrame)
; |
64 void clear(ExceptionState&, LocalFrame* sourceFrame); | 63 void clear(ExceptionState&, LocalFrame* sourceFrame); |
65 bool contains(const String& key, ExceptionState&, LocalFrame* sourceFrame); | 64 bool contains(const String& key, ExceptionState&, LocalFrame* sourceFrame); |
66 | 65 |
67 bool canAccessStorage(LocalFrame*); | 66 bool canAccessStorage(LocalFrame*); |
68 | 67 |
69 static void dispatchLocalStorageEvent(const String& key, const String& oldVa
lue, const String& newValue, | 68 static void dispatchLocalStorageEvent(const String& key, const String& oldVa
lue, const String& newValue, |
70 SecurityOrigin*, const KURL& pageURL, WebStorageArea* sourceAreaInstance
); | 69 SecurityOrigin*, const KURL& pageURL, WebStorageArea* sourceAreaInstance
); |
71 static void dispatchSessionStorageEvent(const String& key, const String& old
Value, const String& newValue, | 70 static void dispatchSessionStorageEvent(const String& key, const String& old
Value, const String& newValue, |
72 SecurityOrigin*, const KURL& pageURL, const WebStorageNamespace&, WebSto
rageArea* sourceAreaInstance); | 71 SecurityOrigin*, const KURL& pageURL, const WebStorageNamespace&, WebSto
rageArea* sourceAreaInstance); |
73 | 72 |
74 DECLARE_TRACE(); | 73 DECLARE_TRACE(); |
75 | 74 |
76 private: | 75 private: |
77 StorageArea(PassOwnPtr<WebStorageArea>, StorageType); | 76 StorageArea(std::unique_ptr<WebStorageArea>, StorageType); |
78 | 77 |
79 static bool isEventSource(Storage*, WebStorageArea* sourceAreaInstance); | 78 static bool isEventSource(Storage*, WebStorageArea* sourceAreaInstance); |
80 | 79 |
81 OwnPtr<WebStorageArea> m_storageArea; | 80 std::unique_ptr<WebStorageArea> m_storageArea; |
82 StorageType m_storageType; | 81 StorageType m_storageType; |
83 bool m_canAccessStorageCachedResult; | 82 bool m_canAccessStorageCachedResult; |
84 }; | 83 }; |
85 | 84 |
86 } // namespace blink | 85 } // namespace blink |
87 | 86 |
88 #endif // StorageArea_h | 87 #endif // StorageArea_h |
OLD | NEW |