| 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 "base/rand_util.h" | 7 #include "base/rand_util.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "third_party/WebKit/public/platform/WebURL.h" | 9 #include "third_party/WebKit/public/platform/WebURL.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 LocalStorageArea::~LocalStorageArea() { | 23 LocalStorageArea::~LocalStorageArea() { |
| 24 cached_area_->AreaDestroyed(this); | 24 cached_area_->AreaDestroyed(this); |
| 25 } | 25 } |
| 26 | 26 |
| 27 unsigned LocalStorageArea::length() { | 27 unsigned LocalStorageArea::length() { |
| 28 return cached_area_->GetLength(); | 28 return cached_area_->GetLength(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 WebString LocalStorageArea::key(unsigned index) { | 31 WebString LocalStorageArea::key(unsigned index) { |
| 32 return cached_area_->GetKey(index); | 32 return WebString::fromUTF16(cached_area_->GetKey(index)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 WebString LocalStorageArea::getItem(const WebString& key) { | 35 WebString LocalStorageArea::getItem(const WebString& key) { |
| 36 return cached_area_->GetItem(key); | 36 return WebString::fromUTF16(cached_area_->GetItem(key.utf16())); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void LocalStorageArea::setItem( | 39 void LocalStorageArea::setItem( |
| 40 const WebString& key, const WebString& value, const WebURL& page_url, | 40 const WebString& key, const WebString& value, const WebURL& page_url, |
| 41 WebStorageArea::Result& result) { | 41 WebStorageArea::Result& result) { |
| 42 if (!cached_area_->SetItem(key, value, page_url, id_)) | 42 if (!cached_area_->SetItem(key.utf16(), value.utf16(), page_url, id_)) |
| 43 result = ResultBlockedByQuota; | 43 result = ResultBlockedByQuota; |
| 44 else | 44 else |
| 45 result = ResultOK; | 45 result = ResultOK; |
| 46 } | 46 } |
| 47 | 47 |
| 48 void LocalStorageArea::removeItem( | 48 void LocalStorageArea::removeItem( |
| 49 const WebString& key, const WebURL& page_url) { | 49 const WebString& key, const WebURL& page_url) { |
| 50 cached_area_->RemoveItem(key, page_url, id_); | 50 cached_area_->RemoveItem(key.utf16(), page_url, id_); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void LocalStorageArea::clear(const WebURL& page_url) { | 53 void LocalStorageArea::clear(const WebURL& page_url) { |
| 54 cached_area_->Clear(page_url, id_); | 54 cached_area_->Clear(page_url, id_); |
| 55 } | 55 } |
| 56 | 56 |
| 57 } // namespace content | 57 } // namespace content |
| OLD | NEW |