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.
5 #ifndef COMPONENTS_PROXIMITY_AUTH_WIRE_MESSAGE_H
6 #define COMPONENTS_PROXIMITY_AUTH_WIRE_MESSAGE_H
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
13 namespace proximity_auth {
17 virtual ~WireMessage();
19 // Returns the deserialized message from |serialized_message|, or NULL if the
20 // message is malformed. Sets |is_incomplete_message| to true if the message
21 // does not have enough data to parse the header, or if the message length
22 // encoded in the message header exceeds the size of the |serialized_message|.
23 static scoped_ptr<WireMessage> Deserialize(
24 const std::string& serialized_message,
25 bool* is_incomplete_message);
27 // Returns a serialized representation of |this| message.
28 virtual std::string Serialize() const;
30 const std::string& permit_id() const { return permit_id_; }
31 const std::string& payload() const { return payload_; }
35 WireMessage(const std::string& permit_id, const std::string& payload);
38 // Identifier of the permit being used.
39 // TODO(isherman): Describe in a bit more detail.
40 const std::string permit_id_;
42 // The message payload.
43 const std::string payload_;
45 DISALLOW_COPY_AND_ASSIGN(WireMessage);
48 } // namespace proximity_auth
50 #endif // COMPONENTS_PROXIMITY_AUTH_WIRE_MESSAGE_H