Use kDefaultURL throughout SpdySessionTest.
[chromium-blink-merge.git] / components / proximity_auth / wire_message.h
blobc023c2181d58b3a233d2e5ca260993e5d5dd0d49
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
8 #include <string>
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
13 namespace proximity_auth {
15 class WireMessage {
16 public:
17 // Creates a WireMessage containing |payload|.
18 explicit WireMessage(const std::string& payload);
20 // Creates a WireMessage containing |payload| and |permit_id| in the metadata.
21 WireMessage(const std::string& payload, const std::string& permit_id);
23 virtual ~WireMessage();
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 scoped_ptr<WireMessage> Deserialize(
30 const std::string& serialized_message,
31 bool* is_incomplete_message);
33 // Returns a serialized representation of |this| message.
34 virtual std::string Serialize() const;
36 const std::string& payload() const { return payload_; }
37 const std::string& permit_id() const { return permit_id_; }
39 private:
40 // The message payload.
41 const std::string payload_;
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_;
50 DISALLOW_COPY_AND_ASSIGN(WireMessage);
53 } // namespace proximity_auth
55 #endif // COMPONENTS_PROXIMITY_AUTH_WIRE_MESSAGE_H