From 4ecbb8f86691102f2a1162677ce091d3de8c5888 Mon Sep 17 00:00:00 2001 From: "bulach@chromium.org" Date: Wed, 6 Mar 2013 09:33:53 +0000 Subject: [PATCH] Allow atomic file writes from Android on the UI thread. This is needed because Android writes its tab data during closedown or when the browser goes into the background. This has to be done on the UI thread to ensure timely completion. BUG=148011 Review URL: https://codereview.chromium.org/12457007 Patch from Anthony Berent . git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186392 0039d316-1c4b-4281-b951-d872f2087c98 --- base/android/important_file_writer_android.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/base/android/important_file_writer_android.cc b/base/android/important_file_writer_android.cc index f2275c183ab70a..05719ae2b8a94e 100644 --- a/base/android/important_file_writer_android.cc +++ b/base/android/important_file_writer_android.cc @@ -8,6 +8,7 @@ #include "base/android/jni_string.h" #include "base/files/important_file_writer.h" +#include "base/threading/thread_restrictions.h" #include "jni/ImportantFileWriterAndroid_jni.h" namespace base { @@ -17,6 +18,9 @@ static jboolean WriteFileAtomically(JNIEnv* env, jclass /* clazz */, jstring file_name, jbyteArray data) { + // This is called on the UI thread during shutdown to save tab data, so + // needs to enable IO. + base::ThreadRestrictions::ScopedAllowIO(); std::string native_file_name; base::android::ConvertJavaStringToUTF8(env, file_name, &native_file_name); base::FilePath path(native_file_name);