Changeset 82856 in webkit


Ignore:
Timestamp:
Apr 4, 2011 12:40:47 PM (13 years ago)
Author:
andersca@apple.com
Message:

2011-04-04 Anders Carlsson <andersca@apple.com>

Reviewed by Adam Roben.

Make it easier to send a message to all processes in a context
https://bugs.webkit.org/show_bug.cgi?id=57776

Add WebContext::sendToAllProcesses and WebContext::sendToAllProcessesRelaunchingThemIfNecessary
as a first step towards getting rid of WebContext::process() and getting rid of a class of crashers
where WebContext::process() is null.

  • UIProcess/WebContext.cpp: (WebKit::WebContext::initializeHistoryClient): (WebKit::WebContext::languageChanged): (WebKit::WebContext::setAlwaysUsesComplexTextCodePath): (WebKit::WebContext::registerURLSchemeAsEmptyDocument): (WebKit::WebContext::registerURLSchemeAsSecure): (WebKit::WebContext::setDomainRelaxationForbiddenForURLScheme): (WebKit::WebContext::setCacheModel): (WebKit::WebContext::setDefaultRequestTimeoutInterval): (WebKit::WebContext::clearResourceCaches): (WebKit::WebContext::clearApplicationCache): (WebKit::WebContext::setEnhancedAccessibility): (WebKit::WebContext::startMemorySampler): Use sendToAllProcesses.

(WebKit::WebContext::stopMemorySampler):
Use sendToAllProcesses. This is a slight policy change where we now create a sandbox extension even
if there's no process around. Since this is a debugging tool it seems OK to do this.

  • UIProcess/WebContext.h: Get rid of hasValidProcess.

(WebKit::WebContext::sendToAllProcesses):
If we have a process and we can send messages to it, then do so.

(WebKit::WebContext::sendToAllProcessesRelaunchingThemIfNecessary):
Relaunch the web process and send the message.

  • UIProcess/WebCookieManagerProxy.cpp: (WebKit::WebCookieManagerProxy::deleteCookiesForHostname): (WebKit::WebCookieManagerProxy::deleteAllCookies): (WebKit::WebCookieManagerProxy::startObservingCookieChanges): (WebKit::WebCookieManagerProxy::stopObservingCookieChanges): (WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy): Use sendToAllProcesses and sendToAllProcessesRelaunchingThemIfNecessary.
Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm

    r75907 r82856  
    20642064            *(NPBool *)value = FALSE;
    20652065#else
    2066             *(NPBool *)value = TRUE;
     2066            *(NPBool *)value = FALSE;
    20672067#endif
    20682068            return NPERR_NO_ERROR;
  • trunk/Source/WebKit2/ChangeLog

    r82854 r82856  
     12011-04-04  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Adam Roben.
     4
     5        Make it easier to send a message to all processes in a context
     6        https://bugs.webkit.org/show_bug.cgi?id=57776
     7
     8        Add WebContext::sendToAllProcesses and WebContext::sendToAllProcessesRelaunchingThemIfNecessary
     9        as a first step towards getting rid of WebContext::process() and getting rid of a class of crashers
     10        where WebContext::process() is null.
     11
     12        * UIProcess/WebContext.cpp:
     13        (WebKit::WebContext::initializeHistoryClient):
     14        (WebKit::WebContext::languageChanged):
     15        (WebKit::WebContext::setAlwaysUsesComplexTextCodePath):
     16        (WebKit::WebContext::registerURLSchemeAsEmptyDocument):
     17        (WebKit::WebContext::registerURLSchemeAsSecure):
     18        (WebKit::WebContext::setDomainRelaxationForbiddenForURLScheme):
     19        (WebKit::WebContext::setCacheModel):
     20        (WebKit::WebContext::setDefaultRequestTimeoutInterval):
     21        (WebKit::WebContext::clearResourceCaches):
     22        (WebKit::WebContext::clearApplicationCache):
     23        (WebKit::WebContext::setEnhancedAccessibility):
     24        (WebKit::WebContext::startMemorySampler):
     25        Use sendToAllProcesses.
     26
     27        (WebKit::WebContext::stopMemorySampler):
     28        Use sendToAllProcesses. This is a slight policy change where we now create a sandbox extension even
     29        if there's no process around. Since this is a debugging tool it seems OK to do this.
     30
     31        * UIProcess/WebContext.h:
     32        Get rid of hasValidProcess.
     33
     34        (WebKit::WebContext::sendToAllProcesses):
     35        If we have a process and we can send messages to it, then do so.
     36
     37        (WebKit::WebContext::sendToAllProcessesRelaunchingThemIfNecessary):
     38        Relaunch the web process and send the message.
     39
     40        * UIProcess/WebCookieManagerProxy.cpp:
     41        (WebKit::WebCookieManagerProxy::deleteCookiesForHostname):
     42        (WebKit::WebCookieManagerProxy::deleteAllCookies):
     43        (WebKit::WebCookieManagerProxy::startObservingCookieChanges):
     44        (WebKit::WebCookieManagerProxy::stopObservingCookieChanges):
     45        (WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy):
     46        Use sendToAllProcesses and sendToAllProcessesRelaunchingThemIfNecessary.
     47
    1482011-04-04  Adam Roben  <aroben@apple.com>
    249
  • trunk/Source/WebKit2/UIProcess/WebContext.cpp

    r82458 r82856  
    194194{
    195195    m_historyClient.initialize(client);
    196    
    197     if (!hasValidProcess())
    198         return;
    199        
    200     m_process->send(Messages::WebProcess::SetShouldTrackVisitedLinks(m_historyClient.shouldTrackVisitedLinks()), 0);
     196
     197    sendToAllProcesses(Messages::WebProcess::SetShouldTrackVisitedLinks(m_historyClient.shouldTrackVisitedLinks()));
    201198}
    202199
     
    213210void WebContext::languageChanged()
    214211{
    215     if (!hasValidProcess())
    216         return;
    217 
    218     m_process->send(Messages::WebProcess::LanguageChanged(defaultLanguage()), 0);
     212    sendToAllProcesses(Messages::WebProcess::LanguageChanged(defaultLanguage()));
    219213}
    220214
     
    464458{
    465459    m_alwaysUsesComplexTextCodePath = alwaysUseComplexText;
    466 
    467     if (!hasValidProcess())
    468         return;
    469 
    470     m_process->send(Messages::WebProcess::SetAlwaysUsesComplexTextCodePath(alwaysUseComplexText), 0);
     460    sendToAllProcesses(Messages::WebProcess::SetAlwaysUsesComplexTextCodePath(alwaysUseComplexText));
    471461}
    472462
     
    474464{
    475465    m_schemesToRegisterAsEmptyDocument.add(urlScheme);
    476 
    477     if (!hasValidProcess())
    478         return;
    479 
    480     m_process->send(Messages::WebProcess::RegisterURLSchemeAsEmptyDocument(urlScheme), 0);
     466    sendToAllProcesses(Messages::WebProcess::RegisterURLSchemeAsEmptyDocument(urlScheme));
    481467}
    482468
     
    484470{
    485471    m_schemesToRegisterAsSecure.add(urlScheme);
    486 
    487     if (!hasValidProcess())
    488         return;
    489 
    490     m_process->send(Messages::WebProcess::RegisterURLSchemeAsSecure(urlScheme), 0);
     472    sendToAllProcesses(Messages::WebProcess::RegisterURLSchemeAsSecure(urlScheme));
    491473}
    492474
     
    494476{
    495477    m_schemesToSetDomainRelaxationForbiddenFor.add(urlScheme);
    496 
    497     if (!hasValidProcess())
    498         return;
    499 
    500     m_process->send(Messages::WebProcess::SetDomainRelaxationForbiddenForURLScheme(urlScheme), 0);
     478    sendToAllProcesses(Messages::WebProcess::SetDomainRelaxationForbiddenForURLScheme(urlScheme));
    501479}
    502480
     
    504482{
    505483    m_cacheModel = cacheModel;
    506 
    507     if (!hasValidProcess())
    508         return;
    509     m_process->send(Messages::WebProcess::SetCacheModel(static_cast<uint32_t>(m_cacheModel)), 0);
     484    sendToAllProcesses(Messages::WebProcess::SetCacheModel(static_cast<uint32_t>(m_cacheModel)));
    510485}
    511486
    512487void WebContext::setDefaultRequestTimeoutInterval(double timeoutInterval)
    513488{
    514     if (!hasValidProcess())
    515         return;
    516 
    517     m_process->send(Messages::WebProcess::SetDefaultRequestTimeoutInterval(timeoutInterval), 0);
     489    sendToAllProcesses(Messages::WebProcess::SetDefaultRequestTimeoutInterval(timeoutInterval));
    518490}
    519491
     
    703675void WebContext::clearResourceCaches(ResourceCachesToClear cachesToClear)
    704676{
    705     if (hasValidProcess()) {
    706         m_process->send(Messages::WebProcess::ClearResourceCaches(cachesToClear), 0);
    707         return;
    708     }
     677    if (sendToAllProcesses(Messages::WebProcess::ClearResourceCaches(cachesToClear)))
     678        return;
    709679
    710680    if (cachesToClear == InMemoryResourceCachesOnly)
     
    719689void WebContext::clearApplicationCache()
    720690{
    721     if (!hasValidProcess()) {
    722         // FIXME <rdar://problem/8727879>: Setting this flag ensures that the next time a WebProcess is created, this request to
    723         // clear the application cache will be respected. But if the user quits the application before another WebProcess is created,
    724         // their request will be ignored.
    725         m_clearApplicationCacheForNewWebProcess = true;
    726         return;
    727     }
    728 
    729     m_process->send(Messages::WebProcess::ClearApplicationCache(), 0);
     691    if (sendToAllProcesses(Messages::WebProcess::ClearApplicationCache()))
     692        return;
     693
     694    // FIXME <rdar://problem/8727879>: Setting this flag ensures that the next time a WebProcess is created, this request to
     695    // clear the application cache will be respected. But if the user quits the application before another WebProcess is created,
     696    // their request will be ignored.
     697    m_clearApplicationCacheForNewWebProcess = true;
    730698}
    731699   
    732700void WebContext::setEnhancedAccessibility(bool flag)
    733701{
    734     if (!hasValidProcess())
    735         return;
    736    
    737     m_process->send(Messages::WebProcess::SetEnhancedAccessibility(flag), 0);
     702    sendToAllProcesses(Messages::WebProcess::SetEnhancedAccessibility(flag));
    738703}
    739704   
     
    749714#endif
    750715   
    751     if (!hasValidProcess())
    752         return;
    753    
    754716    // For WebProcess
    755717    SandboxExtension::Handle sampleLogSandboxHandle;   
     
    758720    sampleLogFilePath = SandboxExtension::createHandleForTemporaryFile(sampleLogFilePath, SandboxExtension::WriteOnly, sampleLogSandboxHandle);
    759721   
    760     m_process->send(Messages::WebProcess::StartMemorySampler(sampleLogSandboxHandle, sampleLogFilePath, interval), 0);
     722    sendToAllProcesses(Messages::WebProcess::StartMemorySampler(sampleLogSandboxHandle, sampleLogFilePath, interval));
    761723}
    762724
     
    770732    WebMemorySampler::shared()->stop();
    771733#endif
    772    
    773     if (!hasValidProcess())
    774         return;
    775    
    776     m_process->send(Messages::WebProcess::StopMemorySampler(), 0);
     734
     735    sendToAllProcesses(Messages::WebProcess::StopMemorySampler());
    777736}
    778737
  • trunk/Source/WebKit2/UIProcess/WebContext.h

    r81997 r82856  
    7676    ProcessModel processModel() const { return m_processModel; }
    7777    WebProcessProxy* process() const { return m_process.get(); }
    78     bool hasValidProcess() const { return m_process && m_process->isValid(); }
    79 
     78
     79    template<typename U> bool sendToAllProcesses(const U& message);
     80    template<typename U> bool sendToAllProcessesRelaunchingThemIfNecessary(const U& message);
     81   
    8082    void processDidFinishLaunching(WebProcessProxy*);
    8183
     
    206208    String localStorageDirectory() const;
    207209    String platformDefaultLocalStorageDirectory() const;
    208    
     210
    209211    ProcessModel m_processModel;
    210212   
     
    266268};
    267269
     270template<typename U> inline bool WebContext::sendToAllProcesses(const U& message)
     271{
     272    if (!m_process || !m_process->canSendMessage())
     273        return false;
     274
     275    return m_process->send(message, 0);
     276}
     277
     278template<typename U> bool WebContext::sendToAllProcessesRelaunchingThemIfNecessary(const U& message)
     279{
     280    relaunchProcessIfNecessary();
     281
     282    return m_process->send(message, 0);
     283}
     284
    268285} // namespace WebKit
    269286
  • trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp

    r82458 r82856  
    101101{
    102102    ASSERT(m_webContext);
    103     m_webContext->relaunchProcessIfNecessary();
    104     m_webContext->process()->send(Messages::WebCookieManager::DeleteCookiesForHostname(hostname), 0);
     103    m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::DeleteCookiesForHostname(hostname));
    105104}
    106105
     
    108107{
    109108    ASSERT(m_webContext);
    110     m_webContext->relaunchProcessIfNecessary();
    111     m_webContext->process()->send(Messages::WebCookieManager::DeleteAllCookies(), 0);
     109    m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::DeleteAllCookies());
    112110}
    113111
     
    115113{
    116114    ASSERT(m_webContext);
    117     m_webContext->relaunchProcessIfNecessary();
    118     m_webContext->process()->send(Messages::WebCookieManager::StartObservingCookieChanges(), 0);
     115    m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::StartObservingCookieChanges());
    119116}
    120117
     
    122119{
    123120    ASSERT(m_webContext);
    124     if (!m_webContext->hasValidProcess())
    125         return;
    126     m_webContext->process()->send(Messages::WebCookieManager::StopObservingCookieChanges(), 0);
     121    m_webContext->sendToAllProcesses(Messages::WebCookieManager::StopObservingCookieChanges());
    127122}
    128123
     
    135130{
    136131    ASSERT(m_webContext);
    137     m_webContext->relaunchProcessIfNecessary();
    138132#if PLATFORM(MAC)
    139133    persistHTTPCookieAcceptPolicy(policy);
    140134#endif
    141     m_webContext->process()->send(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy), 0);
     135
     136    m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy));
    142137}
    143138
Note: See TracChangeset for help on using the changeset viewer.