diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-06 18:15:58 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-06 18:15:58 +0000 |
commit | e4dad9fbf5a48cb65d085e49c8f7917c8f31300b (patch) | |
tree | 3df910ad37afd8d633f16cc47d0f4b46f6647fbf /ipc/ipc_message_utils.cc | |
parent | 2a3e3c054891c865540524beb4af96ec68c481ba (diff) | |
download | chromium_src-e4dad9fbf5a48cb65d085e49c8f7917c8f31300b.zip chromium_src-e4dad9fbf5a48cb65d085e49c8f7917c8f31300b.tar.gz chromium_src-e4dad9fbf5a48cb65d085e49c8f7917c8f31300b.tar.bz2 |
Modify extension request IPC messages to pass a ListValue instead of a string.
This allows us to pass binary values through extension requests. I use this in
my next CL to pass SkBitmaps.
BUG=23269
TEST=no
Review URL: http://codereview.chromium.org/251093
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28130 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_message_utils.cc')
-rw-r--r-- | ipc/ipc_message_utils.cc | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc index ac188bf..06408b4 100644 --- a/ipc/ipc_message_utils.cc +++ b/ipc/ipc_message_utils.cc @@ -27,36 +27,38 @@ static void WriteValue(Message* m, const Value* value, int recursion) { m->WriteInt(value->GetType()); switch (value->GetType()) { - case Value::TYPE_NULL: + case Value::TYPE_NULL: break; - case Value::TYPE_BOOLEAN: { + case Value::TYPE_BOOLEAN: { bool val; value->GetAsBoolean(&val); WriteParam(m, val); break; } - case Value::TYPE_INTEGER: { + case Value::TYPE_INTEGER: { int val; value->GetAsInteger(&val); WriteParam(m, val); break; } - case Value::TYPE_REAL: { + case Value::TYPE_REAL: { double val; value->GetAsReal(&val); WriteParam(m, val); break; } - case Value::TYPE_STRING: { + case Value::TYPE_STRING: { std::string val; value->GetAsString(&val); WriteParam(m, val); break; } - case Value::TYPE_BINARY: { - NOTREACHED() << "Don't send BinaryValues over IPC."; + case Value::TYPE_BINARY: { + const BinaryValue* binary = static_cast<const BinaryValue*>(value); + m->WriteData(binary->GetBuffer(), binary->GetSize()); + break; } - case Value::TYPE_DICTIONARY: { + case Value::TYPE_DICTIONARY: { const DictionaryValue* dict = static_cast<const DictionaryValue*>(value); WriteParam(m, static_cast<int>(dict->GetSize())); @@ -73,7 +75,7 @@ static void WriteValue(Message* m, const Value* value, int recursion) { } break; } - case Value::TYPE_LIST: { + case Value::TYPE_LIST: { const ListValue* list = static_cast<const ListValue*>(value); WriteParam(m, static_cast<int>(list->GetSize())); for (size_t i = 0; i < list->GetSize(); ++i) { @@ -139,56 +141,60 @@ static bool ReadValue(const Message* m, void** iter, Value** value, return false; switch (type) { - case Value::TYPE_NULL: + case Value::TYPE_NULL: *value = Value::CreateNullValue(); break; - case Value::TYPE_BOOLEAN: { + case Value::TYPE_BOOLEAN: { bool val; if (!ReadParam(m, iter, &val)) return false; *value = Value::CreateBooleanValue(val); break; } - case Value::TYPE_INTEGER: { + case Value::TYPE_INTEGER: { int val; if (!ReadParam(m, iter, &val)) return false; *value = Value::CreateIntegerValue(val); break; } - case Value::TYPE_REAL: { + case Value::TYPE_REAL: { double val; if (!ReadParam(m, iter, &val)) return false; *value = Value::CreateRealValue(val); break; } - case Value::TYPE_STRING: { + case Value::TYPE_STRING: { std::string val; if (!ReadParam(m, iter, &val)) return false; *value = Value::CreateStringValue(val); break; } - case Value::TYPE_BINARY: { - NOTREACHED() << "Don't send BinaryValues over IPC."; + case Value::TYPE_BINARY: { + const char* data; + int length; + if (!m->ReadData(iter, &data, &length)) + return false; + *value = BinaryValue::CreateWithCopiedBuffer(data, length); break; } - case Value::TYPE_DICTIONARY: { + case Value::TYPE_DICTIONARY: { scoped_ptr<DictionaryValue> val(new DictionaryValue()); if (!ReadDictionaryValue(m, iter, val.get(), recursion)) return false; *value = val.release(); break; } - case Value::TYPE_LIST: { + case Value::TYPE_LIST: { scoped_ptr<ListValue> val(new ListValue()); if (!ReadListValue(m, iter, val.get(), recursion)) return false; *value = val.release(); break; } - default: + default: return false; } |