Skip to content

Commit

Permalink
Allow atomic file writes from Android on the UI thread.
Browse files Browse the repository at this point in the history
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 <aberent@chromium.org>.

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186392 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
bulach@chromium.org committed Mar 6, 2013
1 parent 129b185 commit 4ecbb8f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions base/android/important_file_writer_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand Down

0 comments on commit 4ecbb8f

Please sign in to comment.