OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_AREA_H_ | 5 #ifndef CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_AREA_H_ |
6 #define CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_AREA_H_ | 6 #define CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_AREA_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "content/renderer/dom_storage/local_storage_cached_area.h" | 10 #include "content/renderer/dom_storage/local_storage_cached_area.h" |
11 #include "third_party/WebKit/public/platform/WebStorageArea.h" | 11 #include "third_party/WebKit/public/platform/WebStorageArea.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 // There could be n instances of this class for the same origin in a renderer | 15 // There could be n instances of this class for the same origin in a renderer |
16 // process. It delegates to the one LocalStorageCachedArea instance in a process | 16 // process. It delegates to the one LocalStorageCachedArea instance in a process |
17 // for a given origin. | 17 // for a given origin. |
18 class LocalStorageArea : public blink::WebStorageArea { | 18 class LocalStorageArea : public blink::WebStorageArea { |
19 public: | 19 public: |
20 // |cached_area| outlives this object. | |
20 explicit LocalStorageArea(scoped_refptr<LocalStorageCachedArea> cached_area); | 21 explicit LocalStorageArea(scoped_refptr<LocalStorageCachedArea> cached_area); |
michaeln
2016/03/18 22:01:14
thnx
| |
21 ~LocalStorageArea() override; | 22 ~LocalStorageArea() override; |
22 | 23 |
23 // blink::WebStorageArea: | 24 // blink::WebStorageArea: |
24 unsigned length() override; | 25 unsigned length() override; |
25 blink::WebString key(unsigned index) override; | 26 blink::WebString key(unsigned index) override; |
26 blink::WebString getItem(const blink::WebString& key) override; | 27 blink::WebString getItem(const blink::WebString& key) override; |
27 void setItem(const blink::WebString& key, | 28 void setItem(const blink::WebString& key, |
28 const blink::WebString& value, | 29 const blink::WebString& value, |
29 const blink::WebURL& page_url, | 30 const blink::WebURL& page_url, |
30 WebStorageArea::Result& result) override; | 31 WebStorageArea::Result& result) override; |
31 void removeItem(const blink::WebString& key, | 32 void removeItem(const blink::WebString& key, |
32 const blink::WebURL& page_url) override; | 33 const blink::WebURL& page_url) override; |
33 void clear(const blink::WebURL& url) override; | 34 void clear(const blink::WebURL& url) override; |
34 | 35 |
36 const std::string& id() const { return id_; } | |
37 | |
35 private: | 38 private: |
36 scoped_refptr<LocalStorageCachedArea> cached_area_; | 39 scoped_refptr<LocalStorageCachedArea> cached_area_; |
40 // A globally unique identifier for this storage area. It's used to pass the | |
41 // source storage area, if any, in mutation events. | |
42 std::string id_; | |
37 | 43 |
38 DISALLOW_COPY_AND_ASSIGN(LocalStorageArea); | 44 DISALLOW_COPY_AND_ASSIGN(LocalStorageArea); |
39 }; | 45 }; |
40 | 46 |
41 } // namespace content | 47 } // namespace content |
42 | 48 |
43 #endif // CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_AREA_H_ | 49 #endif // CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_AREA_H_ |
OLD | NEW |