Index: chromeos/dbus/shill_third_party_vpn_driver_client.cc |
diff --git a/chromeos/dbus/shill_third_party_vpn_driver_client.cc b/chromeos/dbus/shill_third_party_vpn_driver_client.cc |
index c3392cd12851d9adae31cf1308b54381ea0427af..5ea66e413f7b5a6ab10bb5db6869b43cb49994a1 100644 |
--- a/chromeos/dbus/shill_third_party_vpn_driver_client.cc |
+++ b/chromeos/dbus/shill_third_party_vpn_driver_client.cc |
@@ -5,8 +5,10 @@ |
#include "chromeos/dbus/shill_third_party_vpn_driver_client.h" |
#include <string> |
+#include <vector> |
#include "base/bind.h" |
+#include "base/stl_util.h" |
#include "chromeos/dbus/shill_third_party_vpn_observer.h" |
#include "dbus/bus.h" |
#include "dbus/message.h" |
@@ -56,7 +58,7 @@ class ShillThirdPartyVpnDriverClientImpl |
void SendPacket( |
const std::string& object_path_value, |
- const std::string& ip_packet, |
+ const std::vector<char>& ip_packet, |
const base::Closure& callback, |
const ShillClientHelper::ErrorCallback& error_callback) override; |
@@ -245,14 +247,17 @@ void ShillThirdPartyVpnDriverClientImpl::UpdateConnectionState( |
void ShillThirdPartyVpnDriverClientImpl::SendPacket( |
const std::string& object_path_value, |
- const std::string& ip_packet, |
+ const std::vector<char>& ip_packet, |
const base::Closure& callback, |
const ShillClientHelper::ErrorCallback& error_callback) { |
dbus::MethodCall method_call(shill::kFlimflamThirdPartyVpnInterface, |
shill::kSendPacketFunction); |
dbus::MessageWriter writer(&method_call); |
- writer.AppendArrayOfBytes(reinterpret_cast<const uint8_t*>(ip_packet.data()), |
- ip_packet.size()); |
+ static_assert(sizeof(uint8_t) == sizeof(char), |
+ "Can't reinterpret ip_packet if char is not a byte."); |
bartfab (slow)
2015/01/19 17:57:17
Nit: char is always a byte. But a byte is not nece
pneubeck (no reviews)
2015/01/19 18:04:28
Done.
|
+ writer.AppendArrayOfBytes( |
+ reinterpret_cast<const uint8_t*>(vector_as_array(&ip_packet)), |
+ ip_packet.size()); |
GetHelper(object_path_value) |
->CallVoidMethodWithErrorCallback(&method_call, callback, error_callback); |
} |
@@ -269,7 +274,7 @@ void ShillThirdPartyVpnDriverClientImpl::OnPacketReceived( |
size_t length = 0; |
if (reader.PopArrayOfBytes(&data, &length)) { |
helper_info->observer()->OnPacketReceived( |
- std::string(reinterpret_cast<const char*>(data), length)); |
+ std::vector<char>(data, data + length)); |
} |
} |