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

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

Issue 2056563002: Roll base to 0032c8e1a72eb85d947d8df8de503caa62b4d0a8. (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 | « services/java_handler/java_handler.cc ('k') | shell/android/bootstrap.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 "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 ScopedJavaLocalRef<jstring> CreateTemporaryFile(JNIEnv* env, 160 ScopedJavaLocalRef<jstring> CreateTemporaryFile(
161 jclass jcaller, 161 JNIEnv* env,
162 jstring j_directory, 162 const JavaParamRef<jclass>& jcaller,
163 jstring j_basename, 163 const JavaParamRef<jstring>& j_directory,
164 jstring j_extension) { 164 const JavaParamRef<jstring>& j_basename,
165 const JavaParamRef<jstring>& j_extension) {
165 std::string basename(ConvertJavaStringToUTF8(env, j_basename)); 166 std::string basename(ConvertJavaStringToUTF8(env, j_basename));
166 std::string extension(ConvertJavaStringToUTF8(env, j_extension)); 167 std::string extension(ConvertJavaStringToUTF8(env, j_extension));
167 base::FilePath directory(ConvertJavaStringToUTF8(env, j_directory)); 168 base::FilePath directory(ConvertJavaStringToUTF8(env, j_directory));
168 169
169 for (;;) { 170 for (;;) {
170 std::string random = base::RandBytesAsString(16); 171 std::string random = base::RandBytesAsString(16);
171 std::string filename = 172 std::string filename =
172 basename + base::HexEncode(random.data(), random.size()) + extension; 173 basename + base::HexEncode(random.data(), random.size()) + extension;
173 base::FilePath temporary_file = directory.Append(filename); 174 base::FilePath temporary_file = directory.Append(filename);
174 int fd = open(temporary_file.value().c_str(), O_CREAT | O_EXCL, 0600); 175 int fd = open(temporary_file.value().c_str(), O_CREAT | O_EXCL, 0600);
175 if (fd != -1) { 176 if (fd != -1) {
176 close(fd); 177 close(fd);
177 return ConvertUTF8ToJavaString(env, temporary_file.value()); 178 return ConvertUTF8ToJavaString(env, temporary_file.value());
178 } 179 }
179 } 180 }
180 } 181 }
181 182
182 bool RegisterAndroidHandlerJni(JNIEnv* env) { 183 bool RegisterAndroidHandlerJni(JNIEnv* env) {
183 return RegisterNativesImpl(env); 184 return RegisterNativesImpl(env);
184 } 185 }
185 186
186 } // namespace shell 187 } // namespace shell
OLDNEW
« no previous file with comments | « services/java_handler/java_handler.cc ('k') | shell/android/bootstrap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698