mirror of
https://github.com/electron/electron.git
synced 2026-01-26 07:48:08 -05:00
Fix race condition when initializing request context getter.
Note that we are calling GetURLRequestContext() in the UI thread when using the protocol module, this should in fact not be allowed, but for now we just use the workaround of making sure the request context getter has been initialized before we use the protocol module.
This commit is contained in:
@@ -66,6 +66,7 @@ AtomURLRequestContextGetter::~AtomURLRequestContextGetter() {
|
||||
net::URLRequestContext* AtomURLRequestContextGetter::GetURLRequestContext() {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
||||
|
||||
base::AutoLock auto_lock(lock_);
|
||||
if (!url_request_context_.get()) {
|
||||
url_request_context_.reset(new net::URLRequestContext());
|
||||
network_delegate_ = network_delegate_factory_.Run().Pass();
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "base/callback.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "content/public/browser/content_browser_client.h"
|
||||
#include "net/url_request/url_request_context_getter.h"
|
||||
|
||||
@@ -59,6 +60,8 @@ class AtomURLRequestContextGetter : public net::URLRequestContextGetter {
|
||||
base::Callback<scoped_ptr<brightray::NetworkDelegate>(void)>
|
||||
network_delegate_factory_;
|
||||
|
||||
base::Lock lock_;
|
||||
|
||||
scoped_ptr<net::ProxyConfigService> proxy_config_service_;
|
||||
scoped_ptr<brightray::NetworkDelegate> network_delegate_;
|
||||
scoped_ptr<net::URLRequestContextStorage> storage_;
|
||||
|
||||
Reference in New Issue
Block a user