Fix BrowserFileSystem context creation race condition between UI and IO threads (issue #442).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@404 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2011-12-06 10:16:51 +00:00
parent 1d6de4e8b9
commit a254639d2b
7 changed files with 36 additions and 25 deletions

View File

@@ -250,21 +250,26 @@ void BrowserRequestContext::Init(
storage_.set_ftp_transaction_factory(
new net::FtpNetworkLayer(host_resolver()));
blob_storage_controller_.reset(new webkit_blob::BlobStorageController());
file_system_context_ = static_cast<BrowserFileSystem*>(
WebKit::webKitPlatformSupport()->fileSystem())->file_system_context();
net::URLRequestJobFactory* job_factory = new net::URLRequestJobFactory;
blob_storage_controller_.reset(new webkit_blob::BlobStorageController());
job_factory->SetProtocolHandler(
"blob",
new webkit_blob::BlobProtocolHandler(
blob_storage_controller_.get(),
CefThread::GetMessageLoopProxyForThread(CefThread::FILE)));
job_factory->SetProtocolHandler(
"filesystem",
fileapi::CreateFileSystemProtocolHandler(
file_system_context_.get(),
CefThread::GetMessageLoopProxyForThread(CefThread::FILE)));
BrowserFileSystem* file_system = _Context->file_system();
// Create the context if it doesn't already exist.
file_system->CreateContext();
if (file_system->file_system_context()) {
job_factory->SetProtocolHandler(
"filesystem",
fileapi::CreateFileSystemProtocolHandler(
file_system->file_system_context(),
CefThread::GetMessageLoopProxyForThread(CefThread::FILE)));
}
storage_.set_job_factory(job_factory);
}