Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Unified Diff: gpu/command_buffer/common/mailbox.cc

Issue 165393003: gpu: Generate mailboxes on client side (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: meant to remove crypto/random.cc Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698