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

Side by Side Diff: mojo/dart/embedder/builtin_natives.cc

Issue 1244823003: Remove dependency from //mojo to //crypto (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « mojo/dart/embedder/BUILD.gn ('k') | mojo/dart/embedder/dart_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdio.h> 5 #include <stdio.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/files/file_enumerator.h" 9 #include "base/files/file_enumerator.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "crypto/random.h" 15 #include "base/rand_util.h"
16 #include "dart/runtime/include/dart_api.h" 16 #include "dart/runtime/include/dart_api.h"
17 #include "mojo/dart/embedder/builtin.h" 17 #include "mojo/dart/embedder/builtin.h"
18 #include "mojo/dart/embedder/mojo_natives.h" 18 #include "mojo/dart/embedder/mojo_natives.h"
19 19
20 #if defined(OS_ANDROID) 20 #if defined(OS_ANDROID)
21 #include <android/log.h> 21 #include <android/log.h>
22 #endif 22 #endif
23 23
24 namespace mojo { 24 namespace mojo {
25 namespace dart { 25 namespace dart {
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 if (!GetInt64Value(count_obj, &count64) || (count64 < 0) || 317 if (!GetInt64Value(count_obj, &count64) || (count64 < 0) ||
318 (count64 > kMaxRandomBytes)) { 318 (count64 > kMaxRandomBytes)) {
319 Dart_Handle error = Dart_NewStringFromCString( 319 Dart_Handle error = Dart_NewStringFromCString(
320 "Invalid argument: count must be a positive int " 320 "Invalid argument: count must be a positive int "
321 "less than or equal to 4096."); 321 "less than or equal to 4096.");
322 Dart_ThrowException(error); 322 Dart_ThrowException(error);
323 } 323 }
324 intptr_t count = static_cast<intptr_t>(count64); 324 intptr_t count = static_cast<intptr_t>(count64);
325 scoped_ptr<uint8_t[]> buffer(new uint8_t[count]); 325 scoped_ptr<uint8_t[]> buffer(new uint8_t[count]);
326 326
327 crypto::RandBytes(reinterpret_cast<void*>(buffer.get()), count); 327 base::RandBytes(reinterpret_cast<void*>(buffer.get()), count);
328 328
329 Dart_Handle result = Dart_NewTypedData(Dart_TypedData_kUint8, count); 329 Dart_Handle result = Dart_NewTypedData(Dart_TypedData_kUint8, count);
330 if (Dart_IsError(result)) { 330 if (Dart_IsError(result)) {
331 Dart_Handle error = Dart_NewStringFromCString( 331 Dart_Handle error = Dart_NewStringFromCString(
332 "Failed to allocate storage."); 332 "Failed to allocate storage.");
333 Dart_ThrowException(error); 333 Dart_ThrowException(error);
334 } 334 }
335 Dart_ListSetAsBytes(result, 0, buffer.get(), count); 335 Dart_ListSetAsBytes(result, 0, buffer.get(), count);
336 Dart_SetReturnValue(args, result); 336 Dart_SetReturnValue(args, result);
337 } 337 }
338 338
339 } // namespace bin 339 } // namespace bin
340 } // namespace dart 340 } // namespace dart
OLDNEW
« no previous file with comments | « mojo/dart/embedder/BUILD.gn ('k') | mojo/dart/embedder/dart_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698