| Index: gpu/command_buffer/common/mailbox.cc
|
| diff --git a/gpu/command_buffer/common/mailbox.cc b/gpu/command_buffer/common/mailbox.cc
|
| index 8d8393fa63c0a647a992c98d6619156e01e75a92..0a3a942a09392b1e3ffdacd30486d741edb93e72 100644
|
| --- a/gpu/command_buffer/common/mailbox.cc
|
| +++ b/gpu/command_buffer/common/mailbox.cc
|
| @@ -7,6 +7,7 @@
|
| #include <string.h>
|
|
|
| #include "base/logging.h"
|
| +#include "crypto/random.h"
|
|
|
| namespace gpu {
|
|
|
| @@ -31,4 +32,27 @@ void Mailbox::SetName(const int8* n) {
|
| memcpy(name, n, sizeof(name));
|
| }
|
|
|
| +Mailbox Mailbox::Generate() {
|
| + Mailbox result;
|
| + crypto::RandBytes(result.name, sizeof(result.name));
|
| +#if !defined(NDEBUG)
|
| + int8 value = 1;
|
| + for (size_t i = 1; i < sizeof(result.name); ++i)
|
| + value ^= result.name[i];
|
| + result.name[0] = value;
|
| +#endif
|
| + return result;
|
| +}
|
| +
|
| +bool Mailbox::Verify() const {
|
| +#if !defined(NDEBUG)
|
| + int8 value = 1;
|
| + for (size_t i = 0; i < sizeof(name); ++i)
|
| + value ^= name[i];
|
| + return value == 0;
|
| +#else
|
| + return true;
|
| +#endif
|
| +}
|
| +
|
| } // namespace gpu
|
|
|