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

Side by Side Diff: shell/android/android_handler.cc

Issue 2047333003: Roll base to ec59756cc1ad02cc835bcca10056a621c9eb346c. (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
« no previous file with comments | « mojo/android/system/core_impl.cc ('k') | no next file » | 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 "shell/android/android_handler.h" 5 #include "shell/android/android_handler.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 *extracted_dir = base::FilePath( 150 *extracted_dir = base::FilePath(
151 std::string(reinterpret_cast<char*>(&extracted_path.front()), 151 std::string(reinterpret_cast<char*>(&extracted_path.front()),
152 extracted_path.size())); 152 extracted_path.size()));
153 *cache_dir = base::FilePath(std::string( 153 *cache_dir = base::FilePath(std::string(
154 reinterpret_cast<char*>(&cache_path.front()), cache_path.size())); 154 reinterpret_cast<char*>(&cache_path.front()), cache_path.size()));
155 } 155 }
156 callback.Run(); 156 callback.Run();
157 }); 157 });
158 } 158 }
159 159
160 jstring CreateTemporaryFile(JNIEnv* env, 160 ScopedJavaLocalRef<jstring> CreateTemporaryFile(JNIEnv* env,
161 jclass jcaller, 161 jclass jcaller,
162 jstring j_directory, 162 jstring j_directory,
163 jstring j_basename, 163 jstring j_basename,
164 jstring j_extension) { 164 jstring j_extension) {
165 std::string basename(ConvertJavaStringToUTF8(env, j_basename)); 165 std::string basename(ConvertJavaStringToUTF8(env, j_basename));
166 std::string extension(ConvertJavaStringToUTF8(env, j_extension)); 166 std::string extension(ConvertJavaStringToUTF8(env, j_extension));
167 base::FilePath directory(ConvertJavaStringToUTF8(env, j_directory)); 167 base::FilePath directory(ConvertJavaStringToUTF8(env, j_directory));
168 168
169 for (;;) { 169 for (;;) {
170 std::string random = base::RandBytesAsString(16); 170 std::string random = base::RandBytesAsString(16);
171 std::string filename = 171 std::string filename =
172 basename + base::HexEncode(random.data(), random.size()) + extension; 172 basename + base::HexEncode(random.data(), random.size()) + extension;
173 base::FilePath temporary_file = directory.Append(filename); 173 base::FilePath temporary_file = directory.Append(filename);
174 int fd = open(temporary_file.value().c_str(), O_CREAT | O_EXCL, 0600); 174 int fd = open(temporary_file.value().c_str(), O_CREAT | O_EXCL, 0600);
175 if (fd != -1) { 175 if (fd != -1) {
176 close(fd); 176 close(fd);
177 return ConvertUTF8ToJavaString(env, temporary_file.value()).Release(); 177 return ConvertUTF8ToJavaString(env, temporary_file.value());
178 } 178 }
179 } 179 }
180 } 180 }
181 181
182 bool RegisterAndroidHandlerJni(JNIEnv* env) { 182 bool RegisterAndroidHandlerJni(JNIEnv* env) {
183 return RegisterNativesImpl(env); 183 return RegisterNativesImpl(env);
184 } 184 }
185 185
186 } // namespace shell 186 } // namespace shell
OLDNEW
« no previous file with comments | « mojo/android/system/core_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698