Chromium Code Reviews| Index: dbus/message.cc |
| diff --git a/dbus/message.cc b/dbus/message.cc |
| index fd7c07710c4e089143f0342d3f9abe958cabcc93..69f1152a3a121929971c076d676dd48cb2044ba3 100644 |
| --- a/dbus/message.cc |
| +++ b/dbus/message.cc |
| @@ -18,9 +18,9 @@ namespace { |
| // Appends the header name and the value to |output|, if the value is |
| // not empty. |
| -static void AppendStringHeader(const std::string& header_name, |
| - const std::string& header_value, |
| - std::string* output) { |
| +void AppendStringHeader(const std::string& header_name, |
| + const std::string& header_value, |
| + std::string* output) { |
| if (!header_value.empty()) { |
| *output += header_name + ": " + header_value + "\n"; |
| } |
| @@ -28,15 +28,21 @@ static void AppendStringHeader(const std::string& header_name, |
| // Appends the header name and the value to |output|, if the value is |
| // nonzero. |
| -static void AppendUint32Header(const std::string& header_name, |
| - uint32 header_value, |
| - std::string* output) { |
| +void AppendUint32Header(const std::string& header_name, |
| + uint32 header_value, |
| + std::string* output) { |
| if (header_value != 0) { |
| *output += (header_name + ": " + base::StringPrintf("%u", header_value) + |
| "\n"); |
| } |
| } |
| +bool IsDBusTypeUnixFdSupported() { |
|
satorux1
2012/07/24 21:49:08
It's not obvious why we should check this run time
|
| + int major, minor, micro; |
|
satorux1
2012/07/24 21:49:08
nit: initialize them with 0 just in case.
|
| + dbus_get_version(&major, &minor, µ); |
| + return major >= 1 && minor >= 4; |
| +} |
| + |
| } // namespace |
| namespace dbus { |
| @@ -211,7 +217,7 @@ std::string Message::ToStringInternal(const std::string& indent, |
| break; |
| } |
| case UNIX_FD: { |
| - CHECK(kDBusTypeUnixFdIsSupported); |
| + CHECK(IsDBusTypeUnixFdSupported()); |
| FileDescriptor file_descriptor; |
| if (!reader->PopFileDescriptor(&file_descriptor)) |
| @@ -690,7 +696,7 @@ void MessageWriter::AppendVariantOfBasic(int dbus_type, const void* value) { |
| } |
| void MessageWriter::AppendFileDescriptor(const FileDescriptor& value) { |
| - CHECK(kDBusTypeUnixFdIsSupported); |
| + CHECK(IsDBusTypeUnixFdSupported()); |
| if (!value.is_valid()) { |
| // NB: sending a directory potentially enables sandbox escape |
| @@ -960,7 +966,7 @@ bool MessageReader::PopVariantOfBasic(int dbus_type, void* value) { |
| } |
| bool MessageReader::PopFileDescriptor(FileDescriptor* value) { |
| - CHECK(kDBusTypeUnixFdIsSupported); |
| + CHECK(IsDBusTypeUnixFdSupported()); |
| int fd = -1; |
| const bool success = PopBasic(DBUS_TYPE_UNIX_FD, &fd); |