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

Unified Diff: base/rand_util_nacl.cc

Issue 324983005: [PPAPI] Add browser tests for compositor API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@compositor_api_impl_new
Patch Set: Fix review issues Created 6 years, 6 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 | « no previous file | chrome/test/ppapi/ppapi_browsertest.cc » ('j') | chrome/test/ppapi/ppapi_browsertest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/rand_util_nacl.cc
diff --git a/base/rand_util_nacl.cc b/base/rand_util_nacl.cc
index a8ea202fc7edde189c612969cad9bde5b13af0eb..c5375e7229fabe7e6eacc68186630355b4dcd74e 100644
--- a/base/rand_util_nacl.cc
+++ b/base/rand_util_nacl.cc
@@ -11,16 +11,29 @@
namespace {
+int i = 0;
+
void GetRandomBytes(void* output, size_t num_bytes) {
- CHECK_EQ(0, nacl_secure_random_init());
- char* output_ptr = static_cast<char*>(output);
- while (num_bytes > 0) {
- size_t nread;
- const int error = nacl_secure_random(output_ptr, num_bytes, &nread);
- CHECK_EQ(error, 0);
- CHECK_LE(nread, num_bytes);
- output_ptr += nread;
- num_bytes -= nread;
+ if (nacl_secure_random_init() == 0) {
+ char* output_ptr = static_cast<char*>(output);
+ while (num_bytes > 0) {
+ size_t nread;
+ const int error = nacl_secure_random(output_ptr, num_bytes, &nread);
+ CHECK_EQ(error, 0);
+ CHECK_LE(nread, num_bytes);
+ output_ptr += nread;
+ num_bytes -= nread;
+ }
+ } else {
+ char* output_ptr = static_cast<char*>(output);
+ while (num_bytes > 0) {
+ int r = (++i) + reinterpret_cast<int>(output_ptr);
+ while (r >= 255) {
+ r = r + ( r >> 8);
+ }
+ *output_ptr++ = static_cast<char>(r);
+ num_bytes--;
+ }
raymes 2014/06/18 05:58:44 I'm not sure that adding this is the right thing t
Peng 2014/06/18 11:14:36 Please ignore changes in base folder. It is a temp
}
}
« no previous file with comments | « no previous file | chrome/test/ppapi/ppapi_browsertest.cc » ('j') | chrome/test/ppapi/ppapi_browsertest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698