mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-03 04:27:43 +01:00
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:
parent
1d6de4e8b9
commit
a254639d2b
@ -4,6 +4,7 @@
|
||||
|
||||
#include "browser_file_system.h"
|
||||
#include "browser_file_writer.h"
|
||||
#include "cef_thread.h"
|
||||
|
||||
#include "base/file_path.h"
|
||||
#include "base/memory/scoped_callback_factory.h"
|
||||
@ -122,10 +123,19 @@ class BrowserFileSystemCallbackDispatcher
|
||||
} // namespace
|
||||
|
||||
BrowserFileSystem::BrowserFileSystem() {
|
||||
}
|
||||
|
||||
BrowserFileSystem::~BrowserFileSystem() {
|
||||
}
|
||||
|
||||
void BrowserFileSystem::CreateContext() {
|
||||
if (file_system_context_.get())
|
||||
return;
|
||||
|
||||
if (file_system_dir_.CreateUniqueTempDir()) {
|
||||
file_system_context_ = new FileSystemContext(
|
||||
base::MessageLoopProxy::current(),
|
||||
base::MessageLoopProxy::current(),
|
||||
CefThread::GetMessageLoopProxyForThread(CefThread::FILE),
|
||||
CefThread::GetMessageLoopProxyForThread(CefThread::IO),
|
||||
NULL /* special storage policy */,
|
||||
NULL /* quota manager */,
|
||||
file_system_dir_.path(),
|
||||
@ -138,9 +148,6 @@ BrowserFileSystem::BrowserFileSystem() {
|
||||
}
|
||||
}
|
||||
|
||||
BrowserFileSystem::~BrowserFileSystem() {
|
||||
}
|
||||
|
||||
void BrowserFileSystem::OpenFileSystem(
|
||||
WebFrame* frame, WebFileSystem::Type web_filesystem_type,
|
||||
long long, bool create,
|
||||
|
@ -31,6 +31,8 @@ class BrowserFileSystem
|
||||
BrowserFileSystem();
|
||||
virtual ~BrowserFileSystem();
|
||||
|
||||
void CreateContext();
|
||||
|
||||
void OpenFileSystem(WebKit::WebFrame* frame,
|
||||
WebKit::WebFileSystem::Type type,
|
||||
long long size,
|
||||
|
@ -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)));
|
||||
|
||||
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_context_.get(),
|
||||
file_system->file_system_context(),
|
||||
CefThread::GetMessageLoopProxyForThread(CefThread::FILE)));
|
||||
}
|
||||
|
||||
storage_.set_job_factory(job_factory);
|
||||
}
|
||||
|
||||
|
@ -13,10 +13,6 @@
|
||||
|
||||
class FilePath;
|
||||
|
||||
namespace fileapi {
|
||||
class FileSystemContext;
|
||||
}
|
||||
|
||||
namespace webkit_blob {
|
||||
class BlobStorageController;
|
||||
}
|
||||
@ -48,17 +44,12 @@ class BrowserRequestContext : public net::URLRequestContext {
|
||||
return blob_storage_controller_.get();
|
||||
}
|
||||
|
||||
fileapi::FileSystemContext* file_system_context() const {
|
||||
return file_system_context_.get();
|
||||
}
|
||||
|
||||
private:
|
||||
void Init(const FilePath& cache_path, net::HttpCache::Mode cache_mode,
|
||||
bool no_proxy);
|
||||
|
||||
net::URLRequestContextStorage storage_;
|
||||
scoped_ptr<webkit_blob::BlobStorageController> blob_storage_controller_;
|
||||
scoped_refptr<fileapi::FileSystemContext> file_system_context_;
|
||||
scoped_ptr<net::URLSecurityManager> url_security_manager_;
|
||||
FilePath cookie_store_path_;
|
||||
bool accept_all_cookies_;
|
||||
|
@ -95,7 +95,10 @@ WebKit::WebCookieJar* BrowserWebKitInit::cookieJar() {
|
||||
}
|
||||
|
||||
WebKit::WebFileSystem* BrowserWebKitInit::fileSystem() {
|
||||
return &file_system_;
|
||||
BrowserFileSystem* file_system = _Context->file_system();
|
||||
// Create the context if it doesn't already exist.
|
||||
file_system->CreateContext();
|
||||
return file_system;
|
||||
}
|
||||
|
||||
bool BrowserWebKitInit::sandboxEnabled() {
|
||||
|
@ -95,7 +95,6 @@ class BrowserWebKitInit : public webkit_glue::WebKitPlatformSupportImpl {
|
||||
BrowserDatabaseSystem database_system_;
|
||||
BrowserWebCookieJarImpl cookie_jar_;
|
||||
scoped_refptr<BrowserWebBlobRegistryImpl> blob_registry_;
|
||||
BrowserFileSystem file_system_;
|
||||
};
|
||||
|
||||
#endif // _BROWSER_WEBKIT_INIT_H
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define _CEF_CONTEXT_H
|
||||
|
||||
#include "include/cef.h"
|
||||
#include "browser_file_system.h"
|
||||
#include "browser_request_context.h"
|
||||
#include "cef_process.h"
|
||||
#include "dom_storage_context.h"
|
||||
@ -68,6 +69,8 @@ public:
|
||||
{ storage_context_.reset(storage_context); }
|
||||
DOMStorageContext* storage_context() { return storage_context_.get(); }
|
||||
|
||||
BrowserFileSystem* file_system() { return &file_system_; }
|
||||
|
||||
// Used to keep track of the web view host we're dragging over. WARNING:
|
||||
// this pointer should never be dereferenced. Use it only for comparing
|
||||
// pointers.
|
||||
@ -99,6 +102,7 @@ private:
|
||||
FilePath cache_path_;
|
||||
scoped_refptr<BrowserRequestContext> request_context_;
|
||||
scoped_ptr<DOMStorageContext> storage_context_;
|
||||
BrowserFileSystem file_system_;
|
||||
|
||||
// Map of browsers that currently exist.
|
||||
BrowserList browserlist_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user