OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "dbus/message.h" | 5 #include "dbus/message.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 response->Init(dbus_message_new_error(method_call->raw_message(), | 445 response->Init(dbus_message_new_error(method_call->raw_message(), |
446 error_name.c_str(), | 446 error_name.c_str(), |
447 error_message.c_str())); | 447 error_message.c_str())); |
448 return response.Pass(); | 448 return response.Pass(); |
449 } | 449 } |
450 | 450 |
451 // | 451 // |
452 // MessageWriter implementation. | 452 // MessageWriter implementation. |
453 // | 453 // |
454 | 454 |
455 MessageWriter::MessageWriter(Message* message) : | 455 MessageWriter::MessageWriter(Message* message) |
456 message_(message), | 456 : message_(message), |
457 container_is_open_(false) { | 457 container_is_open_(false) { |
458 memset(&raw_message_iter_, 0, sizeof(raw_message_iter_)); | 458 memset(&raw_message_iter_, 0, sizeof(raw_message_iter_)); |
459 if (message) | 459 if (message) |
460 dbus_message_iter_init_append(message_->raw_message(), &raw_message_iter_); | 460 dbus_message_iter_init_append(message_->raw_message(), &raw_message_iter_); |
461 } | 461 } |
462 | 462 |
463 MessageWriter::~MessageWriter() { | 463 MessageWriter::~MessageWriter() { |
464 } | 464 } |
465 | 465 |
466 void MessageWriter::AppendByte(uint8 value) { | 466 void MessageWriter::AppendByte(uint8 value) { |
467 AppendBasic(DBUS_TYPE_BYTE, &value); | 467 AppendBasic(DBUS_TYPE_BYTE, &value); |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 | 959 |
960 if (!CheckDataType(dbus_type)) | 960 if (!CheckDataType(dbus_type)) |
961 return false; | 961 return false; |
962 dbus_message_iter_recurse(&raw_message_iter_, | 962 dbus_message_iter_recurse(&raw_message_iter_, |
963 &sub_reader->raw_message_iter_); | 963 &sub_reader->raw_message_iter_); |
964 dbus_message_iter_next(&raw_message_iter_); | 964 dbus_message_iter_next(&raw_message_iter_); |
965 return true; | 965 return true; |
966 } | 966 } |
967 | 967 |
968 bool MessageReader::PopVariantOfBasic(int dbus_type, void* value) { | 968 bool MessageReader::PopVariantOfBasic(int dbus_type, void* value) { |
969 dbus::MessageReader variant_reader(message_); | 969 MessageReader variant_reader(message_); |
970 if (!PopVariant(&variant_reader)) | 970 if (!PopVariant(&variant_reader)) |
971 return false; | 971 return false; |
972 return variant_reader.PopBasic(dbus_type, value); | 972 return variant_reader.PopBasic(dbus_type, value); |
973 } | 973 } |
974 | 974 |
975 bool MessageReader::PopFileDescriptor(FileDescriptor* value) { | 975 bool MessageReader::PopFileDescriptor(FileDescriptor* value) { |
976 CHECK(IsDBusTypeUnixFdSupported()); | 976 CHECK(IsDBusTypeUnixFdSupported()); |
977 | 977 |
978 int fd = -1; | 978 int fd = -1; |
979 const bool success = PopBasic(DBUS_TYPE_UNIX_FD, &fd); | 979 const bool success = PopBasic(DBUS_TYPE_UNIX_FD, &fd); |
980 if (!success) | 980 if (!success) |
981 return false; | 981 return false; |
982 | 982 |
983 value->PutValue(fd); | 983 value->PutValue(fd); |
984 // NB: the caller must check validity before using the value | 984 // NB: the caller must check validity before using the value |
985 return true; | 985 return true; |
986 } | 986 } |
987 | 987 |
988 } // namespace dbus | 988 } // namespace dbus |
OLD | NEW |