From 15bf871f530cc5527db8a077e41dea8ea51bf31f Mon Sep 17 00:00:00 2001 From: "jorlow@chromium.org" Date: Thu, 27 Aug 2009 00:55:02 +0000 Subject: Add a nullable string16 class to base. It combines a string16 + a null param in order to cover all the possible states of a WebKit string. For strings where the null state is not meaninfully different from the empty state, this class should NOT be used. There are, however, some cases where we do need to track null. LocalStorage is an example. This class should be a fairly light weight way to do so. This change also adds implicit conversion to and from WebStrings. This also switches LocalStorage's IPCs over to using this new class. BUG=17343 TEST=none Review URL: http://codereview.chromium.org/174484 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24574 0039d316-1c4b-4281-b951-d872f2087c98 --- .../browser/in_process_webkit/dom_storage_dispatcher_host.cc | 12 +++++------- .../browser/in_process_webkit/dom_storage_dispatcher_host.h | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'chrome/browser/in_process_webkit') 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 d6aff32..abded7c 100644 --- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc +++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc @@ -4,8 +4,8 @@ #include "chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h" +#include "base/nullable_string16.h" #include "base/stl_util-inl.h" -#include "base/string16.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/in_process_webkit/webkit_thread.h" @@ -263,9 +263,8 @@ void DOMStorageDispatcherHost::OnKey(int64 storage_area_id, unsigned index, DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); WebStorageArea* storage_area = GetStorageArea(storage_area_id); CHECK(storage_area); // TODO(jorlow): Do better than this. - WebString key = storage_area->key(index); - ViewHostMsg_DOMStorageKey::WriteReplyParams(reply_msg, (string16)key, - key.isNull()); + const NullableString16& key = storage_area->key(index); + ViewHostMsg_DOMStorageKey::WriteReplyParams(reply_msg, key); Send(reply_msg); } @@ -284,9 +283,8 @@ void DOMStorageDispatcherHost::OnGetItem(int64 storage_area_id, DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); WebStorageArea* storage_area = GetStorageArea(storage_area_id); CHECK(storage_area); // TODO(jorlow): Do better than this. - WebString value = storage_area->getItem(key); - ViewHostMsg_DOMStorageGetItem::WriteReplyParams(reply_msg, (string16)value, - value.isNull()); + const NullableString16& value = storage_area->getItem(key); + ViewHostMsg_DOMStorageGetItem::WriteReplyParams(reply_msg, value); Send(reply_msg); } diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h index 38fee15..c9a6039 100644 --- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h +++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h @@ -6,8 +6,8 @@ #define CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_DISPATCHER_HOST_H_ #include "base/hash_tables.h" -#include "base/scoped_ptr.h" #include "base/ref_counted.h" +#include "base/scoped_ptr.h" #include "ipc/ipc_message.h" class WebKitContext; -- cgit v1.1