Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(749)

Unified Diff: chrome/renderer/renderer_webstoragearea_impl.cc

Issue 174484: Add a nullable string16 class to base. It combines a string16 + a null param... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/render_messages_internal.h ('k') | ipc/ipc_message_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/renderer_webstoragearea_impl.cc
===================================================================
--- chrome/renderer/renderer_webstoragearea_impl.cc (revision 24540)
+++ chrome/renderer/renderer_webstoragearea_impl.cc (working copy)
@@ -8,9 +8,11 @@
#include "chrome/renderer/render_thread.h"
#include "webkit/api/public/WebString.h"
+using WebKit::WebString;
+
RendererWebStorageAreaImpl::RendererWebStorageAreaImpl(
int64 namespace_id,
- const WebKit::WebString& origin)
+ const WebString& origin)
: namespace_id_(namespace_id),
origin_(origin),
storage_area_id_(kUninitializedStorageAreaId),
@@ -45,22 +47,19 @@
return length;
}
-WebKit::WebString RendererWebStorageAreaImpl::key(unsigned index) {
+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;
+ NullableString16 key;
RenderThread::current()->Send(
- new ViewHostMsg_DOMStorageKey(storage_area_id_, index,
- &key, &key_is_null));
- return key_is_null ? WebKit::WebString() : WebKit::WebString(key);
+ new ViewHostMsg_DOMStorageKey(storage_area_id_, index, &key));
+ return key;
}
-WebKit::WebString RendererWebStorageAreaImpl::getItem(
- const WebKit::WebString& webkit_key) {
+WebString RendererWebStorageAreaImpl::getItem(const WebString& webkit_key) {
EnsureInitializedAndLocked();
string16 key = webkit_key;
@@ -69,23 +68,20 @@
if (iterator != cached_items_.end())
return iterator->second;
if (cached_invalid_items_.find(key) != cached_invalid_items_.end())
- return WebKit::WebString(); // Return a "null" string.
+ return WebString(); // Return a "null" string.
// The item is not in the cache, so we must do a sync IPC. Afterwards,
// add it to the cache.
- string16 raw_value;
- bool value_is_null;
+ NullableString16 raw_value;
RenderThread::current()->Send(
- new ViewHostMsg_DOMStorageGetItem(storage_area_id_, key,
- &raw_value, &value_is_null));
- WebKit::WebString value = value_is_null ? WebKit::WebString()
- : WebKit::WebString(raw_value);
+ new ViewHostMsg_DOMStorageGetItem(storage_area_id_, key, &raw_value));
+ WebString value = raw_value; // Only do the conversion once.
SetCache(key, value);
return value;
}
-void RendererWebStorageAreaImpl::setItem(const WebKit::WebString& key,
- const WebKit::WebString& value,
+void RendererWebStorageAreaImpl::setItem(const WebString& key,
+ const WebString& value,
bool& quota_exception) {
EnsureInitializedAndLocked();
quota_exception = !UpdateQuota(key, value);
@@ -96,13 +92,13 @@
SetCache(key, value);
}
-void RendererWebStorageAreaImpl::removeItem(const WebKit::WebString& key) {
+void RendererWebStorageAreaImpl::removeItem(const WebString& key) {
EnsureInitializedAndLocked();
- bool update_succeeded = UpdateQuota(key, WebKit::WebString());
+ bool update_succeeded = UpdateQuota(key, WebString());
DCHECK(update_succeeded);
RenderThread::current()->Send(
new ViewHostMsg_DOMStorageRemoveItem(storage_area_id_, key));
- SetCache(key, WebKit::WebString());
+ SetCache(key, WebString());
}
void RendererWebStorageAreaImpl::clear() {
@@ -137,8 +133,8 @@
}
}
-bool RendererWebStorageAreaImpl::UpdateQuota(const WebKit::WebString& key,
- const WebKit::WebString& value) {
+bool RendererWebStorageAreaImpl::UpdateQuota(const WebString& key,
+ const WebString& value) {
// TODO(jorlow): Remove once the bytes_left_in_quota values we're getting
// are accurate.
return true;
@@ -160,7 +156,7 @@
}
void RendererWebStorageAreaImpl::SetCache(const string16& key,
- const WebKit::WebString& value) {
+ const WebString& value) {
cached_items_.erase(key);
cached_invalid_items_.erase(key);
« no previous file with comments | « chrome/common/render_messages_internal.h ('k') | ipc/ipc_message_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698