Chromium Code Reviews| 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 "content/common/leveldb_wrapper.mojom.h" | 9 #include "content/common/leveldb_wrapper.mojom.h" |
| 10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
| 11 #include "third_party/WebKit/public/platform/WebStorageArea.h" | 11 #include "third_party/WebKit/public/platform/WebStorageArea.h" |
| 12 #include "url/origin.h" | 12 #include "url/origin.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 class StoragePartitionService; | 15 class StoragePartitionService; |
| 16 | 16 |
| 17 // Maintains a complete cache of the origin's Map of key/value pairs for fast | 17 // Maintains a complete cache of the origin's Map of key/value pairs for fast |
| 18 // access. The cache is primed on first access and changes are written to the | 18 // access. The cache is primed on first access and changes are written to the |
| 19 // backend through the level db interface pointer. Mutations originating in | 19 // backend through the level db interface pointer. Mutations originating in |
| 20 // other processes are applied to the cache via the ApplyMutation method. | 20 // other processes are applied to the cache via the ApplyMutation method. |
| 21 class LocalStorageArea : public blink::WebStorageArea, | 21 class LocalStorageArea : public blink::WebStorageArea, |
|
michaeln
2016/02/26 22:21:44
The [Sycn] attribute looks good, i'm not sure of t
jam
2016/02/29 23:47:47
ah, I missed that there are multiple blink::WebSto
| |
| 22 public LevelDBObserver { | 22 public LevelDBObserver { |
| 23 public: | 23 public: |
| 24 LocalStorageArea(const url::Origin& origin, | 24 LocalStorageArea(const url::Origin& origin, |
| 25 StoragePartitionService* storage_partition_service); | 25 StoragePartitionService* storage_partition_service); |
| 26 ~LocalStorageArea() override; | 26 ~LocalStorageArea() override; |
| 27 | 27 |
| 28 // blink::WebStorageArea.h: | 28 // blink::WebStorageArea.h: |
| 29 unsigned length() override; | 29 unsigned length() override; |
| 30 blink::WebString key(unsigned index) override; | 30 blink::WebString key(unsigned index) override; |
| 31 blink::WebString getItem(const blink::WebString& key) override; | 31 blink::WebString getItem(const blink::WebString& key) override; |
| 32 void setItem(const blink::WebString& key, | 32 void setItem(const blink::WebString& key, |
| 33 const blink::WebString& value, | 33 const blink::WebString& value, |
| 34 const blink::WebURL& page_url, | 34 const blink::WebURL& page_url, |
| 35 WebStorageArea::Result& result) override; | 35 WebStorageArea::Result& result) override; |
| 36 void removeItem(const blink::WebString& key, | 36 void removeItem(const blink::WebString& key, |
| 37 const blink::WebURL& page_url) override; | 37 const blink::WebURL& page_url) override; |
| 38 void clear(const blink::WebURL& url) override; | 38 void clear(const blink::WebURL& url) override; |
| 39 size_t memoryBytesUsedByCache() const override; | 39 size_t memoryBytesUsedByCache() const override; |
| 40 | 40 |
| 41 // LevelDBObserver: | 41 // LevelDBObserver: |
| 42 void KeyChanged(mojo::Array<uint8_t> key, | 42 void KeyChanged(mojo::Array<uint8_t> key, |
| 43 mojo::Array<uint8_t> new_value, | 43 mojo::Array<uint8_t> new_value, |
| 44 mojo::Array<uint8_t> old_value, | 44 mojo::Array<uint8_t> old_value, |
| 45 const mojo::String& source) override; | 45 const mojo::String& source) override; |
| 46 void KeyDeleted(mojo::Array<uint8_t> key, | 46 void KeyDeleted(mojo::Array<uint8_t> key, |
| 47 const mojo::String& source) override; | 47 const mojo::String& source) override; |
| 48 void AllDeleted(const mojo::String& source) override; | 48 void AllDeleted(const mojo::String& source) override; |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 // Synchronously fetches the origin's local storage data if it hasn't been | |
| 52 // fetched already. | |
| 53 void EnsureLoaded(); | |
| 54 | |
| 55 bool loaded_; | |
| 51 url::Origin origin_; | 56 url::Origin origin_; |
| 52 LevelDBWrapperPtr leveldb_; | 57 LevelDBWrapperPtr leveldb_; |
| 53 mojo::Binding<LevelDBObserver> binding_; | 58 mojo::Binding<LevelDBObserver> binding_; |
| 54 | 59 |
| 55 DISALLOW_COPY_AND_ASSIGN(LocalStorageArea); | 60 DISALLOW_COPY_AND_ASSIGN(LocalStorageArea); |
| 56 }; | 61 }; |
| 57 | 62 |
| 58 } // namespace content | 63 } // namespace content |
| 59 | 64 |
| 60 #endif // CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_AREA_H_ | 65 #endif // CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_AREA_H_ |
| OLD | NEW |