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

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

Issue 2069663002: Some scoped_ptr -> std::unique_ptr conversion, especially under //mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 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 unified diff | Download patch
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 <memory>
10
9 #include "base/files/file_enumerator.h" 11 #include "base/files/file_enumerator.h"
10 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
12 #include "base/logging.h" 14 #include "base/logging.h"
13 #include "base/macros.h" 15 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/rand_util.h" 16 #include "base/rand_util.h"
16 #include "dart/runtime/include/dart_api.h" 17 #include "dart/runtime/include/dart_api.h"
17 #include "mojo/dart/embedder/builtin.h" 18 #include "mojo/dart/embedder/builtin.h"
18 19
19 #if defined(OS_ANDROID) 20 #if defined(OS_ANDROID)
20 #include <android/log.h> 21 #include <android/log.h>
21 #endif 22 #endif
22 23
23 namespace mojo { 24 namespace mojo {
24 namespace dart { 25 namespace dart {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 const int64_t kMaxRandomBytes = 4096; 115 const int64_t kMaxRandomBytes = 4096;
115 int64_t count64 = 0; 116 int64_t count64 = 0;
116 if (!GetInt64Value(count_obj, &count64) || (count64 < 0) || 117 if (!GetInt64Value(count_obj, &count64) || (count64 < 0) ||
117 (count64 > kMaxRandomBytes)) { 118 (count64 > kMaxRandomBytes)) {
118 Dart_Handle error = Dart_NewStringFromCString( 119 Dart_Handle error = Dart_NewStringFromCString(
119 "Invalid argument: count must be a positive int " 120 "Invalid argument: count must be a positive int "
120 "less than or equal to 4096."); 121 "less than or equal to 4096.");
121 Dart_ThrowException(error); 122 Dart_ThrowException(error);
122 } 123 }
123 intptr_t count = static_cast<intptr_t>(count64); 124 intptr_t count = static_cast<intptr_t>(count64);
124 scoped_ptr<uint8_t[]> buffer(new uint8_t[count]); 125 std::unique_ptr<uint8_t[]> buffer(new uint8_t[count]);
125 126
126 base::RandBytes(reinterpret_cast<void*>(buffer.get()), count); 127 base::RandBytes(reinterpret_cast<void*>(buffer.get()), count);
127 128
128 Dart_Handle result = Dart_NewTypedData(Dart_TypedData_kUint8, count); 129 Dart_Handle result = Dart_NewTypedData(Dart_TypedData_kUint8, count);
129 if (Dart_IsError(result)) { 130 if (Dart_IsError(result)) {
130 Dart_Handle error = Dart_NewStringFromCString( 131 Dart_Handle error = Dart_NewStringFromCString(
131 "Failed to allocate storage."); 132 "Failed to allocate storage.");
132 Dart_ThrowException(error); 133 Dart_ThrowException(error);
133 } 134 }
134 Dart_ListSetAsBytes(result, 0, buffer.get(), count); 135 Dart_ListSetAsBytes(result, 0, buffer.get(), count);
135 Dart_SetReturnValue(args, result); 136 Dart_SetReturnValue(args, result);
136 } 137 }
137 138
138 } // namespace bin 139 } // namespace bin
139 } // namespace dart 140 } // namespace dart
OLDNEW
« no previous file with comments | « mojo/converters/ozone_drm_gpu/ozone_drm_gpu_type_converters.h ('k') | mojo/data_pipe_utils/data_pipe_file_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698