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/easy_unlock_client.h" | 5 #include "chromeos/dbus/easy_unlock_client.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <vector> | 10 #include <vector> |
8 | 11 |
9 #include "base/bind.h" | 12 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/macros.h" |
11 #include "dbus/bus.h" | 15 #include "dbus/bus.h" |
12 #include "dbus/message.h" | 16 #include "dbus/message.h" |
13 #include "dbus/object_path.h" | 17 #include "dbus/object_path.h" |
14 #include "dbus/object_proxy.h" | 18 #include "dbus/object_proxy.h" |
15 #include "third_party/cros_system_api/dbus/service_constants.h" | 19 #include "third_party/cros_system_api/dbus/service_constants.h" |
16 | 20 |
17 namespace chromeos { | 21 namespace chromeos { |
18 | 22 |
19 namespace { | 23 namespace { |
20 | 24 |
21 // Reads array of bytes from a dbus message reader and converts it to string. | 25 // Reads array of bytes from a dbus message reader and converts it to string. |
22 std::string PopResponseData(dbus::MessageReader* reader) { | 26 std::string PopResponseData(dbus::MessageReader* reader) { |
23 const uint8* bytes = NULL; | 27 const uint8_t* bytes = NULL; |
24 size_t length = 0; | 28 size_t length = 0; |
25 if (!reader->PopArrayOfBytes(&bytes, &length)) | 29 if (!reader->PopArrayOfBytes(&bytes, &length)) |
26 return ""; | 30 return ""; |
27 | 31 |
28 return std::string(reinterpret_cast<const char*>(bytes), length); | 32 return std::string(reinterpret_cast<const char*>(bytes), length); |
29 } | 33 } |
30 | 34 |
31 // Converts string to array of bytes and writes it using dbus meddage writer. | 35 // Converts string to array of bytes and writes it using dbus meddage writer. |
32 void AppendStringAsByteArray(const std::string& data, | 36 void AppendStringAsByteArray(const std::string& data, |
33 dbus::MessageWriter* writer) { | 37 dbus::MessageWriter* writer) { |
34 writer->AppendArrayOfBytes(reinterpret_cast<const uint8*>(data.data()), | 38 writer->AppendArrayOfBytes(reinterpret_cast<const uint8_t*>(data.data()), |
35 data.length()); | 39 data.length()); |
36 } | 40 } |
37 | 41 |
38 // The EasyUnlockClient used in production (and returned by | 42 // The EasyUnlockClient used in production (and returned by |
39 // EasyUnlockClient::Create). | 43 // EasyUnlockClient::Create). |
40 class EasyUnlockClientImpl : public EasyUnlockClient { | 44 class EasyUnlockClientImpl : public EasyUnlockClient { |
41 public: | 45 public: |
42 EasyUnlockClientImpl() : proxy_(NULL), weak_ptr_factory_(this) {} | 46 EasyUnlockClientImpl() : proxy_(NULL), weak_ptr_factory_(this) {} |
43 | 47 |
44 ~EasyUnlockClientImpl() override {} | 48 ~EasyUnlockClientImpl() override {} |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 198 |
195 EasyUnlockClient::~EasyUnlockClient() { | 199 EasyUnlockClient::~EasyUnlockClient() { |
196 } | 200 } |
197 | 201 |
198 // static | 202 // static |
199 EasyUnlockClient* EasyUnlockClient::Create() { | 203 EasyUnlockClient* EasyUnlockClient::Create() { |
200 return new EasyUnlockClientImpl(); | 204 return new EasyUnlockClientImpl(); |
201 } | 205 } |
202 | 206 |
203 } // namespace chromeos | 207 } // namespace chromeos |
OLD | NEW |