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

Side by Side Diff: components/proximity_auth/wire_message.h

Issue 2561203002: Migrate weave-related classes from proximity_auth/ble to cryptauth/ble. (Closed)
Patch Set: Rebase. Created 4 years 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_PROXIMITY_AUTH_WIRE_MESSAGE_H
6 #define COMPONENTS_PROXIMITY_AUTH_WIRE_MESSAGE_H
7
8 #include <memory>
9 #include <string>
10
11 #include "base/macros.h"
12
13 namespace proximity_auth {
14
15 class WireMessage {
16 public:
17 // Creates a WireMessage containing |payload|.
18 explicit WireMessage(const std::string& payload);
19
20 // Creates a WireMessage containing |payload| and |permit_id| in the metadata.
21 WireMessage(const std::string& payload, const std::string& permit_id);
22
23 virtual ~WireMessage();
24
25 // Returns the deserialized message from |serialized_message|, or NULL if the
26 // message is malformed. Sets |is_incomplete_message| to true if the message
27 // does not have enough data to parse the header, or if the message length
28 // encoded in the message header exceeds the size of the |serialized_message|.
29 static std::unique_ptr<WireMessage> Deserialize(
30 const std::string& serialized_message,
31 bool* is_incomplete_message);
32
33 // Returns a serialized representation of |this| message.
34 virtual std::string Serialize() const;
35
36 const std::string& payload() const { return payload_; }
37 const std::string& permit_id() const { return permit_id_; }
38
39 private:
40 // The message payload.
41 const std::string payload_;
42
43 // Identifier of the permit being used. A permit contains the credentials used
44 // to authenticate a device. For example, when sending a WireMessage to the
45 // remote device the |permit_id_| indexes a permit possibly containing the
46 // public key
47 // of the local device or a symmetric key shared between the devices.
48 const std::string permit_id_;
49
50 DISALLOW_COPY_AND_ASSIGN(WireMessage);
51 };
52
53 } // namespace proximity_auth
54
55 #endif // COMPONENTS_PROXIMITY_AUTH_WIRE_MESSAGE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698