OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromeos/dbus/shill_third_party_vpn_driver_client.h" | 5 #include "chromeos/dbus/shill_third_party_vpn_driver_client.h" |
6 | 6 |
7 #include <string> | 7 #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.
| |
8 #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.
| |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/stl_util.h" | |
10 #include "chromeos/dbus/shill_third_party_vpn_observer.h" | 12 #include "chromeos/dbus/shill_third_party_vpn_observer.h" |
11 #include "dbus/bus.h" | 13 #include "dbus/bus.h" |
12 #include "dbus/message.h" | 14 #include "dbus/message.h" |
13 #include "dbus/object_proxy.h" | 15 #include "dbus/object_proxy.h" |
14 #include "third_party/cros_system_api/dbus/service_constants.h" | 16 #include "third_party/cros_system_api/dbus/service_constants.h" |
15 | 17 |
16 namespace chromeos { | 18 namespace chromeos { |
17 | 19 |
18 namespace { | 20 namespace { |
19 | 21 |
(...skipping 29 matching lines...) Expand all Loading... | |
49 const ShillClientHelper::ErrorCallback& error_callback) override; | 51 const ShillClientHelper::ErrorCallback& error_callback) override; |
50 | 52 |
51 void UpdateConnectionState( | 53 void UpdateConnectionState( |
52 const std::string& object_path_value, | 54 const std::string& object_path_value, |
53 const uint32_t connection_state, | 55 const uint32_t connection_state, |
54 const base::Closure& callback, | 56 const base::Closure& callback, |
55 const ShillClientHelper::ErrorCallback& error_callback) override; | 57 const ShillClientHelper::ErrorCallback& error_callback) override; |
56 | 58 |
57 void SendPacket( | 59 void SendPacket( |
58 const std::string& object_path_value, | 60 const std::string& object_path_value, |
59 const std::string& ip_packet, | 61 const std::vector<char>& ip_packet, |
60 const base::Closure& callback, | 62 const base::Closure& callback, |
61 const ShillClientHelper::ErrorCallback& error_callback) override; | 63 const ShillClientHelper::ErrorCallback& error_callback) override; |
62 | 64 |
63 protected: | 65 protected: |
64 void Init(dbus::Bus* bus) override { bus_ = bus; } | 66 void Init(dbus::Bus* bus) override { bus_ = bus; } |
65 | 67 |
66 ShillThirdPartyVpnDriverClient::TestInterface* GetTestInterface() override { | 68 ShillThirdPartyVpnDriverClient::TestInterface* GetTestInterface() override { |
67 return nullptr; | 69 return nullptr; |
68 } | 70 } |
69 | 71 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 dbus::MethodCall method_call(shill::kFlimflamThirdPartyVpnInterface, | 240 dbus::MethodCall method_call(shill::kFlimflamThirdPartyVpnInterface, |
239 shill::kUpdateConnectionStateFunction); | 241 shill::kUpdateConnectionStateFunction); |
240 dbus::MessageWriter writer(&method_call); | 242 dbus::MessageWriter writer(&method_call); |
241 writer.AppendUint32(connection_state); | 243 writer.AppendUint32(connection_state); |
242 GetHelper(object_path_value) | 244 GetHelper(object_path_value) |
243 ->CallVoidMethodWithErrorCallback(&method_call, callback, error_callback); | 245 ->CallVoidMethodWithErrorCallback(&method_call, callback, error_callback); |
244 } | 246 } |
245 | 247 |
246 void ShillThirdPartyVpnDriverClientImpl::SendPacket( | 248 void ShillThirdPartyVpnDriverClientImpl::SendPacket( |
247 const std::string& object_path_value, | 249 const std::string& object_path_value, |
248 const std::string& ip_packet, | 250 const std::vector<char>& ip_packet, |
249 const base::Closure& callback, | 251 const base::Closure& callback, |
250 const ShillClientHelper::ErrorCallback& error_callback) { | 252 const ShillClientHelper::ErrorCallback& error_callback) { |
251 dbus::MethodCall method_call(shill::kFlimflamThirdPartyVpnInterface, | 253 dbus::MethodCall method_call(shill::kFlimflamThirdPartyVpnInterface, |
252 shill::kSendPacketFunction); | 254 shill::kSendPacketFunction); |
253 dbus::MessageWriter writer(&method_call); | 255 dbus::MessageWriter writer(&method_call); |
254 writer.AppendArrayOfBytes(reinterpret_cast<const uint8_t*>(ip_packet.data()), | 256 writer.AppendArrayOfBytes( |
255 ip_packet.size()); | 257 reinterpret_cast<const uint8_t*>(vector_as_array(&ip_packet)), |
258 ip_packet.size()); | |
256 GetHelper(object_path_value) | 259 GetHelper(object_path_value) |
257 ->CallVoidMethodWithErrorCallback(&method_call, callback, error_callback); | 260 ->CallVoidMethodWithErrorCallback(&method_call, callback, error_callback); |
258 } | 261 } |
259 | 262 |
260 // static | 263 // static |
261 void ShillThirdPartyVpnDriverClientImpl::OnPacketReceived( | 264 void ShillThirdPartyVpnDriverClientImpl::OnPacketReceived( |
262 base::WeakPtr<HelperInfo> helper_info, | 265 base::WeakPtr<HelperInfo> helper_info, |
263 dbus::Signal* signal) { | 266 dbus::Signal* signal) { |
264 if (!helper_info || !helper_info->observer()) | 267 if (!helper_info || !helper_info->observer()) |
265 return; | 268 return; |
266 | 269 |
267 dbus::MessageReader reader(signal); | 270 dbus::MessageReader reader(signal); |
268 const uint8_t* data = nullptr; | 271 const uint8_t* data = nullptr; |
269 size_t length = 0; | 272 size_t length = 0; |
270 if (reader.PopArrayOfBytes(&data, &length)) { | 273 if (reader.PopArrayOfBytes(&data, &length)) { |
271 helper_info->observer()->OnPacketReceived( | 274 helper_info->observer()->OnPacketReceived( |
272 std::string(reinterpret_cast<const char*>(data), length)); | 275 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
| |
273 } | 276 } |
274 } | 277 } |
275 | 278 |
276 // static | 279 // static |
277 void ShillThirdPartyVpnDriverClientImpl::OnPlatformMessage( | 280 void ShillThirdPartyVpnDriverClientImpl::OnPlatformMessage( |
278 base::WeakPtr<HelperInfo> helper_info, | 281 base::WeakPtr<HelperInfo> helper_info, |
279 dbus::Signal* signal) { | 282 dbus::Signal* signal) { |
280 if (!helper_info || !helper_info->observer()) | 283 if (!helper_info || !helper_info->observer()) |
281 return; | 284 return; |
282 | 285 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 | 333 |
331 ShillThirdPartyVpnDriverClient::~ShillThirdPartyVpnDriverClient() { | 334 ShillThirdPartyVpnDriverClient::~ShillThirdPartyVpnDriverClient() { |
332 } | 335 } |
333 | 336 |
334 // static | 337 // static |
335 ShillThirdPartyVpnDriverClient* ShillThirdPartyVpnDriverClient::Create() { | 338 ShillThirdPartyVpnDriverClient* ShillThirdPartyVpnDriverClient::Create() { |
336 return new ShillThirdPartyVpnDriverClientImpl(); | 339 return new ShillThirdPartyVpnDriverClientImpl(); |
337 } | 340 } |
338 | 341 |
339 } // namespace chromeos | 342 } // namespace chromeos |
OLD | NEW |