diff options
author | armansito@chromium.org <armansito@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-15 07:40:49 +0000 |
---|---|---|
committer | armansito@chromium.org <armansito@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-15 07:40:49 +0000 |
commit | ebbfffa2f19d6d4727586710dd49be63fcd8e1e2 (patch) | |
tree | ca18177ab6074fd42aa589b53581ad7ca8d67983 /dbus/test_service.cc | |
parent | df42c35236e9570d64477009bf89fb42baee7b60 (diff) | |
download | chromium_src-ebbfffa2f19d6d4727586710dd49be63fcd8e1e2.zip chromium_src-ebbfffa2f19d6d4727586710dd49be63fcd8e1e2.tar.gz chromium_src-ebbfffa2f19d6d4727586710dd49be63fcd8e1e2.tar.bz2 |
dbus: Add template specialization for Property<vector<uint8> >.
BUG=351229
TEST=dbus_unittests
Review URL: https://codereview.chromium.org/199573003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257315 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/test_service.cc')
-rw-r--r-- | dbus/test_service.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/dbus/test_service.cc b/dbus/test_service.cc index 064b91e..96fa8bc 100644 --- a/dbus/test_service.cc +++ b/dbus/test_service.cc @@ -408,6 +408,20 @@ void TestService::GetProperty(MethodCall* method_call, writer.CloseContainer(&variant_writer); response_sender.Run(response.Pass()); + } else if (name == "Bytes") { + // Return the previous value for the "Bytes" property: + // Variant<[0x54, 0x65, 0x73, 0x74]> + scoped_ptr<Response> response = Response::FromMethodCall(method_call); + MessageWriter writer(response.get()); + MessageWriter variant_writer(NULL); + MessageWriter variant_array_writer(NULL); + + writer.OpenVariant("ay", &variant_writer); + const uint8 bytes[] = { 0x54, 0x65, 0x73, 0x74 }; + variant_writer.AppendArrayOfBytes(bytes, sizeof(bytes)); + writer.CloseContainer(&variant_writer); + + response_sender.Run(response.Pass()); } else { // Return error. response_sender.Run(scoped_ptr<Response>()); @@ -554,6 +568,7 @@ void TestService::AddPropertiesToWriter(MessageWriter* writer) { // "Version": Variant<10>, // "Methods": Variant<["Echo", "SlowEcho", "AsyncEcho", "BrokenMethod"]>, // "Objects": Variant<[objectpath:"/TestObjectPath"]> + // "Bytes": Variant<[0x54, 0x65, 0x73, 0x74]> // } MessageWriter array_writer(NULL); @@ -594,6 +609,14 @@ void TestService::AddPropertiesToWriter(MessageWriter* writer) { dict_entry_writer.CloseContainer(&variant_writer); array_writer.CloseContainer(&dict_entry_writer); + array_writer.OpenDictEntry(&dict_entry_writer); + dict_entry_writer.AppendString("Bytes"); + dict_entry_writer.OpenVariant("ay", &variant_writer); + const uint8 bytes[] = { 0x54, 0x65, 0x73, 0x74 }; + variant_writer.AppendArrayOfBytes(bytes, sizeof(bytes)); + dict_entry_writer.CloseContainer(&variant_writer); + array_writer.CloseContainer(&dict_entry_writer); + writer->CloseContainer(&array_writer); } |