summaryrefslogtreecommitdiffstats
path: root/chrome/common/indexed_db_key.cc
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-14 14:29:40 +0000
committerjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-14 14:29:40 +0000
commit5c71640cdf15c2782b8331e9e2623da50ec5d102 (patch)
treeda7cf7505bb23c3e206bdcaab66f064d3edc5936 /chrome/common/indexed_db_key.cc
parent699f2246bf56e1aadf31e1edd6c5aef9b4b39638 (diff)
downloadchromium_src-5c71640cdf15c2782b8331e9e2623da50ec5d102.zip
chromium_src-5c71640cdf15c2782b8331e9e2623da50ec5d102.tar.gz
chromium_src-5c71640cdf15c2782b8331e9e2623da50ec5d102.tar.bz2
The Chrome half of implementing get/put/remove for object stores (https://bugs.webkit.org/show_bug.cgi?id=41250).
TEST=none BUG=none Review URL: http://codereview.chromium.org/2830030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52313 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/indexed_db_key.cc')
-rw-r--r--chrome/common/indexed_db_key.cc54
1 files changed, 54 insertions, 0 deletions
diff --git a/chrome/common/indexed_db_key.cc b/chrome/common/indexed_db_key.cc
new file mode 100644
index 0000000..1c09ea2
--- /dev/null
+++ b/chrome/common/indexed_db_key.cc
@@ -0,0 +1,54 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/indexed_db_key.h"
+
+#include "base/logging.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
+
+using WebKit::WebIDBKey;
+
+IndexedDBKey::IndexedDBKey()
+ : type_(WebIDBKey::InvalidType) {
+}
+
+IndexedDBKey::IndexedDBKey(const WebIDBKey& key)
+ : type_(key.type()),
+ string_(key.type() == WebIDBKey::StringType
+ ? static_cast<string16>(key.string()) : string16()),
+ number_(key.type() == WebIDBKey::NumberType ? key.number() : 0) {
+}
+
+void IndexedDBKey::SetNull() {
+ type_ = WebIDBKey::NullType;
+}
+
+void IndexedDBKey::SetInvalid() {
+ type_ = WebIDBKey::InvalidType;
+}
+
+void IndexedDBKey::Set(const string16& string) {
+ type_ = WebIDBKey::StringType;
+ string_ = string;
+}
+
+void IndexedDBKey::Set(int32_t number) {
+ type_ = WebIDBKey::NumberType;
+ number_ = number;
+}
+
+IndexedDBKey::operator WebIDBKey() const {
+ switch (type_) {
+ case WebIDBKey::NullType:
+ return WebIDBKey::createNull();
+ case WebIDBKey::StringType:
+ return WebIDBKey(string_);
+ case WebIDBKey::NumberType:
+ return WebIDBKey(number_);
+ case WebIDBKey::InvalidType:
+ return WebIDBKey::createInvalid();
+ }
+ NOTREACHED();
+ return WebIDBKey::createInvalid();
+}