Chromium Code Reviews| Index: components/proximity_auth/permit_message.h |
| diff --git a/components/proximity_auth/permit_message.h b/components/proximity_auth/permit_message.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b6057dfdb0f9df357d86fc6246696c667d0b3e1a |
| --- /dev/null |
| +++ b/components/proximity_auth/permit_message.h |
| @@ -0,0 +1,39 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_PROXIMITY_AUTH_PERMIT_MESSAGE_H |
| +#define COMPONENTS_PROXIMITY_AUTH_PERMIT_MESSAGE_H |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| + |
| +namespace proximity_auth { |
| + |
| +class PermitMessage { |
|
Tim Song
2014/09/05 00:30:34
WireMessage would be a better name for this class.
Ilya Sherman
2014/09/05 01:02:12
Done.
|
| + public: |
| + virtual ~PermitMessage(); |
| + |
| + // Returns |true| iff the |size| is at least equal to the message length |
| + // encoded in the header of |bytes|. |
| + static bool IsCompleteMessage(const char* bytes, int size); |
|
Tim Song
2014/09/05 00:30:34
Let's use a vector<uint8_t> as the shared data typ
Ilya Sherman
2014/09/05 01:02:12
It looks like I was mistaken about how strings han
Tim Song
2014/09/05 03:10:33
Strings are good.
|
| + |
| + // Returns the deserialized message from the first |size| bytes of |bytes|, or |
| + // NULL if the message is malformed. |
| + static scoped_ptr<PermitMessage> FromBytes(const char* bytes, int size); |
| + |
| + protected: |
| + // Visible for tests. |
| + PermitMessage(); |
| + |
| + private: |
| + // Returns the deserialized message from the first |size| bytes of |bytes|, or |
| + // NULL if the message is malformed. |
| + static scoped_ptr<PermitMessage> FromBytesImpl(const char* bytes, int size); |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PermitMessage); |
| +}; |
| + |
| +} // namespace proximity_auth |
| + |
| +#endif // COMPONENTS_PROXIMITY_AUTH_PERMIT_MESSAGE_H |