Changeset 46609 in webkit


Ignore:
Timestamp:
Jul 30, 2009 4:08:33 PM (15 years ago)
Author:
darin@chromium.org
Message:

2009-07-30 Michael Nordman <Michael Nordman>

Reviewed by Darin Fisher.

https://bugs.webkit.org/show_bug.cgi?id=27821

ApplicationCacheHost refactoring.


1) Better encapsulate the interfaces between webcore common code
and the appcache system within a new class ApplicationCacheHost.

2) Use that interface throughout the loader system, replacing inline appcache logic.

3) Implement the interface in terms of webcore's appcache system.

4) Add the new files to various makefiles.

5) Implement protocolHostAndPortAreEqual() in KURLGoogle.cpp

No new features, no new tests. The existing layout tests all pass.

  • GNUmakefile.am:
  • WebCore.base.exp:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • WebCoreSources.bkl:
  • html/HTMLHtmlElement.cpp: (WebCore::HTMLHtmlElement::insertedIntoDocument):
  • loader/DocumentLoader.cpp: (WebCore::DocumentLoader::DocumentLoader): (WebCore::DocumentLoader::~DocumentLoader): (WebCore::DocumentLoader::mainReceivedError): (WebCore::DocumentLoader::detachFromFrame): (WebCore::DocumentLoader::setPrimaryLoadComplete):
  • loader/DocumentLoader.h: (WebCore::DocumentLoader::applicationCacheHost):
  • loader/FrameLoader.cpp: (WebCore::FrameLoader::canCachePageContainingThisFrame): (WebCore::FrameLoader::logCanCacheFrameDecision): (WebCore::FrameLoader::loadResourceSynchronously):
  • loader/MainResourceLoader.cpp: (WebCore::MainResourceLoader::didReceiveResponse): (WebCore::MainResourceLoader::didReceiveData): (WebCore::MainResourceLoader::didFinishLoading): (WebCore::MainResourceLoader::didFail): (WebCore::MainResourceLoader::load):
  • loader/MainResourceLoader.h:
  • loader/ResourceLoader.cpp: (WebCore::ResourceLoader::load): (WebCore::ResourceLoader::willSendRequest): (WebCore::ResourceLoader::didReceiveResponse): (WebCore::ResourceLoader::didFail):
  • loader/ResourceLoader.h:
  • loader/appcache/ApplicationCacheGroup.cpp: (WebCore::ApplicationCacheGroup::selectCache): (WebCore::ApplicationCacheGroup::selectCacheWithoutManifestURL): (WebCore::ApplicationCacheGroup::finishedLoadingMainResource): (WebCore::ApplicationCacheGroup::failedLoadingMainResource): (WebCore::ApplicationCacheGroup::disassociateDocumentLoader): (WebCore::ApplicationCacheGroup::update): (WebCore::ApplicationCacheGroup::didFinishLoadingManifest): (WebCore::ApplicationCacheGroup::manifestNotFound): (WebCore::ApplicationCacheGroup::checkIfLoadIsComplete): (WebCore::ApplicationCacheGroup::startLoadingEntry): (WebCore::ApplicationCacheGroup::associateDocumentLoaderWithCache): (WebCore::CallCacheListenerTask::create): (WebCore::CallCacheListenerTask::performTask): (WebCore::CallCacheListenerTask::CallCacheListenerTask): (WebCore::ApplicationCacheGroup::postListenerTask):
  • loader/appcache/ApplicationCacheGroup.h:
  • loader/appcache/ApplicationCacheHost.cpp: Added.
  • loader/appcache/ApplicationCacheHost.h: Added.
  • loader/appcache/ApplicationCacheStorage.cpp: (WebCore::ApplicationCacheStorage::transferApplicationCache):
  • loader/appcache/ApplicationCacheStorage.h:
  • loader/appcache/DOMApplicationCache.cpp: (WebCore::DOMApplicationCache::DOMApplicationCache): (WebCore::DOMApplicationCache::disconnectFrame): (WebCore::DOMApplicationCache::applicationCacheHost): (WebCore::DOMApplicationCache::status): (WebCore::DOMApplicationCache::update): (WebCore::DOMApplicationCache::swapCache): (WebCore::DOMApplicationCache::addEventListener): (WebCore::DOMApplicationCache::removeEventListener): (WebCore::DOMApplicationCache::dispatchEvent): (WebCore::DOMApplicationCache::callListener): (WebCore::DOMApplicationCache::toEventName): (WebCore::DOMApplicationCache::toEventType):
  • loader/appcache/DOMApplicationCache.h: (WebCore::DOMApplicationCache::): (WebCore::DOMApplicationCache::setAttributeEventListener): (WebCore::DOMApplicationCache::getAttributeEventListener): (WebCore::DOMApplicationCache::clearAttributeEventListener): (WebCore::DOMApplicationCache::callEventListener): (WebCore::DOMApplicationCache::setOnchecking): (WebCore::DOMApplicationCache::onchecking): (WebCore::DOMApplicationCache::setOnerror): (WebCore::DOMApplicationCache::onerror): (WebCore::DOMApplicationCache::setOnnoupdate): (WebCore::DOMApplicationCache::onnoupdate): (WebCore::DOMApplicationCache::setOndownloading): (WebCore::DOMApplicationCache::ondownloading): (WebCore::DOMApplicationCache::setOnprogress): (WebCore::DOMApplicationCache::onprogress): (WebCore::DOMApplicationCache::setOnupdateready): (WebCore::DOMApplicationCache::onupdateready): (WebCore::DOMApplicationCache::setOncached): (WebCore::DOMApplicationCache::oncached): (WebCore::DOMApplicationCache::setOnobsolete): (WebCore::DOMApplicationCache::onobsolete): (WebCore::DOMApplicationCache::~DOMApplicationCache):
  • platform/KURLGoogle.cpp: (WebCore::protocolHostAndPortAreEqual):
Location:
trunk
Files:
2 added
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r46606 r46609  
     12009-07-30  Michael Nordman  <michaeln@google.com>
     2
     3        Reviewed by Darin Fisher.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=27821
     6
     7        ApplicationCacheHost refactoring.
     8       
     9        1) Better encapsulate the interfaces between webcore common code
     10        and the appcache system within a new class ApplicationCacheHost.
     11
     12        2) Use that interface throughout the loader system, replacing inline appcache logic.
     13
     14        3) Implement the interface in terms of webcore's appcache system.
     15
     16        4) Add the new files to various makefiles.
     17
     18        5) Implement protocolHostAndPortAreEqual() in KURLGoogle.cpp
     19
     20        No new features, no new tests. The existing layout tests all pass.
     21
     22        * GNUmakefile.am:
     23        * WebCore.base.exp:
     24        * WebCore.gypi:
     25        * WebCore.pro:
     26        * WebCore.vcproj/WebCore.vcproj:
     27        * WebCore.xcodeproj/project.pbxproj:
     28        * WebCoreSources.bkl:
     29        * html/HTMLHtmlElement.cpp:
     30        (WebCore::HTMLHtmlElement::insertedIntoDocument):
     31        * loader/DocumentLoader.cpp:
     32        (WebCore::DocumentLoader::DocumentLoader):
     33        (WebCore::DocumentLoader::~DocumentLoader):
     34        (WebCore::DocumentLoader::mainReceivedError):
     35        (WebCore::DocumentLoader::detachFromFrame):
     36        (WebCore::DocumentLoader::setPrimaryLoadComplete):
     37        * loader/DocumentLoader.h:
     38        (WebCore::DocumentLoader::applicationCacheHost):
     39        * loader/FrameLoader.cpp:
     40        (WebCore::FrameLoader::canCachePageContainingThisFrame):
     41        (WebCore::FrameLoader::logCanCacheFrameDecision):
     42        (WebCore::FrameLoader::loadResourceSynchronously):
     43        * loader/MainResourceLoader.cpp:
     44        (WebCore::MainResourceLoader::didReceiveResponse):
     45        (WebCore::MainResourceLoader::didReceiveData):
     46        (WebCore::MainResourceLoader::didFinishLoading):
     47        (WebCore::MainResourceLoader::didFail):
     48        (WebCore::MainResourceLoader::load):
     49        * loader/MainResourceLoader.h:
     50        * loader/ResourceLoader.cpp:
     51        (WebCore::ResourceLoader::load):
     52        (WebCore::ResourceLoader::willSendRequest):
     53        (WebCore::ResourceLoader::didReceiveResponse):
     54        (WebCore::ResourceLoader::didFail):
     55        * loader/ResourceLoader.h:
     56        * loader/appcache/ApplicationCacheGroup.cpp:
     57        (WebCore::ApplicationCacheGroup::selectCache):
     58        (WebCore::ApplicationCacheGroup::selectCacheWithoutManifestURL):
     59        (WebCore::ApplicationCacheGroup::finishedLoadingMainResource):
     60        (WebCore::ApplicationCacheGroup::failedLoadingMainResource):
     61        (WebCore::ApplicationCacheGroup::disassociateDocumentLoader):
     62        (WebCore::ApplicationCacheGroup::update):
     63        (WebCore::ApplicationCacheGroup::didFinishLoadingManifest):
     64        (WebCore::ApplicationCacheGroup::manifestNotFound):
     65        (WebCore::ApplicationCacheGroup::checkIfLoadIsComplete):
     66        (WebCore::ApplicationCacheGroup::startLoadingEntry):
     67        (WebCore::ApplicationCacheGroup::associateDocumentLoaderWithCache):
     68        (WebCore::CallCacheListenerTask::create):
     69        (WebCore::CallCacheListenerTask::performTask):
     70        (WebCore::CallCacheListenerTask::CallCacheListenerTask):
     71        (WebCore::ApplicationCacheGroup::postListenerTask):
     72        * loader/appcache/ApplicationCacheGroup.h:
     73        * loader/appcache/ApplicationCacheHost.cpp: Added.
     74        * loader/appcache/ApplicationCacheHost.h: Added.
     75        * loader/appcache/ApplicationCacheStorage.cpp:
     76        (WebCore::ApplicationCacheStorage::transferApplicationCache):
     77        * loader/appcache/ApplicationCacheStorage.h:
     78        * loader/appcache/DOMApplicationCache.cpp:
     79        (WebCore::DOMApplicationCache::DOMApplicationCache):
     80        (WebCore::DOMApplicationCache::disconnectFrame):
     81        (WebCore::DOMApplicationCache::applicationCacheHost):
     82        (WebCore::DOMApplicationCache::status):
     83        (WebCore::DOMApplicationCache::update):
     84        (WebCore::DOMApplicationCache::swapCache):
     85        (WebCore::DOMApplicationCache::addEventListener):
     86        (WebCore::DOMApplicationCache::removeEventListener):
     87        (WebCore::DOMApplicationCache::dispatchEvent):
     88        (WebCore::DOMApplicationCache::callListener):
     89        (WebCore::DOMApplicationCache::toEventName):
     90        (WebCore::DOMApplicationCache::toEventType):
     91        * loader/appcache/DOMApplicationCache.h:
     92        (WebCore::DOMApplicationCache::):
     93        (WebCore::DOMApplicationCache::setAttributeEventListener):
     94        (WebCore::DOMApplicationCache::getAttributeEventListener):
     95        (WebCore::DOMApplicationCache::clearAttributeEventListener):
     96        (WebCore::DOMApplicationCache::callEventListener):
     97        (WebCore::DOMApplicationCache::setOnchecking):
     98        (WebCore::DOMApplicationCache::onchecking):
     99        (WebCore::DOMApplicationCache::setOnerror):
     100        (WebCore::DOMApplicationCache::onerror):
     101        (WebCore::DOMApplicationCache::setOnnoupdate):
     102        (WebCore::DOMApplicationCache::onnoupdate):
     103        (WebCore::DOMApplicationCache::setOndownloading):
     104        (WebCore::DOMApplicationCache::ondownloading):
     105        (WebCore::DOMApplicationCache::setOnprogress):
     106        (WebCore::DOMApplicationCache::onprogress):
     107        (WebCore::DOMApplicationCache::setOnupdateready):
     108        (WebCore::DOMApplicationCache::onupdateready):
     109        (WebCore::DOMApplicationCache::setOncached):
     110        (WebCore::DOMApplicationCache::oncached):
     111        (WebCore::DOMApplicationCache::setOnobsolete):
     112        (WebCore::DOMApplicationCache::onobsolete):
     113        (WebCore::DOMApplicationCache::~DOMApplicationCache):
     114        * platform/KURLGoogle.cpp:
     115        (WebCore::protocolHostAndPortAreEqual):
     116
    11172009-07-30  Chris Fleizach  <cfleizach@apple.com>
    2118
  • trunk/WebCore/GNUmakefile.am

    r46509 r46609  
    20072007        WebCore/loader/appcache/ApplicationCacheGroup.cpp \
    20082008        WebCore/loader/appcache/ApplicationCacheGroup.h \
     2009        WebCore/loader/appcache/ApplicationCacheHost.cpp \
     2010        WebCore/loader/appcache/ApplicationCacheHost.h \
    20092011        WebCore/loader/appcache/ApplicationCacheResource.cpp \
    20102012        WebCore/loader/appcache/ApplicationCacheResource.h \
  • trunk/WebCore/WebCore.base.exp

    r46449 r46609  
    444444__ZN7WebCore22externalRepresentationEPNS_12RenderObjectE
    445445__ZN7WebCore23ApplicationCacheStorage14setMaximumSizeEx
    446 __ZN7WebCore23ApplicationCacheStorage16storeCopyOfCacheERKNS_6StringEPNS_16ApplicationCacheE
     446__ZN7WebCore23ApplicationCacheStorage24transferApplicationCacheERKNS_6StringEPNS_20ApplicationCacheHostE
    447447__ZN7WebCore23ApplicationCacheStorage17setCacheDirectoryERKNS_6StringE
    448448__ZN7WebCore23ApplicationCacheStorage18vacuumDatabaseFileEv
  • trunk/WebCore/WebCore.gypi

    r46529 r46609  
    14261426            'loader/appcache/ApplicationCacheGroup.cpp',
    14271427            'loader/appcache/ApplicationCacheGroup.h',
     1428            'loader/appcache/ApplicationCacheHost.cpp',
     1429            'loader/appcache/ApplicationCacheHost.h',
    14281430            'loader/appcache/ApplicationCacheResource.cpp',
    14291431            'loader/appcache/ApplicationCacheResource.h',
  • trunk/WebCore/WebCore.pro

    r46522 r46609  
    15141514    inspector/JavaScriptProfileNode.h \
    15151515    loader/appcache/ApplicationCacheGroup.h \
     1516    loader/appcache/ApplicationCacheHost.h \
    15161517    loader/appcache/ApplicationCache.h \
    15171518    loader/appcache/ApplicationCacheResource.h \
     
    30343035    loader/appcache/ApplicationCache.cpp \
    30353036    loader/appcache/ApplicationCacheGroup.cpp \
     3037    loader/appcache/ApplicationCacheHost.cpp \
    30363038    loader/appcache/ApplicationCacheStorage.cpp \
    30373039    loader/appcache/ApplicationCacheResource.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r46507 r46609  
    1729417294                                <File
    1729517295                                        RelativePath="..\loader\appcache\ApplicationCacheGroup.h"
     17296                                        >
     17297                                </File>
     17298                                <File
     17299                                        RelativePath="..\loader\appcache\ApplicationCacheHost.cpp"
     17300                                        >
     17301                                </File>
     17302                                <File
     17303                                        RelativePath="..\loader\appcache\ApplicationCacheHost.h"
    1729617304                                        >
    1729717305                                </File>
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r46507 r46609  
    353353                1A8F6BC10DB55CDC001DB794 /* ApplicationCacheResource.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8F6BB60DB55CDC001DB794 /* ApplicationCacheResource.h */; };
    354354                1A8F6BC20DB55CDC001DB794 /* DOMApplicationCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8F6BB70DB55CDC001DB794 /* DOMApplicationCache.cpp */; };
    355                 1A8F6BC30DB55CDC001DB794 /* DOMApplicationCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8F6BB80DB55CDC001DB794 /* DOMApplicationCache.h */; };
     355                1A8F6BC30DB55CDC001DB794 /* DOMApplicationCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8F6BB80DB55CDC001DB794 /* DOMApplicationCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
    356356                1A8F6BC50DB55CDC001DB794 /* ManifestParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8F6BBA0DB55CDC001DB794 /* ManifestParser.cpp */; };
    357357                1A8F6BC60DB55CDC001DB794 /* ManifestParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8F6BBB0DB55CDC001DB794 /* ManifestParser.h */; };
     
    525525                1CF6BE150E9BB4670025E1CD /* ObjCNodeFilterCondition.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CF6BE130E9BB4670025E1CD /* ObjCNodeFilterCondition.h */; };
    526526                1CFAE3230A6D6A3F0032593D /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CFAE3220A6D6A3F0032593D /* libobjc.dylib */; };
     527                24F54EAC101FE914000AE741 /* ApplicationCacheHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 24F54EAA101FE914000AE741 /* ApplicationCacheHost.cpp */; };
     528                24F54EAD101FE914000AE741 /* ApplicationCacheHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 24F54EAB101FE914000AE741 /* ApplicationCacheHost.h */; settings = {ATTRIBUTES = (Private, ); }; };
    527529                29A812260FBB9C1D00510293 /* AccessibilityRenderObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29A812080FBB9C1D00510293 /* AccessibilityRenderObject.cpp */; };
    528530                29A812270FBB9C1D00510293 /* AccessibilityTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29A812090FBB9C1D00510293 /* AccessibilityTable.cpp */; };
     
    54885490                1CF6BE130E9BB4670025E1CD /* ObjCNodeFilterCondition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjCNodeFilterCondition.h; sourceTree = "<group>"; };
    54895491                1CFAE3220A6D6A3F0032593D /* libobjc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libobjc.dylib; path = /usr/lib/libobjc.dylib; sourceTree = "<absolute>"; };
     5492                24F54EAA101FE914000AE741 /* ApplicationCacheHost.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplicationCacheHost.cpp; sourceTree = "<group>"; };
     5493                24F54EAB101FE914000AE741 /* ApplicationCacheHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationCacheHost.h; sourceTree = "<group>"; };
    54905494                29A812080FBB9C1D00510293 /* AccessibilityRenderObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityRenderObject.cpp; sourceTree = "<group>"; };
    54915495                29A812090FBB9C1D00510293 /* AccessibilityTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityTable.cpp; sourceTree = "<group>"; };
     
    97099713                        isa = PBXGroup;
    97109714                        children = (
     9715                                24F54EAA101FE914000AE741 /* ApplicationCacheHost.cpp */,
     9716                                24F54EAB101FE914000AE741 /* ApplicationCacheHost.h */,
    97119717                                1A8F6BB10DB55CDC001DB794 /* ApplicationCache.cpp */,
    97129718                                1A8F6BB20DB55CDC001DB794 /* ApplicationCache.h */,
     
    1706317069                                7A74ECBB101839A600BF939E /* InspectorBackend.h in Headers */,
    1706417070                                7A1E88F6101CC384000C4DF5 /* ScriptArray.h in Headers */,
     17071                                24F54EAD101FE914000AE741 /* ApplicationCacheHost.h in Headers */,
    1706517072                                41A3D58F101C152D00316D07 /* DedicatedWorkerThread.h in Headers */,
    1706617073                        );
     
    1910519112                                7A74ECBD101839DA00BF939E /* JSInspectorBackendCustom.cpp in Sources */,
    1910619113                                7A1E88F5101CC384000C4DF5 /* ScriptArray.cpp in Sources */,
     19114                                24F54EAC101FE914000AE741 /* ApplicationCacheHost.cpp in Sources */,
    1910719115                                41A3D58E101C152D00316D07 /* DedicatedWorkerThread.cpp in Sources */,
    1910819116                        );
  • trunk/WebCore/WebCoreSources.bkl

    r46490 r46609  
    677677        loader/appcache/ApplicationCache.cpp
    678678        loader/appcache/ApplicationCacheGroup.cpp
     679        loader/appcache/ApplicationCacheHost.cpp
    679680        loader/appcache/ApplicationCacheResource.cpp
    680681        loader/appcache/DOMApplicationCache.cpp
  • trunk/WebCore/html/HTMLHtmlElement.cpp

    r43215 r46609  
    2424#include "HTMLHtmlElement.h"
    2525
    26 #include "ApplicationCacheGroup.h"
     26#if ENABLE(OFFLINE_WEB_APPLICATIONS)
     27#include "ApplicationCacheHost.h"
     28#endif
     29
    2730#include "Document.h"
     31#include "DocumentLoader.h"
     32#include "Frame.h"
    2833#include "HTMLNames.h"
    2934
     
    6974        return;
    7075
     76    DocumentLoader* documentLoader = document()->frame()->loader()->documentLoader();
     77    if (!documentLoader)
     78        return;
     79
    7180    // Check the manifest attribute
    7281    AtomicString manifest = getAttribute(manifestAttr);
    73     if (manifest.isNull())
    74         ApplicationCacheGroup::selectCacheWithoutManifestURL(document()->frame());
     82    if (manifest.isEmpty())
     83        documentLoader->applicationCacheHost()->selectCacheWithoutManifest();
    7584    else
    76         ApplicationCacheGroup::selectCache(document()->frame(), document()->completeURL(manifest));
     85        documentLoader->applicationCacheHost()->selectCacheWithManifest(document()->completeURL(manifest));
    7786}
    7887#endif
  • trunk/WebCore/loader/DocumentLoader.cpp

    r44943 r46609  
    3030#include "DocumentLoader.h"
    3131
    32 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
    33 #include "ApplicationCache.h"
    34 #include "ApplicationCacheGroup.h"
    35 #include "ApplicationCacheResource.h"
    36 #endif
    3732#include "ArchiveFactory.h"
    3833#include "ArchiveResourceCollection.h"
     
    154149    , m_didCreateGlobalHistoryEntry(false)
    155150#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    156     , m_candidateApplicationCacheGroup(0)
     151    , m_applicationCacheHost(this)
    157152#endif
    158153{
     
    169164{
    170165    ASSERT(!m_frame || frameLoader()->activeDocumentLoader() != this || !frameLoader()->isLoading());
    171    
    172 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
    173     if (m_applicationCache)
    174         m_applicationCache->group()->disassociateDocumentLoader(this);
    175     else if (m_candidateApplicationCacheGroup)
    176         m_candidateApplicationCacheGroup->disassociateDocumentLoader(this);
    177 #endif
    178166}
    179167
     
    259247
    260248#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    261     ApplicationCacheGroup* group = m_candidateApplicationCacheGroup;
    262     if (!group && m_applicationCache) {
    263         ASSERT(!mainResourceApplicationCache()); // If the main resource were loaded from a cache, it wouldn't fail.
    264         group = m_applicationCache->group();
    265     }
    266    
    267     if (group)
    268         group->failedLoadingMainResource(this);
     249    m_applicationCacheHost.failedLoadingMainResource();
    269250#endif
    270251   
     
    431412{
    432413    ASSERT(m_frame);
     414#if ENABLE(OFFLINE_WEB_APPLICATIONS)
     415    m_applicationCacheHost.setDOMApplicationCache(0);
     416#endif
    433417    m_frame = 0;
    434418}
     
    452436        if (m_mainResourceLoader) {
    453437            m_mainResourceData = m_mainResourceLoader->resourceData();
    454 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
    455             m_mainResourceApplicationCache = m_mainResourceLoader->applicationCache();
    456 #endif
    457438            m_mainResourceLoader = 0;
    458439        }
     
    848829}
    849830
    850 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
    851 void DocumentLoader::setCandidateApplicationCacheGroup(ApplicationCacheGroup* group)
    852 {
    853     ASSERT(!m_applicationCache);
    854     m_candidateApplicationCacheGroup = group;
    855 }
    856    
    857 void DocumentLoader::setApplicationCache(PassRefPtr<ApplicationCache> applicationCache)
    858 {
    859     if (m_candidateApplicationCacheGroup) {
    860         ASSERT(!m_applicationCache);
    861         m_candidateApplicationCacheGroup = 0;
    862     }
    863 
    864     m_applicationCache = applicationCache;
    865 }
    866 
    867 ApplicationCache* DocumentLoader::mainResourceApplicationCache() const
    868 {
    869     if (m_mainResourceApplicationCache)
    870         return m_mainResourceApplicationCache.get();
    871     if (m_mainResourceLoader)
    872         return m_mainResourceLoader->applicationCache();
    873     return 0;
    874 }
    875 
    876 bool DocumentLoader::shouldLoadResourceFromApplicationCache(const ResourceRequest& request, ApplicationCacheResource*& resource)
    877 {
    878     ApplicationCache* cache = applicationCache();
    879     if (!cache || !cache->isComplete())
    880         return false;
    881 
    882     // If the resource is not a HTTP/HTTPS GET, then abort
    883     if (!ApplicationCache::requestIsHTTPOrHTTPSGet(request))
    884         return false;
    885 
    886     // If the resource's URL is an master entry, the manifest, an explicit entry, or a fallback entry
    887     // in the application cache, then get the resource from the cache (instead of fetching it).
    888     resource = cache->resourceForURL(request.url());
    889 
    890     // Resources that match fallback namespaces or online whitelist entries are fetched from the network,
    891     // unless they are also cached.
    892     if (!resource && (cache->urlMatchesFallbackNamespace(request.url()) || cache->isURLInOnlineWhitelist(request.url())))
    893         return false;
    894 
    895     // Resources that are not present in the manifest will always fail to load (at least, after the
    896     // cache has been primed the first time), making the testing of offline applications simpler.
    897     return true;
    898 }
    899 
    900 bool DocumentLoader::getApplicationCacheFallbackResource(const ResourceRequest& request, ApplicationCacheResource*& resource, ApplicationCache* cache)
    901 {
    902     if (!cache) {
    903         cache = applicationCache();
    904         if (!cache)
    905             return false;
    906     }
    907     if (!cache->isComplete())
    908         return false;
    909    
    910     // If the resource is not a HTTP/HTTPS GET, then abort
    911     if (!ApplicationCache::requestIsHTTPOrHTTPSGet(request))
    912         return false;
    913 
    914     KURL fallbackURL;
    915     if (!cache->urlMatchesFallbackNamespace(request.url(), &fallbackURL))
    916         return false;
    917 
    918     resource = cache->resourceForURL(fallbackURL);
    919     ASSERT(resource);
    920 
    921     return true;
    922 }
    923 
    924 bool DocumentLoader::scheduleApplicationCacheLoad(ResourceLoader* loader, const ResourceRequest& request, const KURL& originalURL)
    925 {
    926     if (!frameLoader()->frame()->settings() || !frameLoader()->frame()->settings()->offlineWebApplicationCacheEnabled())
    927         return false;
    928    
    929     if (request.url() != originalURL)
    930         return false;
    931 
    932     ApplicationCacheResource* resource;
    933     if (!shouldLoadResourceFromApplicationCache(request, resource))
    934         return false;
    935    
    936     m_pendingSubstituteResources.set(loader, resource);
    937     deliverSubstituteResourcesAfterDelay();
    938        
    939     return true;
    940 }
    941 
    942 bool DocumentLoader::scheduleLoadFallbackResourceFromApplicationCache(ResourceLoader* loader, const ResourceRequest& request, ApplicationCache* cache)
    943 {
    944     if (!frameLoader()->frame()->settings() || !frameLoader()->frame()->settings()->offlineWebApplicationCacheEnabled())
    945         return false;
    946 
    947     ApplicationCacheResource* resource;
    948     if (!getApplicationCacheFallbackResource(request, resource, cache))
    949         return false;
    950 
    951     m_pendingSubstituteResources.set(loader, resource);
    952     deliverSubstituteResourcesAfterDelay();
    953        
    954     return true;
    955 }
    956 
    957 #endif // ENABLE(OFFLINE_WEB_APPLICATIONS)
    958 
    959 }
     831}
  • trunk/WebCore/loader/DocumentLoader.h

    r44468 r46609  
    3030#define DocumentLoader_h
    3131
     32#if ENABLE(OFFLINE_WEB_APPLICATIONS)
     33#include "ApplicationCacheHost.h"
     34#endif
     35
    3236#include "NavigationAction.h"
    3337#include "ResourceError.h"
     
    3943namespace WebCore {
    4044
    41     class ApplicationCache;
    42     class ApplicationCacheGroup;
    43     class ApplicationCacheResource;
    4445    class Archive;
    4546    class ArchiveResource;
     
    208209
    209210#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    210         bool scheduleApplicationCacheLoad(ResourceLoader*, const ResourceRequest&, const KURL& originalURL);
    211         bool scheduleLoadFallbackResourceFromApplicationCache(ResourceLoader*, const ResourceRequest&, ApplicationCache* = 0);
    212         bool shouldLoadResourceFromApplicationCache(const ResourceRequest&, ApplicationCacheResource*&);
    213         bool getApplicationCacheFallbackResource(const ResourceRequest&, ApplicationCacheResource*&, ApplicationCache* = 0);
    214        
    215         void setCandidateApplicationCacheGroup(ApplicationCacheGroup* group);
    216         ApplicationCacheGroup* candidateApplicationCacheGroup() const { return m_candidateApplicationCacheGroup; }
    217        
    218         void setApplicationCache(PassRefPtr<ApplicationCache> applicationCache);
    219         ApplicationCache* applicationCache() const { return m_applicationCache.get(); }
    220 
    221         ApplicationCache* mainResourceApplicationCache() const;
     211        ApplicationCacheHost* applicationCacheHost() { return &m_applicationCacheHost; }
    222212#endif
    223213
     
    307297        bool m_didCreateGlobalHistoryEntry;
    308298
    309 #if ENABLE(OFFLINE_WEB_APPLICATIONS) 
    310         // The application cache that the document loader is associated with (if any).
    311         RefPtr<ApplicationCache> m_applicationCache;
    312        
    313         // Before an application cache has finished loading, this will be the candidate application
    314         // group that the document loader is associated with.
    315         ApplicationCacheGroup* m_candidateApplicationCacheGroup;
    316        
    317         // Once the main resource has finished loading, this is the application cache it was loaded from (if any).
    318         RefPtr<ApplicationCache> m_mainResourceApplicationCache;
     299#if ENABLE(OFFLINE_WEB_APPLICATIONS)
     300        friend class ApplicationCacheHost;  // for substitute resource delivery
     301        ApplicationCacheHost m_applicationCacheHost;
    319302#endif
    320303    };
  • trunk/WebCore/loader/FrameLoader.cpp

    r46592 r46609  
    9696
    9797#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    98 #include "ApplicationCache.h"
    99 #include "ApplicationCacheResource.h"
     98#include "ApplicationCacheHost.h"
    10099#endif
    101100
     
    18171816        // FIXME: We should investigating caching frames that have an associated
    18181817        // application cache. <rdar://problem/5917899> tracks that work.
    1819         && !m_documentLoader->applicationCache()
    1820         && !m_documentLoader->candidateApplicationCacheGroup()
     1818        && m_documentLoader->applicationCacheHost()->canCacheInPageCache()
    18211819#endif
    18221820#if ENABLE(WML)
     
    19681966            { PCLOG("   -The document cannot suspect its active DOM Objects"); cannotCache = true; }
    19691967#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    1970         if (m_documentLoader->applicationCache())
    1971             { PCLOG("   -The DocumentLoader has an active application cache"); cannotCache = true; }
    1972         if (m_documentLoader->candidateApplicationCacheGroup())
    1973             { PCLOG("   -The DocumentLoader has a candidateApplicationCacheGroup"); cannotCache = true; }
     1968        if (!m_documentLoader->applicationCacheHost()->canCacheInPageCache())
     1969            { PCLOG("   -The DocumentLoader uses an application cache"); cannotCache = true; }
    19741970#endif
    19751971        if (!m_client->canCachePage())
     
    36823678       
    36833679#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    3684         ApplicationCacheResource* resource;
    3685         if (documentLoader()->shouldLoadResourceFromApplicationCache(newRequest, resource)) {
    3686             if (resource) {
    3687                 response = resource->response();
    3688                 data.append(resource->data()->data(), resource->data()->size());
    3689             } else
    3690                 error = cannotShowURLError(newRequest);
    3691         } else {
     3680        if (!documentLoader()->applicationCacheHost()->maybeLoadSynchronously(newRequest, error, response, data)) {
    36923681#endif
    36933682            ResourceHandle::loadResourceSynchronously(newRequest, storedCredentials, error, response, data, m_frame);
    3694 
    36953683#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    3696             // If normal loading results in a redirect to a resource with another origin (indicative of a captive portal), or a 4xx or 5xx status code or equivalent,
    3697             // or if there were network errors (but not if the user canceled the download), then instead get, from the cache, the resource of the fallback entry
    3698             // corresponding to the matched namespace.
    3699             if ((!error.isNull() && !error.isCancellation())
    3700                  || response.httpStatusCode() / 100 == 4 || response.httpStatusCode() / 100 == 5
    3701                  || !protocolHostAndPortAreEqual(newRequest.url(), response.url())) {
    3702                 if (documentLoader()->getApplicationCacheFallbackResource(newRequest, resource)) {
    3703                     response = resource->response();
    3704                     data.clear();
    3705                     data.append(resource->data()->data(), resource->data()->size());
    3706                 }
    3707             }
     3684            documentLoader()->applicationCacheHost()->maybeLoadFallbackSynchronously(newRequest, error, response, data);
    37083685        }
    37093686#endif
  • trunk/WebCore/loader/MainResourceLoader.cpp

    r44047 r46609  
    4343
    4444#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    45 #include "ApplicationCache.h"
    46 #include "ApplicationCacheGroup.h"
    47 #include "ApplicationCacheResource.h"
     45#include "ApplicationCacheHost.h"
    4846#endif
    4947
     
    284282{
    285283#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    286     if (r.httpStatusCode() / 100 == 4 || r.httpStatusCode() / 100 == 5) {
    287         ASSERT(!m_applicationCache);
    288         if (m_frame->settings() && m_frame->settings()->offlineWebApplicationCacheEnabled()) {
    289             m_applicationCache = ApplicationCacheGroup::fallbackCacheForMainRequest(request(), documentLoader());
    290 
    291             if (scheduleLoadFallbackResourceFromApplicationCache(m_applicationCache.get()))
    292                 return;
    293         }
    294     }
     284    if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForMainResponse(request(), r))
     285        return;
    295286#endif
    296287
     
    354345#endif
    355346 
     347 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
     348    documentLoader()->applicationCacheHost()->mainResourceDataReceived(data, length, lengthReceived, allAtOnce);
     349#endif
     350
    356351    // The additional processing can do anything including possibly removing the last
    357352    // reference to this object; one example of this is 3266216.
     
    381376   
    382377#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    383     ApplicationCacheGroup* group = dl->candidateApplicationCacheGroup();
    384     if (!group && dl->applicationCache() && !dl->mainResourceApplicationCache())
    385         group = dl->applicationCache()->group();
    386    
    387     if (group)
    388         group->finishedLoadingMainResource(dl.get());
     378    dl->applicationCacheHost()->finishedLoadingMainResource();
    389379#endif
    390380}
     
    393383{
    394384#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    395     if (!error.isCancellation()) {
    396         ASSERT(!m_applicationCache);
    397         if (m_frame->settings() && m_frame->settings()->offlineWebApplicationCacheEnabled()) {
    398             m_applicationCache = ApplicationCacheGroup::fallbackCacheForMainRequest(request(), documentLoader());
    399 
    400             if (scheduleLoadFallbackResourceFromApplicationCache(m_applicationCache.get()))
    401                 return;
    402         }
    403     }
     385    if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForMainError(request(), error))
     386        return;
    404387#endif
    405388
     
    496479    m_substituteData = substituteData;
    497480
     481    ResourceRequest request(r);
     482
    498483#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    499     // Check if this request should be loaded from the application cache
    500     if (!m_substituteData.isValid() && frameLoader()->frame()->settings() && frameLoader()->frame()->settings()->offlineWebApplicationCacheEnabled()) {
    501         ASSERT(!m_applicationCache);
    502 
    503         m_applicationCache = ApplicationCacheGroup::cacheForMainRequest(r, m_documentLoader.get());
    504 
    505         if (m_applicationCache) {
    506             // Get the resource from the application cache. By definition, cacheForMainRequest() returns a cache that contains the resource.
    507             ApplicationCacheResource* resource = m_applicationCache->resourceForRequest(r);
    508             m_substituteData = SubstituteData(resource->data(),
    509                                               resource->response().mimeType(),
    510                                               resource->response().textEncodingName(), KURL());
    511         }
    512     }
    513 #endif
    514 
    515     ResourceRequest request(r);
     484    documentLoader()->applicationCacheHost()->maybeLoadMainResource(request, m_substituteData);
     485#endif
     486
    516487    bool defer = defersLoading();
    517488    if (defer) {
    518         bool shouldLoadEmpty = shouldLoadAsEmptyDocument(r.url());
     489        bool shouldLoadEmpty = shouldLoadAsEmptyDocument(request.url());
    519490        if (shouldLoadEmpty)
    520491            defer = false;
  • trunk/WebCore/loader/MainResourceLoader.h

    r41845 r46609  
    4040namespace WebCore {
    4141
    42 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
    43     class ApplicationCache;
    44 #endif
    4542    class FormState;
    4643    struct ResourceRequest;
     
    7168
    7269        bool isLoadingMultipartContent() const { return m_loadingMultipartContent; }
    73 
    74 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
    75         ApplicationCache* applicationCache() const { return m_applicationCache.get(); }
    76 #endif
    7770
    7871    private:
     
    10699        MainResourceLoaderTimer m_dataLoadTimer;
    107100
    108 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
    109         // The application cache that the main resource was loaded from (if any).
    110         RefPtr<ApplicationCache> m_applicationCache;
    111 #endif
    112 
    113101        bool m_loadingMultipartContent;
    114102        bool m_waitingForContentPolicy;
  • trunk/WebCore/loader/ResourceLoader.cpp

    r39962 r46609  
    3131#include "ResourceLoader.h"
    3232
     33#if ENABLE(OFFLINE_WEB_APPLICATIONS)
     34#include "ApplicationCacheHost.h"
     35#endif
    3336#include "DocumentLoader.h"
    3437#include "Frame.h"
     
    120123   
    121124#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    122     if (m_documentLoader->scheduleApplicationCacheLoad(this, clientRequest, r.url()))
     125    if (m_documentLoader->applicationCacheHost()->maybeLoadResource(this, clientRequest, r.url()))
    123126        return true;
    124127#endif
     
    191194}
    192195
    193 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
    194 bool ResourceLoader::scheduleLoadFallbackResourceFromApplicationCache(ApplicationCache* cache)
    195 {
    196     if (documentLoader()->scheduleLoadFallbackResourceFromApplicationCache(this, m_request, cache)) {
    197         handle()->cancel();
    198         return true;
    199     }
    200     return false;
    201 }
    202 #endif
    203 
    204196void ResourceLoader::willSendRequest(ResourceRequest& request, const ResourceResponse& redirectResponse)
    205197{
     
    383375{
    384376#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    385     if (!redirectResponse.isNull() && !protocolHostAndPortAreEqual(request.url(), redirectResponse.url())) {
    386         if (scheduleLoadFallbackResourceFromApplicationCache())
    387             return;
    388     }
     377    if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForRedirect(this, request, redirectResponse))
     378        return;
    389379#endif
    390380    willSendRequest(request, redirectResponse);
     
    399389{
    400390#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    401     if (response.httpStatusCode() / 100 == 4 || response.httpStatusCode() / 100 == 5) {
    402         if (scheduleLoadFallbackResourceFromApplicationCache())
    403             return;
    404     }
     391    if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForResponse(this, response))
     392        return;
    405393#endif
    406394    didReceiveResponse(response);
     
    420408{
    421409#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    422     if (!error.isCancellation()) {
    423         if (documentLoader()->scheduleLoadFallbackResourceFromApplicationCache(this, m_request))
    424             return;
    425     }
     410    if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForError(this, error))
     411        return;
    426412#endif
    427413    didFail(error);
  • trunk/WebCore/loader/ResourceLoader.h

    r41773 r46609  
    4141namespace WebCore {
    4242
    43     class ApplicationCache;
     43    class ApplicationCacheHost;
    4444    class DocumentLoader;
    4545    class Frame;
     
    120120
    121121#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    122         bool scheduleLoadFallbackResourceFromApplicationCache(ApplicationCache* = 0);
     122        friend class ApplicationCacheHost;  // for access to request()
    123123#endif
    124124
     
    134134        RefPtr<Frame> m_frame;
    135135        RefPtr<DocumentLoader> m_documentLoader;
    136         ResourceResponse m_response;       
     136        ResourceResponse m_response;
    137137       
    138138    private:
     
    140140        RefPtr<SharedBuffer> m_resourceData;
    141141       
    142         unsigned long m_identifier;       
     142        unsigned long m_identifier;
    143143
    144144        bool m_reachedTerminalState;
  • trunk/WebCore/loader/appcache/ApplicationCacheGroup.cpp

    r46344 r46609  
    3030
    3131#include "ApplicationCache.h"
     32#include "ApplicationCacheHost.h"
    3233#include "ApplicationCacheResource.h"
    3334#include "ApplicationCacheStorage.h"
     
    127128   
    128129    DocumentLoader* documentLoader = frame->loader()->documentLoader();
    129     ASSERT(!documentLoader->applicationCache());
     130    ASSERT(!documentLoader->applicationCacheHost()->applicationCache());
    130131
    131132    if (passedManifestURL.isNull()) {
     
    138139        manifestURL.removeRef();
    139140
    140     ApplicationCache* mainResourceCache = documentLoader->mainResourceApplicationCache();
     141    ApplicationCache* mainResourceCache = documentLoader->applicationCacheHost()->mainResourceApplicationCache();
    141142   
    142143    if (mainResourceCache) {
     
    176177    // Don't change anything on disk if private browsing is enabled.
    177178    if (!frame->settings() || frame->settings()->privateBrowsingEnabled()) {
    178         postListenerTask(&DOMApplicationCache::callCheckingListener, documentLoader);
    179         postListenerTask(&DOMApplicationCache::callErrorListener, documentLoader);
     179        postListenerTask(DOMApplicationCache::CHECKING_EVENT, documentLoader);
     180        postListenerTask(DOMApplicationCache::ERROR_EVENT, documentLoader);
    180181        return;
    181182    }
     
    183184    ApplicationCacheGroup* group = cacheStorage().findOrCreateCacheGroup(manifestURL);
    184185
    185     documentLoader->setCandidateApplicationCacheGroup(group);
     186    documentLoader->applicationCacheHost()->setCandidateApplicationCacheGroup(group);
    186187    group->m_pendingMasterResourceLoaders.add(documentLoader);
    187188    group->m_downloadingPendingMasterResourceLoadersCount++;
     
    197198
    198199    DocumentLoader* documentLoader = frame->loader()->documentLoader();
    199     ASSERT(!documentLoader->applicationCache());
    200 
    201     ApplicationCache* mainResourceCache = documentLoader->mainResourceApplicationCache();
     200    ASSERT(!documentLoader->applicationCacheHost()->applicationCache());
     201
     202    ApplicationCache* mainResourceCache = documentLoader->applicationCacheHost()->mainResourceApplicationCache();
    202203
    203204    if (mainResourceCache) {
     
    236237        // (its main resource was not cached yet, so it is likely that the application changed significantly server-side).
    237238        ASSERT(!m_cacheBeingUpdated); // Already cleared out by stopLoading().
    238         loader->setApplicationCache(0); // Will unset candidate, too.
     239        loader->applicationCacheHost()->setApplicationCache(0); // Will unset candidate, too.
    239240        m_associatedDocumentLoaders.remove(loader);
    240         postListenerTask(&DOMApplicationCache::callErrorListener, loader);
     241        postListenerTask(DOMApplicationCache::ERROR_EVENT, loader);
    241242        break;
    242243    case Completed:
     
    272273        // The manifest didn't change, and we have a relevant cache - but the main resource download failed mid-way, so it cannot be stored to the cache,
    273274        // and the loader does not get associated to it. If there are other main resources being downloaded for this cache group, they may still succeed.
    274         postListenerTask(&DOMApplicationCache::callErrorListener, loader);
     275        postListenerTask(DOMApplicationCache::ERROR_EVENT, loader);
    275276
    276277        break;
     
    278279        // Cache update failed, too.
    279280        ASSERT(!m_cacheBeingUpdated); // Already cleared out by stopLoading().
    280         ASSERT(!loader->applicationCache() || loader->applicationCache() == m_cacheBeingUpdated);
    281 
    282         loader->setApplicationCache(0); // Will unset candidate, too.
     281        ASSERT(!loader->applicationCacheHost()->applicationCache() || loader->applicationCacheHost()->applicationCache() == m_cacheBeingUpdated);
     282
     283        loader->applicationCacheHost()->setApplicationCache(0); // Will unset candidate, too.
    283284        m_associatedDocumentLoaders.remove(loader);
    284         postListenerTask(&DOMApplicationCache::callErrorListener, loader);
     285        postListenerTask(DOMApplicationCache::ERROR_EVENT, loader);
    285286        break;
    286287    case Completed:
     
    288289        // so it cannot be stored to the cache. If there are other main resources being downloaded for this cache group, they may still succeed.
    289290        ASSERT(m_associatedDocumentLoaders.contains(loader));
    290         ASSERT(loader->applicationCache() == m_cacheBeingUpdated);
    291         ASSERT(!loader->candidateApplicationCacheGroup());
     291        ASSERT(loader->applicationCacheHost()->applicationCache() == m_cacheBeingUpdated);
     292        ASSERT(!loader->applicationCacheHost()->candidateApplicationCacheGroup());
    292293        m_associatedDocumentLoaders.remove(loader);
    293         loader->setApplicationCache(0);
    294 
    295         postListenerTask(&DOMApplicationCache::callErrorListener, loader);
     294        loader->applicationCacheHost()->setApplicationCache(0);
     295
     296        postListenerTask(DOMApplicationCache::ERROR_EVENT, loader);
    296297
    297298        break;
     
    333334    m_pendingMasterResourceLoaders.remove(loader);
    334335
    335     loader->setApplicationCache(0); // Will set candidate to 0, too.
     336    loader->applicationCacheHost()->setApplicationCache(0); // Will set candidate to 0, too.
    336337
    337338    if (!m_associatedDocumentLoaders.isEmpty() || !m_pendingMasterResourceLoaders.isEmpty())
     
    389390    if (m_updateStatus == Checking || m_updateStatus == Downloading) {
    390391        if (updateOption == ApplicationCacheUpdateWithBrowsingContext) {
    391             postListenerTask(&DOMApplicationCache::callCheckingListener, frame->loader()->documentLoader());
     392            postListenerTask(DOMApplicationCache::CHECKING_EVENT, frame->loader()->documentLoader());
    392393            if (m_updateStatus == Downloading)
    393                 postListenerTask(&DOMApplicationCache::callDownloadingListener, frame->loader()->documentLoader());
     394                postListenerTask(DOMApplicationCache::DOWNLOADING_EVENT, frame->loader()->documentLoader());
    394395        }
    395396        return;
     
    401402        ASSERT(m_pendingEntries.isEmpty());
    402403        ASSERT(!m_cacheBeingUpdated);
    403         postListenerTask(&DOMApplicationCache::callCheckingListener, frame->loader()->documentLoader());
    404         postListenerTask(&DOMApplicationCache::callNoUpdateListener, frame->loader()->documentLoader());
     404        postListenerTask(DOMApplicationCache::CHECKING_EVENT, frame->loader()->documentLoader());
     405        postListenerTask(DOMApplicationCache::NOUPDATE_EVENT, frame->loader()->documentLoader());
    405406        return;
    406407    }
     
    411412    m_updateStatus = Checking;
    412413
    413     postListenerTask(&DOMApplicationCache::callCheckingListener, m_associatedDocumentLoaders);
     414    postListenerTask(DOMApplicationCache::CHECKING_EVENT, m_associatedDocumentLoaders);
    414415    if (!m_newestCache) {
    415416        ASSERT(updateOption == ApplicationCacheUpdateWithBrowsingContext);
    416         postListenerTask(&DOMApplicationCache::callCheckingListener, frame->loader()->documentLoader());
     417        postListenerTask(DOMApplicationCache::CHECKING_EVENT, frame->loader()->documentLoader());
    417418    }
    418419   
     
    649650    m_updateStatus = Downloading;
    650651   
    651     postListenerTask(&DOMApplicationCache::callDownloadingListener, m_associatedDocumentLoaders);
     652    postListenerTask(DOMApplicationCache::DOWNLOADING_EVENT, m_associatedDocumentLoaders);
    652653
    653654    ASSERT(m_pendingEntries.isEmpty());
     
    699700    makeObsolete();
    700701
    701     postListenerTask(&DOMApplicationCache::callObsoleteListener, m_associatedDocumentLoaders);
    702     postListenerTask(&DOMApplicationCache::callErrorListener, m_pendingMasterResourceLoaders);
     702    postListenerTask(DOMApplicationCache::OBSOLETE_EVENT, m_associatedDocumentLoaders);
     703    postListenerTask(DOMApplicationCache::ERROR_EVENT, m_pendingMasterResourceLoaders);
    703704
    704705    stopLoading();
     
    710711        HashSet<DocumentLoader*>::iterator it = m_pendingMasterResourceLoaders.begin();
    711712       
    712         ASSERT((*it)->candidateApplicationCacheGroup() == this);
    713         ASSERT(!(*it)->applicationCache());
    714         (*it)->setCandidateApplicationCacheGroup(0);
     713        ASSERT((*it)->applicationCacheHost()->candidateApplicationCacheGroup() == this);
     714        ASSERT(!(*it)->applicationCacheHost()->applicationCache());
     715        (*it)->applicationCacheHost()->setCandidateApplicationCacheGroup(0);
    715716        m_pendingMasterResourceLoaders.remove(it);
    716717    }
     
    748749            cacheStorage().storeNewestCache(this);
    749750
    750         postListenerTask(&DOMApplicationCache::callNoUpdateListener, m_associatedDocumentLoaders);
     751        postListenerTask(DOMApplicationCache::NOUPDATE_EVENT, m_associatedDocumentLoaders);
    751752        break;
    752753    case Failure:
    753754        ASSERT(!m_cacheBeingUpdated);
    754         postListenerTask(&DOMApplicationCache::callErrorListener, m_associatedDocumentLoaders);
     755        postListenerTask(DOMApplicationCache::ERROR_EVENT, m_associatedDocumentLoaders);
    755756        if (m_caches.isEmpty()) {
    756757            ASSERT(m_associatedDocumentLoaders.isEmpty());
     
    781782                cacheStorage().remove(oldNewestCache.get());
    782783            // Fire the success events.
    783             postListenerTask(isUpgradeAttempt ? &DOMApplicationCache::callUpdateReadyListener : &DOMApplicationCache::callCachedListener, m_associatedDocumentLoaders);
     784            postListenerTask(isUpgradeAttempt ? DOMApplicationCache::UPDATEREADY_EVENT : DOMApplicationCache::CACHED_EVENT, m_associatedDocumentLoaders);
    784785        } else {
    785786            if (cacheStorage().isMaximumSizeReached() && !m_calledReachedMaxAppCacheSize) {
     
    801802                // Fire the error events to all pending master entries, as well any other cache hosts
    802803                // currently associated with a cache in this group.
    803                 postListenerTask(&DOMApplicationCache::callErrorListener, m_associatedDocumentLoaders);
     804                postListenerTask(DOMApplicationCache::ERROR_EVENT, m_associatedDocumentLoaders);
    804805                // Disassociate the pending master entries from the failed new cache. Note that
    805806                // all other loaders in the m_associatedDocumentLoaders are still associated with
     
    847848    EntryMap::const_iterator it = m_pendingEntries.begin();
    848849
    849     postListenerTask(&DOMApplicationCache::callProgressListener, m_associatedDocumentLoaders);
     850    postListenerTask(DOMApplicationCache::PROGRESS_EVENT, m_associatedDocumentLoaders);
    850851
    851852    ASSERT(!m_currentHandle);
     
    911912    ASSERT(!m_isObsolete);
    912913
    913     loader->setApplicationCache(cache);
     914    loader->applicationCacheHost()->setApplicationCache(cache);
    914915
    915916    ASSERT(!m_associatedDocumentLoaders.contains(loader));
     
    945946
    946947class CallCacheListenerTask : public ScriptExecutionContext::Task {
    947     typedef void (DOMApplicationCache::*ListenerFunction)();
    948948public:
    949     static PassRefPtr<CallCacheListenerTask> create(ListenerFunction listenerFunction)
     949    static PassRefPtr<CallCacheListenerTask> create(PassRefPtr<DocumentLoader> loader, DOMApplicationCache::EventType eventType)
    950950    {
    951         return adoptRef(new CallCacheListenerTask(listenerFunction));
     951        return adoptRef(new CallCacheListenerTask(loader, eventType));
    952952    }
    953953
    954954    virtual void performTask(ScriptExecutionContext* context)
    955955    {
    956         ASSERT(context->isDocument());
    957         if (DOMWindow* window = static_cast<Document*>(context)->domWindow()) {
    958             if (DOMApplicationCache* domCache = window->optionalApplicationCache())
    959                 (domCache->*m_listenerFunction)();
    960         }
     956       
     957        ASSERT_UNUSED(context, context->isDocument());
     958        Frame* frame = m_documentLoader->frame();
     959        if (!frame)
     960            return;
     961   
     962        ASSERT(frame->loader()->documentLoader() == m_documentLoader.get());
     963
     964        m_documentLoader->applicationCacheHost()->notifyEventListener(m_eventType);
    961965    }
    962966
    963967private:
    964     CallCacheListenerTask(ListenerFunction listenerFunction)
    965         : m_listenerFunction(listenerFunction)
     968    CallCacheListenerTask(PassRefPtr<DocumentLoader> loader, DOMApplicationCache::EventType eventType)
     969        : m_documentLoader(loader)
     970        , m_eventType(eventType)
    966971    {
    967972    }
    968973
    969     ListenerFunction m_listenerFunction;
     974    RefPtr<DocumentLoader> m_documentLoader;
     975    DOMApplicationCache::EventType m_eventType;
    970976};
    971977
    972 void ApplicationCacheGroup::postListenerTask(ListenerFunction listenerFunction, const HashSet<DocumentLoader*>& loaderSet)
     978void ApplicationCacheGroup::postListenerTask(DOMApplicationCache::EventType eventType, const HashSet<DocumentLoader*>& loaderSet)
    973979{
    974980    HashSet<DocumentLoader*>::const_iterator loaderSetEnd = loaderSet.end();
    975981    for (HashSet<DocumentLoader*>::const_iterator iter = loaderSet.begin(); iter != loaderSetEnd; ++iter)
    976         postListenerTask(listenerFunction, *iter);
    977 }
    978 
    979 void ApplicationCacheGroup::postListenerTask(ListenerFunction listenerFunction, DocumentLoader* loader)
     982        postListenerTask(eventType, *iter);
     983}
     984
     985void ApplicationCacheGroup::postListenerTask(DOMApplicationCache::EventType eventType, DocumentLoader* loader)
    980986{
    981987    Frame* frame = loader->frame();
     
    985991    ASSERT(frame->loader()->documentLoader() == loader);
    986992
    987     frame->document()->postTask(CallCacheListenerTask::create(listenerFunction));
     993    frame->document()->postTask(CallCacheListenerTask::create(loader, eventType));
    988994}
    989995
  • trunk/WebCore/loader/appcache/ApplicationCacheGroup.h

    r46344 r46609  
    3333#include <wtf/HashSet.h>
    3434
     35#include "DOMApplicationCache.h"
    3536#include "KURL.h"
    3637#include "PlatformString.h"
     
    4344class ApplicationCache;
    4445class ApplicationCacheResource;
    45 class DOMApplicationCache;
    4646class Document;
    4747class DocumentLoader;
     
    9393private:
    9494    typedef void (DOMApplicationCache::*ListenerFunction)();
    95     static void postListenerTask(ListenerFunction, const HashSet<DocumentLoader*>&);
    96     static void postListenerTask(ListenerFunction, const Vector<RefPtr<DocumentLoader> >& loaders);
    97     static void postListenerTask(ListenerFunction, DocumentLoader*);
     95    static void postListenerTask(DOMApplicationCache::EventType, const HashSet<DocumentLoader*>&);
     96    static void postListenerTask(DOMApplicationCache::EventType, DocumentLoader*);
    9897    void scheduleReachedMaxAppCacheSizeCallback();
    9998
  • trunk/WebCore/loader/appcache/ApplicationCacheStorage.cpp

    r46353 r46609  
    3030
    3131#include "ApplicationCache.h"
     32#include "ApplicationCacheHost.h"
    3233#include "ApplicationCacheGroup.h"
    3334#include "ApplicationCacheResource.h"
     
    938939}   
    939940
     941bool ApplicationCacheStorage::transferApplicationCache(const String& cacheDirectory, ApplicationCacheHost* cacheHost)
     942{
     943    ApplicationCache* cache = cacheHost->applicationCache();
     944    if (!cache)
     945        return true;
     946    return ApplicationCacheStorage::storeCopyOfCache(cacheDirectory, cache);
     947}
     948
    940949bool ApplicationCacheStorage::storeCopyOfCache(const String& cacheDirectory, ApplicationCache* cache)
    941950{
  • trunk/WebCore/loader/appcache/ApplicationCacheStorage.h

    r46344 r46609  
    3838
    3939class ApplicationCache;
     40class ApplicationCacheHost;
    4041class ApplicationCacheGroup;
    4142class ApplicationCacheResource;
     
    7071    void empty();
    7172   
     73    static bool transferApplicationCache(const String& cacheDirectory, ApplicationCacheHost*);
    7274    static bool storeCopyOfCache(const String& cacheDirectory, ApplicationCache*);
    7375
  • trunk/WebCore/loader/appcache/DOMApplicationCache.cpp

    r44943 r46609  
    2929#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    3030
    31 #include "ApplicationCache.h"
    32 #include "ApplicationCacheGroup.h"
    33 #include "ApplicationCacheResource.h"
     31#include "ApplicationCacheHost.h"
    3432#include "DocumentLoader.h"
    3533#include "Event.h"
     
    4543    : m_frame(frame)
    4644{
     45    ASSERT(applicationCacheHost());
     46    applicationCacheHost()->setDOMApplicationCache(this);
    4747}
    4848
    4949void DOMApplicationCache::disconnectFrame()
    5050{
     51    ApplicationCacheHost* cacheHost = applicationCacheHost();
     52    if (cacheHost)
     53        cacheHost->setDOMApplicationCache(0);
    5154    m_frame = 0;
    5255}
    5356
    54 ApplicationCache* DOMApplicationCache::associatedCache() const
    55 {
    56     if (!m_frame)
     57ApplicationCacheHost* DOMApplicationCache::applicationCacheHost() const
     58{
     59    if (!m_frame || !m_frame->loader()->documentLoader())
    5760        return 0;
    58  
    59     return m_frame->loader()->documentLoader()->applicationCache();
     61    return m_frame->loader()->documentLoader()->applicationCacheHost();
    6062}
    6163
    6264unsigned short DOMApplicationCache::status() const
    6365{
    64     ApplicationCache* cache = associatedCache();   
    65     if (!cache)
     66    ApplicationCacheHost* cacheHost = applicationCacheHost();
     67    if (!cacheHost)
    6668        return UNCACHED;
    67 
    68     switch (cache->group()->updateStatus()) {
    69         case ApplicationCacheGroup::Checking:
    70             return CHECKING;
    71         case ApplicationCacheGroup::Downloading:
    72             return DOWNLOADING;
    73         case ApplicationCacheGroup::Idle: {
    74             if (cache->group()->isObsolete())
    75                 return OBSOLETE;
    76             if (cache != cache->group()->newestCache())
    77                 return UPDATEREADY;
    78             return IDLE;
    79         }
    80     }
    81 
    82     ASSERT_NOT_REACHED();
    83     return 0;
     69    return cacheHost->status();
    8470}
    8571
    8672void DOMApplicationCache::update(ExceptionCode& ec)
    8773{
    88     ApplicationCache* cache = associatedCache();
    89     if (!cache) {
     74    ApplicationCacheHost* cacheHost = applicationCacheHost();
     75    if (!cacheHost || !cacheHost->update())
    9076        ec = INVALID_STATE_ERR;
    91         return;
    92     }
    93    
    94     cache->group()->update(m_frame, ApplicationCacheUpdateWithoutBrowsingContext);
    9577}
    9678
    9779bool DOMApplicationCache::swapCache()
    9880{
    99     if (!m_frame)
     81    ApplicationCacheHost* cacheHost = applicationCacheHost();
     82    if (!cacheHost)
    10083        return false;
    101    
    102     ApplicationCache* cache = m_frame->loader()->documentLoader()->applicationCache();
    103     if (!cache)
    104         return false;
    105 
    106     // If the group of application caches to which cache belongs has the lifecycle status obsolete, unassociate document from cache.
    107     if (cache->group()->isObsolete()) {
    108         cache->group()->disassociateDocumentLoader(m_frame->loader()->documentLoader());
    109         return true;
    110     }
    111 
    112     // If there is no newer cache, raise an INVALID_STATE_ERR exception.
    113     ApplicationCache* newestCache = cache->group()->newestCache();
    114     if (cache == newestCache)
    115         return false;
    116    
    117     ASSERT(cache->group() == newestCache->group());
    118     m_frame->loader()->documentLoader()->setApplicationCache(newestCache);
    119    
    120     return true;
     84    return cacheHost->swapCache();
    12185}
    12286   
     
    13296}
    13397
    134 void DOMApplicationCache::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> eventListener, bool)
    135 {
    136     EventListenersMap::iterator iter = m_eventListeners.find(eventType);
     98void DOMApplicationCache::addEventListener(const AtomicString& eventName, PassRefPtr<EventListener> eventListener, bool)
     99{
     100    EventListenersMap::iterator iter = m_eventListeners.find(eventName);
    137101    if (iter == m_eventListeners.end()) {
    138102        ListenerVector listeners;
    139103        listeners.append(eventListener);
    140         m_eventListeners.add(eventType, listeners);
     104        m_eventListeners.add(eventName, listeners);
    141105    } else {
    142106        ListenerVector& listeners = iter->second;
     
    147111       
    148112        listeners.append(eventListener);
    149         m_eventListeners.add(eventType, listeners);
     113        m_eventListeners.add(eventName, listeners);
    150114    }   
    151115}
    152116
    153 void DOMApplicationCache::removeEventListener(const AtomicString& eventType, EventListener* eventListener, bool)
    154 {
    155     EventListenersMap::iterator iter = m_eventListeners.find(eventType);
     117void DOMApplicationCache::removeEventListener(const AtomicString& eventName, EventListener* eventListener, bool)
     118{
     119    EventListenersMap::iterator iter = m_eventListeners.find(eventName);
    156120    if (iter == m_eventListeners.end())
    157121        return;
     
    172136        return true;
    173137    }
    174    
     138
    175139    ListenerVector listenersCopy = m_eventListeners.get(event->type());
    176140    for (ListenerVector::const_iterator listenerIter = listenersCopy.begin(); listenerIter != listenersCopy.end(); ++listenerIter) {
     
    183147}
    184148
    185 void DOMApplicationCache::callListener(const AtomicString& eventType, EventListener* listener)
     149void DOMApplicationCache::callListener(const AtomicString& eventName, EventListener* listener)
    186150{
    187151    ASSERT(m_frame);
    188152   
    189     RefPtr<Event> event = Event::create(eventType, false, false);
     153    RefPtr<Event> event = Event::create(eventName, false, false);
    190154    if (listener) {
    191155        event->setTarget(this);
     
    199163}
    200164
    201 void DOMApplicationCache::callCheckingListener()
    202 {
    203     callListener(eventNames().checkingEvent, m_onCheckingListener.get());
    204 }
    205 
    206 void DOMApplicationCache::callErrorListener()
    207 {
    208     callListener(eventNames().errorEvent, m_onErrorListener.get());
    209 }
    210 
    211 void DOMApplicationCache::callNoUpdateListener()
    212 {
    213     callListener(eventNames().noupdateEvent, m_onNoUpdateListener.get());
    214 }
    215 
    216 void DOMApplicationCache::callDownloadingListener()
    217 {
    218     callListener(eventNames().downloadingEvent, m_onDownloadingListener.get());
    219 }
    220 
    221 void DOMApplicationCache::callProgressListener()
    222 {
    223     callListener(eventNames().progressEvent, m_onProgressListener.get());
    224 }
    225 
    226 void DOMApplicationCache::callUpdateReadyListener()
    227 {
    228     callListener(eventNames().updatereadyEvent, m_onUpdateReadyListener.get());
    229 }
    230 
    231 void DOMApplicationCache::callCachedListener()
    232 {
    233     callListener(eventNames().cachedEvent, m_onCachedListener.get());
    234 }
    235 
    236 void DOMApplicationCache::callObsoleteListener()
    237 {
    238     callListener(eventNames().obsoleteEvent, m_onObsoleteListener.get());
    239 }
     165// static
     166const AtomicString& DOMApplicationCache::toEventName(EventType eventType)
     167{
     168    switch (eventType) {
     169    case CHECKING_EVENT:
     170        return eventNames().checkingEvent;
     171    case ERROR_EVENT:
     172        return eventNames().errorEvent;
     173    case NOUPDATE_EVENT:
     174        return eventNames().noupdateEvent;
     175    case DOWNLOADING_EVENT:
     176        return eventNames().downloadingEvent;
     177    case PROGRESS_EVENT:
     178        return eventNames().progressEvent;
     179    case UPDATEREADY_EVENT:
     180        return eventNames().updatereadyEvent;
     181    case CACHED_EVENT:
     182        return eventNames().cachedEvent;
     183    case OBSOLETE_EVENT:           
     184        return eventNames().obsoleteEvent;
     185    }
     186    ASSERT_NOT_REACHED();
     187    return eventNames().errorEvent;
     188}
     189
     190// static
     191DOMApplicationCache::EventType DOMApplicationCache::toEventType(const AtomicString& eventName)
     192{
     193    if (eventName == eventNames().checkingEvent)
     194        return CHECKING_EVENT;
     195    if (eventName == eventNames().errorEvent)
     196        return ERROR_EVENT;
     197    if (eventName == eventNames().noupdateEvent)
     198        return NOUPDATE_EVENT;
     199    if (eventName == eventNames().downloadingEvent)
     200        return DOWNLOADING_EVENT;
     201    if (eventName == eventNames().progressEvent)
     202        return PROGRESS_EVENT;
     203    if (eventName == eventNames().updatereadyEvent)
     204        return UPDATEREADY_EVENT;
     205    if (eventName == eventNames().cachedEvent)
     206        return CACHED_EVENT;
     207    if (eventName == eventNames().obsoleteEvent)
     208        return OBSOLETE_EVENT;
     209 
     210    ASSERT_NOT_REACHED();
     211    return ERROR_EVENT;
     212}
     213
    240214
    241215} // namespace WebCore
  • trunk/WebCore/loader/appcache/DOMApplicationCache.h

    r44943 r46609  
    3939namespace WebCore {
    4040
    41 class ApplicationCache;
     41class ApplicationCacheHost;
    4242class AtomicStringImpl;
    4343class Frame;
     
    4848public:
    4949    static PassRefPtr<DOMApplicationCache> create(Frame* frame) { return adoptRef(new DOMApplicationCache(frame)); }
     50    ~DOMApplicationCache() { ASSERT(!m_frame); }
     51
    5052    void disconnectFrame();
    5153
     
    5961    };
    6062
     63    enum EventType {
     64        CHECKING_EVENT = 0,
     65        ERROR_EVENT,
     66        NOUPDATE_EVENT,
     67        DOWNLOADING_EVENT,
     68        PROGRESS_EVENT,
     69        UPDATEREADY_EVENT,
     70        CACHED_EVENT,
     71        OBSOLETE_EVENT
     72    };
     73
    6174    unsigned short status() const;
    62    
    6375    void update(ExceptionCode&);
    6476    void swapCache(ExceptionCode&);
    65    
    66     virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
    67     virtual void removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
     77
     78    // Event listener attributes by EventType
     79
     80    void setAttributeEventListener(EventType type, PassRefPtr<EventListener> eventListener) { m_attributeEventListeners[type] = eventListener; }
     81    EventListener* getAttributeEventListener(EventType type) const { return m_attributeEventListeners[type].get(); }
     82    void clearAttributeEventListener(EventType type) { m_attributeEventListeners[type] = 0; }
     83    void callEventListener(EventType type) { callListener(toEventName(type), getAttributeEventListener(type)); }
     84
     85    // EventTarget impl
     86
     87    virtual void addEventListener(const AtomicString& eventName, PassRefPtr<EventListener>, bool useCapture);
     88    virtual void removeEventListener(const AtomicString& eventName, EventListener*, bool useCapture);
    6889    virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&);
    69    
    7090    typedef Vector<RefPtr<EventListener> > ListenerVector;
    7191    typedef HashMap<AtomicString, ListenerVector> EventListenersMap;
     
    7595    using RefCounted<DOMApplicationCache>::deref;
    7696
    77     void setOnchecking(PassRefPtr<EventListener> eventListener) { m_onCheckingListener = eventListener; }
    78     EventListener* onchecking() const { return m_onCheckingListener.get(); }
     97    // Explicitly named attribute event listener helpers
    7998
    80     void setOnerror(PassRefPtr<EventListener> eventListener) { m_onErrorListener = eventListener; }
    81     EventListener* onerror() const { return m_onErrorListener.get(); }
     99    void setOnchecking(PassRefPtr<EventListener> listener) { setAttributeEventListener(CHECKING_EVENT, listener); }
     100    EventListener* onchecking() const { return getAttributeEventListener(CHECKING_EVENT); }
    82101
    83     void setOnnoupdate(PassRefPtr<EventListener> eventListener) { m_onNoUpdateListener = eventListener; }
    84     EventListener* onnoupdate() const { return m_onNoUpdateListener.get(); }
     102    void setOnerror(PassRefPtr<EventListener> listener) { setAttributeEventListener(ERROR_EVENT, listener);}
     103    EventListener* onerror() const { return getAttributeEventListener(ERROR_EVENT); }
    85104
    86     void setOndownloading(PassRefPtr<EventListener> eventListener) { m_onDownloadingListener = eventListener; }
    87     EventListener* ondownloading() const { return m_onDownloadingListener.get(); }
    88    
    89     void setOnprogress(PassRefPtr<EventListener> eventListener) { m_onProgressListener = eventListener; }
    90     EventListener* onprogress() const { return m_onProgressListener.get(); }
     105    void setOnnoupdate(PassRefPtr<EventListener> listener) { setAttributeEventListener(NOUPDATE_EVENT, listener); }
     106    EventListener* onnoupdate() const { return getAttributeEventListener(NOUPDATE_EVENT); }
    91107
    92     void setOnupdateready(PassRefPtr<EventListener> eventListener) { m_onUpdateReadyListener = eventListener; }
    93     EventListener* onupdateready() const { return m_onUpdateReadyListener.get(); }
     108    void setOndownloading(PassRefPtr<EventListener> listener) { setAttributeEventListener(DOWNLOADING_EVENT, listener); }
     109    EventListener* ondownloading() const { return getAttributeEventListener(DOWNLOADING_EVENT); }
    94110
    95     void setOncached(PassRefPtr<EventListener> eventListener) { m_onCachedListener = eventListener; }
    96     EventListener* oncached() const { return m_onCachedListener.get(); }
     111    void setOnprogress(PassRefPtr<EventListener> listener) { setAttributeEventListener(PROGRESS_EVENT, listener); }
     112    EventListener* onprogress() const { return getAttributeEventListener(PROGRESS_EVENT); }
    97113
    98     void setOnobsolete(PassRefPtr<EventListener> eventListener) { m_onObsoleteListener = eventListener; }
    99     EventListener* onobsolete() const { return m_onObsoleteListener.get(); }
     114    void setOnupdateready(PassRefPtr<EventListener> listener) { setAttributeEventListener(UPDATEREADY_EVENT, listener); }
     115    EventListener* onupdateready() const { return getAttributeEventListener(UPDATEREADY_EVENT); }
     116
     117    void setOncached(PassRefPtr<EventListener> listener) { setAttributeEventListener(CACHED_EVENT, listener); }
     118    EventListener* oncached() const { return getAttributeEventListener(CACHED_EVENT); }
     119
     120    void setOnobsolete(PassRefPtr<EventListener> listener) { setAttributeEventListener(OBSOLETE_EVENT, listener); }
     121    EventListener* onobsolete() const { return getAttributeEventListener(OBSOLETE_EVENT); }
    100122
    101123    virtual ScriptExecutionContext* scriptExecutionContext() const;
    102124    DOMApplicationCache* toDOMApplicationCache() { return this; }
    103125
    104     void callCheckingListener();
    105     void callErrorListener();   
    106     void callNoUpdateListener();   
    107     void callDownloadingListener();
    108     void callProgressListener();
    109     void callUpdateReadyListener();
    110     void callCachedListener();
    111     void callObsoleteListener();
    112    
     126    static const AtomicString& toEventName(EventType eventType);
     127    static EventType toEventType(const AtomicString& eventName);
     128
    113129private:
    114130    DOMApplicationCache(Frame*);
    115     void callListener(const AtomicString& eventType, EventListener*);
     131
     132    void callListener(const AtomicString& eventName, EventListener*);
    116133   
    117134    virtual void refEventTarget() { ref(); }
    118135    virtual void derefEventTarget() { deref(); }
    119136
    120     ApplicationCache* associatedCache() const;
     137    ApplicationCacheHost* applicationCacheHost() const;
    121138    bool swapCache();
    122139   
    123     RefPtr<EventListener> m_onCheckingListener;
    124     RefPtr<EventListener> m_onErrorListener;
    125     RefPtr<EventListener> m_onNoUpdateListener;
    126     RefPtr<EventListener> m_onDownloadingListener;
    127     RefPtr<EventListener> m_onProgressListener;
    128     RefPtr<EventListener> m_onUpdateReadyListener;
    129     RefPtr<EventListener> m_onCachedListener;
    130     RefPtr<EventListener> m_onObsoleteListener;
    131    
     140    RefPtr<EventListener> m_attributeEventListeners[OBSOLETE_EVENT + 1];
     141
    132142    EventListenersMap m_eventListeners;
    133143
  • trunk/WebCore/platform/KURLGoogle.cpp

    r43941 r46609  
    958958}
    959959
     960bool protocolHostAndPortAreEqual(const KURL& a, const KURL& b)
     961{
     962    if (a.parsed().scheme.end() != b.parsed().scheme.end())
     963        return false;
     964
     965    int hostStartA = a.hostStart();
     966    int hostStartB = b.hostStart();
     967    if (a.hostEnd() - hostStartA != b.hostEnd() - hostStartB)
     968        return false;
     969
     970    // Check the scheme
     971    for (int i = 0; i < a.parsed().scheme.end(); ++i)
     972        if (a.string()[i] != b.string()[i])
     973            return false;
     974   
     975    // And the host
     976    for (int i = hostStartA; i < static_cast<int>(a.hostEnd()); ++i)
     977        if (a.string()[i] != b.string()[i])
     978            return false;
     979   
     980    if (a.port() != b.port())
     981        return false;
     982
     983    return true;
     984}
     985
    960986} // namespace WebCore
    961987
  • trunk/WebKit/mac/ChangeLog

    r46565 r46609  
     12009-07-30  Michael Nordman  <michaeln@google.com>
     2
     3        Reviewed by Darin Fisher.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=27821
     6
     7        Mods to keep up with ApplicationCacheHost refactoring.
     8
     9        * WebView/WebDataSource.mm:
     10        (-[WebDataSource _transferApplicationCache:]):
     11
    1122009-07-29  David Kilzer  <ddkilzer@apple.com>
    213
  • trunk/WebKit/mac/WebView/WebDataSource.mm

    r46384 r46609  
    199199    if (!loader)
    200200        return NO;
    201    
    202     ApplicationCache* cache = loader->applicationCache();
    203     if (!cache)
    204         return YES;
    205    
     201       
    206202    NSString *cacheDir = [NSString _webkit_localCacheDirectoryWithBundleIdentifier:destinationBundleIdentifier];
    207203   
    208     return ApplicationCacheStorage::storeCopyOfCache(cacheDir, cache);
     204    return ApplicationCacheStorage::transferApplicationCache(cacheDir, loader->applicationCacheHost());
    209205}
    210206
Note: See TracChangeset for help on using the changeset viewer.