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

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: rebase 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
« no previous file with comments | « gpu/command_buffer/common/mailbox.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..21602ab6d4df291b19348f365d9d266abce12663 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 "base/rand_util.h"
namespace gpu {
@@ -31,4 +32,28 @@ void Mailbox::SetName(const int8* n) {
memcpy(name, n, sizeof(name));
}
+Mailbox Mailbox::Generate() {
+ Mailbox result;
+ // Generates cryptographically-secure bytes.
+ base::RandBytes(result.name, sizeof(result.name));
awong 2014/02/26 19:19:22 Use crypto::RandBytes() instead?
+#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
« no previous file with comments | « gpu/command_buffer/common/mailbox.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698