| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/android/important_file_writer_android.h" | |
| 6 | |
| 7 #include <string> | 5 #include <string> |
| 8 | 6 |
| 9 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 10 #include "base/files/important_file_writer.h" | 8 #include "base/files/important_file_writer.h" |
| 11 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
| 12 #include "jni/ImportantFileWriterAndroid_jni.h" | 10 #include "jni/ImportantFileWriterAndroid_jni.h" |
| 13 | 11 |
| 14 namespace base { | 12 namespace base { |
| 15 namespace android { | 13 namespace android { |
| 16 | 14 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 27 int data_length = env->GetArrayLength(data); | 25 int data_length = env->GetArrayLength(data); |
| 28 jbyte* native_data = env->GetByteArrayElements(data, NULL); | 26 jbyte* native_data = env->GetByteArrayElements(data, NULL); |
| 29 std::string native_data_string(reinterpret_cast<char *>(native_data), | 27 std::string native_data_string(reinterpret_cast<char *>(native_data), |
| 30 data_length); | 28 data_length); |
| 31 bool result = base::ImportantFileWriter::WriteFileAtomically( | 29 bool result = base::ImportantFileWriter::WriteFileAtomically( |
| 32 path, native_data_string); | 30 path, native_data_string); |
| 33 env->ReleaseByteArrayElements(data, native_data, JNI_ABORT); | 31 env->ReleaseByteArrayElements(data, native_data, JNI_ABORT); |
| 34 return result; | 32 return result; |
| 35 } | 33 } |
| 36 | 34 |
| 37 bool RegisterImportantFileWriterAndroid(JNIEnv* env) { | |
| 38 return RegisterNativesImpl(env); | |
| 39 } | |
| 40 | |
| 41 } // namespace android | 35 } // namespace android |
| 42 } // namespace base | 36 } // namespace base |
| OLD | NEW |