Skip to content
Permalink
Browse files
Fix MiniBrowser crashes during startup and shutdown
https://bugs.webkit.org/show_bug.cgi?id=47954

Reviewed by Sam Weinig.

* UIProcess/WebContext.cpp:
(WebKit::WebContext::sharedProcessContext):
Initialize the main thread.

(WebKit::WebContext::create):
Ditto.

(WebKit::WebContext::WebContext):
Add the language observer here so we know that it will always be set up.

(WebKit::WebContext::ensureWebProcess):
Remove code.

* UIProcess/WebContext.h:

Canonical link: https://commits.webkit.org/60666@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@70109 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Oct 19, 2010
1 parent b408d20 commit 6cfa2a74743d44c31f110afb72def95c2f7fd34a
Showing 3 changed files with 38 additions and 8 deletions.
@@ -1,3 +1,25 @@
2010-10-19 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.

Fix MiniBrowser crashes during startup and shutdown
https://bugs.webkit.org/show_bug.cgi?id=47954

* UIProcess/WebContext.cpp:
(WebKit::WebContext::sharedProcessContext):
Initialize the main thread.

(WebKit::WebContext::create):
Ditto.

(WebKit::WebContext::WebContext):
Add the language observer here so we know that it will always be set up.

(WebKit::WebContext::ensureWebProcess):
Remove code.

* UIProcess/WebContext.h:

2010-10-19 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.
@@ -61,6 +61,7 @@ static WTF::RefCountedLeakCounter webContextCounter("WebContext");

WebContext* WebContext::sharedProcessContext()
{
WTF::initializeMainThread();
RunLoop::initializeMainRunLoop();
static WebContext* context = adoptRef(new WebContext(ProcessModelSharedSecondaryProcess, String())).leakRef();
return context;
@@ -75,6 +76,7 @@ WebContext* WebContext::sharedThreadContext()

PassRefPtr<WebContext> WebContext::create(const String& injectedBundlePath)
{
WTF::initializeMainThread();
RunLoop::initializeMainRunLoop();
return adoptRef(new WebContext(ProcessModelSecondaryProcess, injectedBundlePath));
}
@@ -88,7 +90,7 @@ WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePa
, m_shouldPaintNativeControls(true)
#endif
{
RunLoop::initializeMainRunLoop();
addLanguageChangeObserver(this, languageChanged);

m_preferences = WebPreferences::shared();
m_preferences->addContext(this);
@@ -124,11 +126,17 @@ void WebContext::initializeHistoryClient(const WKContextHistoryClient* client)
m_process->send(Messages::WebProcess::SetShouldTrackVisitedLinks(m_historyClient.shouldTrackVisitedLinks()), 0);
}

static void languageChanged(void* context)
void WebContext::languageChanged(void* context)
{
WebProcessProxy* process = static_cast<WebContext*>(context)->process();
if (process)
process->send(Messages::WebProcess::LanguageChanged(defaultLanguage()), 0);
static_cast<WebContext*>(context)->languageChanged();
}

void WebContext::languageChanged()
{
if (!hasValidProcess())
return;

m_process->send(Messages::WebProcess::LanguageChanged(defaultLanguage()), 0);
}

void WebContext::ensureWebProcess()
@@ -159,10 +167,7 @@ void WebContext::ensureWebProcess()

parameters.shouldTrackVisitedLinks = m_historyClient.shouldTrackVisitedLinks();
parameters.cacheModel = m_cacheModel;

parameters.languageCode = defaultLanguage();
addLanguageChangeObserver(this, languageChanged);

parameters.applicationCacheDirectory = applicationCacheDirectory();

copyToVector(m_schemesToRegisterAsEmptyDocument, parameters.urlSchemesRegistererdAsEmptyDocument);
@@ -127,6 +127,9 @@ class WebContext : public APIObject {
bool hasValidProcess() const { return m_process && m_process->isValid(); }
void platformInitializeWebProcess(WebProcessCreationParameters&);

static void languageChanged(void* context);
void languageChanged();

ProcessModel m_processModel;

// FIXME: In the future, this should be one or more WebProcessProxies.

0 comments on commit 6cfa2a7

Please sign in to comment.