diff options
author | jsbell@chromium.org <jsbell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-09 17:48:38 +0000 |
---|---|---|
committer | jsbell@chromium.org <jsbell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-09 17:48:38 +0000 |
commit | e40aab96ddec63ff5d3b02ebda75941fb8982576 (patch) | |
tree | f442124e97a551d0b9ff01f548204efbb525d895 /content | |
parent | 5895fcdadaca9808c23cd9333441dd2ed11d2192 (diff) | |
download | chromium_src-e40aab96ddec63ff5d3b02ebda75941fb8982576.zip chromium_src-e40aab96ddec63ff5d3b02ebda75941fb8982576.tar.gz chromium_src-e40aab96ddec63ff5d3b02ebda75941fb8982576.tar.bz2 |
IndexedDB: IPC support for compound (array) keys
WebKit side is: https://bugs.webkit.org/show_bug.cgi?id=62284
BUG=92038
Review URL: http://codereview.chromium.org/8417055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109266 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/in_process_webkit/indexed_db_browsertest.cc | 4 | ||||
-rw-r--r-- | content/common/indexed_db_key.cc | 15 | ||||
-rw-r--r-- | content/common/indexed_db_key.h | 5 | ||||
-rw-r--r-- | content/common/indexed_db_param_traits.cc | 78 |
4 files changed, 80 insertions, 22 deletions
diff --git a/content/browser/in_process_webkit/indexed_db_browsertest.cc b/content/browser/in_process_webkit/indexed_db_browsertest.cc index d7e3433..4a30039 100644 --- a/content/browser/in_process_webkit/indexed_db_browsertest.cc +++ b/content/browser/in_process_webkit/indexed_db_browsertest.cc @@ -83,6 +83,10 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, TransactionGetTest) { SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("transaction_get_test.html")))); } +IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, KeyTypesTest) { + SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("key_types_test.html")))); +} + // Flaky: http://crbug.com/70773 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, DISABLED_ObjectStoreTest) { SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("object_store_test.html")))); diff --git a/content/common/indexed_db_key.cc b/content/common/indexed_db_key.cc index 6a97d08..44cb81a 100644 --- a/content/common/indexed_db_key.cc +++ b/content/common/indexed_db_key.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" using WebKit::WebIDBKey; @@ -26,6 +27,11 @@ void IndexedDBKey::SetInvalid() { type_ = WebIDBKey::InvalidType; } +void IndexedDBKey::SetArray(const std::vector<IndexedDBKey>& array) { + type_ = WebIDBKey::ArrayType; + array_ = array; +} + void IndexedDBKey::SetString(const string16& string) { type_ = WebIDBKey::StringType; string_ = string; @@ -43,6 +49,12 @@ void IndexedDBKey::SetNumber(double number) { void IndexedDBKey::Set(const WebIDBKey& key) { type_ = key.type(); + array_.clear(); + if (key.type() == WebIDBKey::ArrayType) { + for (size_t i = 0; i < key.array().size(); ++i) { + array_.push_back(IndexedDBKey(key.array()[i])); + } + } string_ = key.type() == WebIDBKey::StringType ? static_cast<string16>(key.string()) : string16(); number_ = key.type() == WebIDBKey::NumberType ? key.number() : 0; @@ -51,6 +63,8 @@ void IndexedDBKey::Set(const WebIDBKey& key) { IndexedDBKey::operator WebIDBKey() const { switch (type_) { + case WebIDBKey::ArrayType: + return WebIDBKey::createArray(array_); case WebIDBKey::StringType: return WebIDBKey::createString(string_); case WebIDBKey::DateType: @@ -58,7 +72,6 @@ IndexedDBKey::operator WebIDBKey() const { case WebIDBKey::NumberType: return WebIDBKey::createNumber(number_); case WebIDBKey::InvalidType: - default: // TODO(jsbell): Remove after WebIDBKey::ArrayType added. return WebIDBKey::createInvalid(); } NOTREACHED(); diff --git a/content/common/indexed_db_key.h b/content/common/indexed_db_key.h index 808aaa8..93daf7c 100644 --- a/content/common/indexed_db_key.h +++ b/content/common/indexed_db_key.h @@ -6,6 +6,8 @@ #define CONTENT_COMMON_INDEXED_DB_KEY_H_ #pragma once +#include <vector> + #include "base/basictypes.h" #include "base/string16.h" #include "content/common/content_export.h" @@ -18,12 +20,14 @@ class CONTENT_EXPORT IndexedDBKey { ~IndexedDBKey(); void SetInvalid(); + void SetArray(const std::vector<IndexedDBKey>& array); void SetString(const string16& string); void SetDate(double date); void SetNumber(double number); void Set(const WebKit::WebIDBKey& key); WebKit::WebIDBKey::Type type() const { return type_; } + const std::vector<IndexedDBKey>& array() const { return array_; } const string16& string() const { return string_; } double date() const { return date_; } double number() const { return number_; } @@ -32,6 +36,7 @@ class CONTENT_EXPORT IndexedDBKey { private: WebKit::WebIDBKey::Type type_; + std::vector<IndexedDBKey> array_; string16 string_; double date_; double number_; diff --git a/content/common/indexed_db_param_traits.cc b/content/common/indexed_db_param_traits.cc index 7aa7ec9..5c3eb95 100644 --- a/content/common/indexed_db_param_traits.cc +++ b/content/common/indexed_db_param_traits.cc @@ -48,39 +48,66 @@ void ParamTraits<content::SerializedScriptValue>::Log(const param_type& p, void ParamTraits<IndexedDBKey>::Write(Message* m, const param_type& p) { WriteParam(m, int(p.type())); - // TODO(jorlow): Technically, we only need to pack the type being used. - WriteParam(m, p.string()); - WriteParam(m, p.date()); - WriteParam(m, p.number()); + switch (p.type()) { + case WebKit::WebIDBKey::ArrayType: + WriteParam(m, p.array()); + return; + case WebKit::WebIDBKey::StringType: + WriteParam(m, p.string()); + return; + case WebKit::WebIDBKey::DateType: + WriteParam(m, p.date()); + return; + case WebKit::WebIDBKey::NumberType: + WriteParam(m, p.number()); + return; + case WebKit::WebIDBKey::InvalidType: + return; + } + NOTREACHED(); } bool ParamTraits<IndexedDBKey>::Read(const Message* m, void** iter, param_type* r) { int type; - string16 string; - double date; - double number; - bool ok = - ReadParam(m, iter, &type) && - ReadParam(m, iter, &string) && - ReadParam(m, iter, &date) && - ReadParam(m, iter, &number); - - if (!ok) + if (!ReadParam(m, iter, &type)) return false; + switch (type) { + case WebKit::WebIDBKey::ArrayType: + { + std::vector<IndexedDBKey> array; + if (!ReadParam(m, iter, &array)) + return false; + r->SetArray(array); + return true; + } case WebKit::WebIDBKey::StringType: - r->SetString(string); - return true; + { + string16 string; + if (!ReadParam(m, iter, &string)) + return false; + r->SetString(string); + return true; + } case WebKit::WebIDBKey::DateType: - r->SetDate(date); - return true; + { + double date; + if (!ReadParam(m, iter, &date)) + return false; + r->SetDate(date); + return true; + } case WebKit::WebIDBKey::NumberType: - r->SetNumber(number); - return true; + { + double number; + if (!ReadParam(m, iter, &number)) + return false; + r->SetNumber(number); + return true; + } case WebKit::WebIDBKey::InvalidType: - default: // TODO(jsbell): Remove after WebIDBKey::ArrayType added. r->SetInvalid(); return true; } @@ -92,6 +119,15 @@ void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) { l->append("<IndexedDBKey>("); LogParam(int(p.type()), l); l->append(", "); + l->append("["); + std::vector<IndexedDBKey>::const_iterator it = p.array().begin(); + while (it != p.array().end()) { + Log(*it, l); + ++it; + if (it != p.array().end()) + l->append(", "); + } + l->append("], "); LogParam(p.string(), l); l->append(", "); LogParam(p.date(), l); |