Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: chromeos/dbus/shill_third_party_vpn_driver_client.cc

Issue 820673004: json_schema_compiler: Use std::vector<char> for binary values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simplify_json_schema
Patch Set: Fix merge error. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3237f501a80ffe08a1ad9ecb14931c3d983de128 100644
--- a/chromeos/dbus/shill_third_party_vpn_driver_client.cc
+++ b/chromeos/dbus/shill_third_party_vpn_driver_client.cc
@@ -4,9 +4,8 @@
#include "chromeos/dbus/shill_third_party_vpn_driver_client.h"
-#include <string>
-
#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 +55,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 +244,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 8 bit large.");
+ 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 +271,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));
}
}
« no previous file with comments | « chromeos/dbus/shill_third_party_vpn_driver_client.h ('k') | chromeos/dbus/shill_third_party_vpn_driver_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698