From 6077a01022957200646ae74b40ee7ab499b99e72 Mon Sep 17 00:00:00 2001 From: "evan@chromium.org" Date: Sat, 23 Oct 2010 00:07:32 +0000 Subject: Thread IO safety: annotate file_util, and block IO thread from doing IO - Mark functions in file_util_posix as requiring permission to perform disk actions. - Mark the IO thread as disallowed from performing disk actions. - Temporarily work around the protections in places where we currently have bugs. BUG=59847,59849,60207,60211 TEST=no dchecks in debug builds Review URL: http://codereview.chromium.org/3872002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63600 0039d316-1c4b-4281-b951-d872f2087c98 --- net/url_request/url_request_file_job.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'net/url_request') diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc index 8c282ff..f9c6559 100644 --- a/net/url_request/url_request_file_job.cc +++ b/net/url_request/url_request_file_job.cc @@ -23,6 +23,7 @@ #include "base/message_loop.h" #include "base/platform_file.h" #include "base/string_util.h" +#include "base/thread_restrictions.h" #include "build/build_config.h" #include "googleurl/src/gurl.h" #include "net/base/io_buffer.h" @@ -128,8 +129,15 @@ void URLRequestFileJob::Start() { return; } #endif + + // URL requests should not block on the disk! + // http://code.google.com/p/chromium/issues/detail?id=59849 + bool exists; base::PlatformFileInfo file_info; - bool exists = file_util::GetFileInfo(file_path_, &file_info); + { + base::ThreadRestrictions::ScopedAllowIO allow_io; + exists = file_util::GetFileInfo(file_path_, &file_info); + } // Continue asynchronously. MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( -- cgit v1.1