diff options
author | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-11 04:16:43 +0000 |
---|---|---|
committer | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-11 04:16:43 +0000 |
commit | 99ddfd29900cc4caa1f1ffd979cc09be3f104336 (patch) | |
tree | dd3987a5578e15a27340a43c32027099050cfb8d /chrome | |
parent | 9c5645b5f8af3c04528caef61c59e2754f79288b (diff) | |
download | chromium_src-99ddfd29900cc4caa1f1ffd979cc09be3f104336.zip chromium_src-99ddfd29900cc4caa1f1ffd979cc09be3f104336.tar.gz chromium_src-99ddfd29900cc4caa1f1ffd979cc09be3f104336.tar.bz2 |
The spec for ____storage.key() changed. Now, instead of raising an exception when you try to access a key
at an index that's greater than or equal to ___Storage.length, it simply returns a null.
This is yet another demonstration of why we need a NullableString16 (rather than passing around a string and
a bool) but this cannot block on that work.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/165289
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23011 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
4 files changed, 10 insertions, 10 deletions
diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc index 5a7c169..d6aff32 100644 --- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc +++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc @@ -261,11 +261,11 @@ void DOMStorageDispatcherHost::OnKey(int64 storage_area_id, unsigned index, } DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); - bool key_exception = false; WebStorageArea* storage_area = GetStorageArea(storage_area_id); CHECK(storage_area); // TODO(jorlow): Do better than this. - string16 key = storage_area->key(index, key_exception); - ViewHostMsg_DOMStorageKey::WriteReplyParams(reply_msg, key_exception, key); + WebString key = storage_area->key(index); + ViewHostMsg_DOMStorageKey::WriteReplyParams(reply_msg, (string16)key, + key.isNull()); Send(reply_msg); } diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 22cd1c0..d831654 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -1575,8 +1575,8 @@ IPC_BEGIN_MESSAGES(ViewHost) IPC_SYNC_MESSAGE_CONTROL2_2(ViewHostMsg_DOMStorageKey, int64 /* storage_area_id */, unsigned /* index */, - bool /* key_exception */, - string16 /* key */) + string16 /* key */, + bool /* key_is_null */) // Get a value based on a key from a storage area. // TODO(jorlow): Convert value + value_is_null over to a NullableString16 diff --git a/chrome/renderer/renderer_webstoragearea_impl.cc b/chrome/renderer/renderer_webstoragearea_impl.cc index c438cdfe..14f2273 100644 --- a/chrome/renderer/renderer_webstoragearea_impl.cc +++ b/chrome/renderer/renderer_webstoragearea_impl.cc @@ -45,18 +45,18 @@ unsigned RendererWebStorageAreaImpl::length() { return length; } -WebKit::WebString RendererWebStorageAreaImpl::key(unsigned index, - bool& key_exception) { +WebKit::WebString RendererWebStorageAreaImpl::key(unsigned index) { EnsureInitializedAndLocked(); // Right now this is always sync. We may want to optimize this by fetching // chunks of keys rather than single keys (and flushing the cache on every // mutation of the storage area) since this will most often be used to fetch // all the keys at once. string16 key; + bool key_is_null; RenderThread::current()->Send( new ViewHostMsg_DOMStorageKey(storage_area_id_, index, - &key_exception, &key)); - return key; + &key, &key_is_null)); + return key_is_null ? WebKit::WebString() : WebKit::WebString(key); } WebKit::WebString RendererWebStorageAreaImpl::getItem( diff --git a/chrome/renderer/renderer_webstoragearea_impl.h b/chrome/renderer/renderer_webstoragearea_impl.h index 0a313c2..0b734e8 100644 --- a/chrome/renderer/renderer_webstoragearea_impl.h +++ b/chrome/renderer/renderer_webstoragearea_impl.h @@ -21,7 +21,7 @@ class RendererWebStorageAreaImpl : public WebKit::WebStorageArea { virtual void lock(bool& invalidate_cache, size_t& bytes_left_in_quota); virtual void unlock(); virtual unsigned length(); - virtual WebKit::WebString key(unsigned index, bool& key_exception); + virtual WebKit::WebString key(unsigned index); virtual WebKit::WebString getItem(const WebKit::WebString& key); virtual void setItem(const WebKit::WebString& key, const WebKit::WebString& value, |