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

Unified Diff: content/child/indexed_db/indexed_db_key_builders.cc

Issue 2586483002: Use explicit WebString <-> string16 conversion methods in storage API files (Closed)
Patch Set: '' Created 4 years 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
Index: content/child/indexed_db/indexed_db_key_builders.cc
diff --git a/content/child/indexed_db/indexed_db_key_builders.cc b/content/child/indexed_db/indexed_db_key_builders.cc
index d0da139c1859b3dfaf669765617fa6a505b4532b..6000df88a536158d0a504a588af42df2bbc028cc 100644
--- a/content/child/indexed_db/indexed_db_key_builders.cc
+++ b/content/child/indexed_db/indexed_db_key_builders.cc
@@ -40,11 +40,10 @@ static std::vector<base::string16> CopyArray(
const WebVector<WebString>& array) {
std::vector<base::string16> copy(array.size());
for (size_t i = 0; i < array.size(); ++i)
- copy[i] = array[i];
+ copy[i] = array[i].utf16();
return copy;
}
-
namespace content {
IndexedDBKey IndexedDBKeyBuilder::Build(const blink::WebIDBKey& key) {
@@ -55,7 +54,7 @@ IndexedDBKey IndexedDBKeyBuilder::Build(const blink::WebIDBKey& key) {
return IndexedDBKey(
std::string(key.binary().data(), key.binary().size()));
case WebIDBKeyTypeString:
- return IndexedDBKey(key.string());
+ return IndexedDBKey(key.string().utf16());
case WebIDBKeyTypeDate:
return IndexedDBKey(key.date(), WebIDBKeyTypeDate);
case WebIDBKeyTypeNumber:
@@ -83,7 +82,7 @@ WebIDBKey WebIDBKeyBuilder::Build(const IndexedDBKey& key) {
case WebIDBKeyTypeBinary:
return WebIDBKey::createBinary(key.binary());
case WebIDBKeyTypeString:
- return WebIDBKey::createString(key.string());
+ return WebIDBKey::createString(WebString::fromUTF16(key.string()));
case WebIDBKeyTypeDate:
return WebIDBKey::createDate(key.date());
case WebIDBKeyTypeNumber:
@@ -119,7 +118,7 @@ IndexedDBKeyPath IndexedDBKeyPathBuilder::Build(
const blink::WebIDBKeyPath& key_path) {
switch (key_path.keyPathType()) {
case blink::WebIDBKeyPathTypeString:
- return IndexedDBKeyPath(key_path.string());
+ return IndexedDBKeyPath(key_path.string().utf16());
case blink::WebIDBKeyPathTypeArray:
return IndexedDBKeyPath(CopyArray(key_path.array()));
case blink::WebIDBKeyPathTypeNull:
@@ -134,9 +133,17 @@ blink::WebIDBKeyPath WebIDBKeyPathBuilder::Build(
const IndexedDBKeyPath& key_path) {
switch (key_path.type()) {
case blink::WebIDBKeyPathTypeString:
- return blink::WebIDBKeyPath::create(WebString(key_path.string()));
- case blink::WebIDBKeyPathTypeArray:
- return blink::WebIDBKeyPath::create(CopyArray(key_path.array()));
+ return blink::WebIDBKeyPath::create(
+ WebString::fromUTF16(key_path.string()));
+ case blink::WebIDBKeyPathTypeArray: {
+ WebVector<WebString> key_path_vector(key_path.array().size());
+ std::transform(key_path.array().begin(), key_path.array().end(),
+ key_path_vector.begin(),
+ [](const typename base::string16& s) {
+ return WebString::fromUTF16(s);
+ });
+ return blink::WebIDBKeyPath::create(key_path_vector);
+ }
case blink::WebIDBKeyPathTypeNull:
return blink::WebIDBKeyPath::createNull();
default:
« no previous file with comments | « content/child/indexed_db/indexed_db_database_callbacks_impl.cc ('k') | content/child/indexed_db/webidbdatabase_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698