| 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 #include "content/renderer/dom_storage/local_storage_area.h" | 5 #include "content/renderer/dom_storage/local_storage_area.h" |
| 6 | 6 |
| 7 #include "content/common/storage_partition_service.mojom.h" | 7 #include "content/common/storage_partition_service.mojom.h" |
| 8 | 8 |
| 9 using blink::WebString; | 9 using blink::WebString; |
| 10 using blink::WebURL; | 10 using blink::WebURL; |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 LocalStorageArea::LocalStorageArea( | 14 LocalStorageArea::LocalStorageArea( |
| 15 const url::Origin& origin, | 15 const url::Origin& origin, |
| 16 StoragePartitionService* storage_partition_service) | 16 StoragePartitionService* storage_partition_service) |
| 17 : origin_(origin), binding_(this) { | 17 : loaded_(false), origin_(origin), binding_(this) { |
| 18 storage_partition_service->OpenLocalStorage( | 18 storage_partition_service->OpenLocalStorage( |
| 19 origin_.Serialize(), binding_.CreateInterfacePtrAndBind(), | 19 origin_.Serialize(), binding_.CreateInterfacePtrAndBind(), |
| 20 mojo::GetProxy(&leveldb_)); | 20 mojo::GetProxy(&leveldb_)); |
| 21 } | 21 } |
| 22 | 22 |
| 23 LocalStorageArea::~LocalStorageArea() { | 23 LocalStorageArea::~LocalStorageArea() { |
| 24 } | 24 } |
| 25 | 25 |
| 26 unsigned LocalStorageArea::length() { | 26 unsigned LocalStorageArea::length() { |
| 27 EnsureLoaded(); |
| 27 return 0u; | 28 return 0u; |
| 28 } | 29 } |
| 29 | 30 |
| 30 WebString LocalStorageArea::key(unsigned index) { | 31 WebString LocalStorageArea::key(unsigned index) { |
| 32 EnsureLoaded(); |
| 31 return WebString(); | 33 return WebString(); |
| 32 } | 34 } |
| 33 | 35 |
| 34 WebString LocalStorageArea::getItem(const WebString& key) { | 36 WebString LocalStorageArea::getItem(const WebString& key) { |
| 37 EnsureLoaded(); |
| 35 return WebString(); | 38 return WebString(); |
| 36 } | 39 } |
| 37 | 40 |
| 38 void LocalStorageArea::setItem( | 41 void LocalStorageArea::setItem( |
| 39 const WebString& key, const WebString& value, const WebURL& page_url, | 42 const WebString& key, const WebString& value, const WebURL& page_url, |
| 40 WebStorageArea::Result& result) { | 43 WebStorageArea::Result& result) { |
| 44 EnsureLoaded(); |
| 41 } | 45 } |
| 42 | 46 |
| 43 void LocalStorageArea::removeItem( | 47 void LocalStorageArea::removeItem( |
| 44 const WebString& key, const WebURL& page_url) { | 48 const WebString& key, const WebURL& page_url) { |
| 49 EnsureLoaded(); |
| 45 } | 50 } |
| 46 | 51 |
| 47 void LocalStorageArea::clear(const WebURL& page_url) { | 52 void LocalStorageArea::clear(const WebURL& page_url) { |
| 53 // No need to prime the cache in this case. |
| 48 } | 54 } |
| 49 | 55 |
| 50 size_t LocalStorageArea::memoryBytesUsedByCache() const { | 56 size_t LocalStorageArea::memoryBytesUsedByCache() const { |
| 51 return 0u; | 57 return 0u; |
| 52 } | 58 } |
| 53 | 59 |
| 54 void LocalStorageArea::KeyChanged(mojo::Array<uint8_t> key, | 60 void LocalStorageArea::KeyChanged(mojo::Array<uint8_t> key, |
| 55 mojo::Array<uint8_t> new_value, | 61 mojo::Array<uint8_t> new_value, |
| 56 mojo::Array<uint8_t> old_value, | 62 mojo::Array<uint8_t> old_value, |
| 57 const mojo::String& source) { | 63 const mojo::String& source) { |
| 58 } | 64 } |
| 59 | 65 |
| 60 void LocalStorageArea::KeyDeleted(mojo::Array<uint8_t> key, | 66 void LocalStorageArea::KeyDeleted(mojo::Array<uint8_t> key, |
| 61 const mojo::String& source) { | 67 const mojo::String& source) { |
| 62 } | 68 } |
| 63 | 69 |
| 64 void LocalStorageArea::AllDeleted(const mojo::String& source) { | 70 void LocalStorageArea::AllDeleted(const mojo::String& source) { |
| 65 } | 71 } |
| 66 | 72 |
| 73 void LocalStorageArea::EnsureLoaded() { |
| 74 if (loaded_) |
| 75 return; |
| 76 |
| 77 loaded_ = true; |
| 78 leveldb::DatabaseError status = leveldb::DatabaseError::OK; |
| 79 mojo::Array<content::KeyValuePtr> data; |
| 80 leveldb_->GetAll(&status, &data); |
| 81 } |
| 82 |
| 67 } // namespace content | 83 } // namespace content |
| OLD | NEW |