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

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: 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..8cb3c00e82975f735aac1271719789c86eaea1a0 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>
bartfab (slow) 2015/01/19 10:08:38 Nit: Already included by header.
pneubeck (no reviews) 2015/01/19 17:13:46 independent of the header, string is used in line
bartfab (slow) 2015/01/19 17:57:17 The way we do IWYU is to not include a header that
pneubeck (no reviews) 2015/01/19 18:04:28 Done.
+#include <vector>
bartfab (slow) 2015/01/19 10:08:38 Nit: Already included by header.
pneubeck (no reviews) 2015/01/19 17:13:46 independent of the header vector is used in line 2
bartfab (slow) 2015/01/19 17:57:17 The way we do IWYU is to not include a header that
pneubeck (no reviews) 2015/01/19 18:04:28 Done.
#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,15 @@ 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());
+ 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 +272,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));
bartfab (slow) 2015/01/19 10:08:38 You assume that a |char| is exactly 8 bits in size
pneubeck (no reviews) 2015/01/19 17:13:46 as discussed, added a static assert
}
}

Powered by Google App Engine
This is Rietveld 408576698