Don't create cross origins references in the extension system
[chromium-blink-merge.git] / components / proximity_auth / wire_message.h
blob73b643fa6a1a92d7c19f4f6b5eb02fddb2eef5e5
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 WireMessage(const std::string& permit_id, const std::string& payload);
18 virtual ~WireMessage();
20 // Returns the deserialized message from |serialized_message|, or NULL if the
21 // message is malformed. Sets |is_incomplete_message| to true if the message
22 // does not have enough data to parse the header, or if the message length
23 // encoded in the message header exceeds the size of the |serialized_message|.
24 static scoped_ptr<WireMessage> Deserialize(
25 const std::string& serialized_message,
26 bool* is_incomplete_message);
28 // Returns a serialized representation of |this| message.
29 virtual std::string Serialize() const;
31 const std::string& permit_id() const { return permit_id_; }
32 const std::string& payload() const { return payload_; }
34 private:
35 // Identifier of the permit being used.
36 // TODO(isherman): Describe in a bit more detail.
37 const std::string permit_id_;
39 // The message payload.
40 const std::string payload_;
42 DISALLOW_COPY_AND_ASSIGN(WireMessage);
45 } // namespace proximity_auth
47 #endif // COMPONENTS_PROXIMITY_AUTH_WIRE_MESSAGE_H