summaryrefslogtreecommitdiffstats
path: root/chrome/common/indexed_db_param_traits.cc
diff options
context:
space:
mode:
authorbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-09 18:56:05 +0000
committerbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-09 18:56:05 +0000
commit52ebf2b46daaddbc67e05d61f7dcee46625de5f0 (patch)
treeb127dffc687094c0f2b66028e4951955ffc3e60f /chrome/common/indexed_db_param_traits.cc
parent94109d47407c890229c77eee259aa5a6d429b4e6 (diff)
downloadchromium_src-52ebf2b46daaddbc67e05d61f7dcee46625de5f0.zip
chromium_src-52ebf2b46daaddbc67e05d61f7dcee46625de5f0.tar.gz
chromium_src-52ebf2b46daaddbc67e05d61f7dcee46625de5f0.tar.bz2
Removes indexed_db_param_traits.h depedencies on WebKit headers.
BUG=53317 TEST=No functional change, compiler/linker should be happy. Review URL: http://codereview.chromium.org/3297011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58971 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/indexed_db_param_traits.cc')
-rw-r--r--chrome/common/indexed_db_param_traits.cc96
1 files changed, 96 insertions, 0 deletions
diff --git a/chrome/common/indexed_db_param_traits.cc b/chrome/common/indexed_db_param_traits.cc
new file mode 100644
index 0000000..fd47ecf
--- /dev/null
+++ b/chrome/common/indexed_db_param_traits.cc
@@ -0,0 +1,96 @@
+// 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_param_traits.h"
+
+#include "chrome/common/indexed_db_key.h"
+#include "chrome/common/serialized_script_value.h"
+#include "ipc/ipc_message_utils.h"
+
+namespace IPC {
+
+void ParamTraits<SerializedScriptValue>::Write(Message* m,
+ const param_type& p) {
+ WriteParam(m, p.is_null());
+ WriteParam(m, p.is_invalid());
+ WriteParam(m, p.data());
+}
+
+bool ParamTraits<SerializedScriptValue>::Read(const Message* m,
+ void** iter,
+ param_type* r) {
+ bool is_null;
+ bool is_invalid;
+ string16 data;
+ bool ok =
+ ReadParam(m, iter, &is_null) &&
+ ReadParam(m, iter, &is_invalid) &&
+ ReadParam(m, iter, &data);
+ if (!ok)
+ return false;
+ r->set_is_null(is_null);
+ r->set_is_invalid(is_invalid);
+ r->set_data(data);
+ return true;
+}
+
+void ParamTraits<SerializedScriptValue>::Log(const param_type& p,
+ std::string* l) {
+ l->append("<SerializedScriptValue>(");
+ LogParam(p.is_null(), l);
+ l->append(", ");
+ LogParam(p.is_invalid(), l);
+ l->append(", ");
+ LogParam(p.data(), l);
+ l->append(")");
+}
+
+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.number());
+}
+
+bool ParamTraits<IndexedDBKey>::Read(const Message* m,
+ void** iter,
+ param_type* r) {
+ int type;
+ string16 string;
+ int32 number;
+ bool ok =
+ ReadParam(m, iter, &type) &&
+ ReadParam(m, iter, &string) &&
+ ReadParam(m, iter, &number);
+ if (!ok)
+ return false;
+ switch (type) {
+ case WebKit::WebIDBKey::NullType:
+ r->SetNull();
+ return true;
+ case WebKit::WebIDBKey::StringType:
+ r->Set(string);
+ return true;
+ case WebKit::WebIDBKey::NumberType:
+ r->Set(number);
+ return true;
+ case WebKit::WebIDBKey::InvalidType:
+ r->SetInvalid();
+ return true;
+ }
+ NOTREACHED();
+ return false;
+}
+
+void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) {
+ l->append("<IndexedDBKey>(");
+ LogParam(int(p.type()), l);
+ l->append(", ");
+ LogParam(p.string(), l);
+ l->append(", ");
+ LogParam(p.number(), l);
+ l->append(")");
+}
+
+} // namespace IPC