Chinaunix首页 | 论坛 | 博客
  • 博客访问: 315468
  • 博文数量: 174
  • 博客积分: 3061
  • 博客等级: 中校
  • 技术积分: 1740
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-04 22:43
文章分类

全部博文(174)

文章存档

2011年(54)

2010年(14)

2009年(30)

2008年(26)

2007年(27)

2006年(23)

我的朋友

分类: WINDOWS

2011-08-04 13:28:31

最近工作需要使用qtwebkit 的离线程序部署,发现一个问题,

即qtwebkit 2.1 / qt 4.7.3 中的代码在更新结束后,将立刻生效从代码上来看

setNewestCache(m_cacheBeingUpdated.release());  // 这句话将导致直接替换旧的cache
        if (cacheStorage().storeNewestCache(this)) {
            // New cache stored, now remove the old cache.
            if (oldNewestCache)
                cacheStorage().remove(oldNewestCache.get());
            // Fire the success events.
            postListenerTask(isUpgradeAttempt ? ApplicationCacheHost::UPDATEREADY_EVENT : ApplicationCacheHost::CACHED_EVENT, m_associatedDocumentLoaders);
        } 

或者说直接使得applicationcache.swapcache变得没有意义。



考虑到实际使用情况,进行了修改, 这些修改体现了

1. 本次不生效,但是会写入db
2. 本次的旧cache如果存在,将替换其内存中的manifest resource,否则每个打开的页面将导致每次都会重复下载更新db。



m_cacheBeingUpdated->setGroup(this);
//
        if (cacheStorage().storeUpdatedCache(this))
{
            // New cache stored, now remove the old cache.
           // if (oldNewestCache)
             //   cacheStorage().remove(oldNewestCache.get());
            // Fire the success events.
if(!oldNewestCache)
{
setNewestCache(m_cacheBeingUpdated.release());
}
else
{
// 由于清单已经发生了变化,所要把清单的变化apply到旧的
oldNewestCache->setManifestResource(m_cacheBeingUpdated->manifestResource());
m_cacheBeingUpdated.release();
}
            postListenerTask(isUpgradeAttempt ? ApplicationCacheHost::UPDATEREADY_EVENT : ApplicationCacheHost::CACHED_EVENT, m_associatedDocumentLoaders);
        } 
else
{
            if (cacheStorage().isMaximumSizeReached() && !m_calledReachedMaxAppCacheSize) 
{
                // We ran out of space. All the changes in the cache storage have
                // been rolled back. We roll back to the previous state in here,
                // as well, call the chrome client asynchronously and retry to
                // save the new cache.

                // Save a reference to the new cache.
                //m_cacheBeingUpdated = m_newestCache.release();
                //if (oldNewestCache) {
                    // Reinstate the oldNewestCache.
                  //  setNewestCache(oldNewestCache.release());
                //}

if(!oldNewestCache)
{
setNewestCache(m_cacheBeingUpdated.release());
}
else
{
oldNewestCache->setManifestResource(m_cacheBeingUpdated->manifestResource());
m_cacheBeingUpdated.release();
}

                scheduleReachedMaxAppCacheSizeCallback();
                return;
            } 
else
{
                // Run the "cache failure steps"
                // Fire the error events to all pending master entries, as well any other cache hosts
                // currently associated with a cache in this group.
                postListenerTask(ApplicationCacheHost::ERROR_EVENT, m_associatedDocumentLoaders);
                // Disassociate the pending master entries from the failed new cache. Note that
                // all other loaders in the m_associatedDocumentLoaders are still associated with
                // some other cache in this group. They are not associated with the failed new cache.

                // Need to copy loaders, because the cache group may be destroyed at the end of iteration.
                Vector loaders;
                copyToVector(m_pendingMasterResourceLoaders, loaders);
                size_t count = loaders.size();
                for (size_t i = 0; i != count; ++i)
                    disassociateDocumentLoader(loaders[i]); // This can delete this group.

                // Reinstate the oldNewestCache, if there was one.
                //if (oldNewestCache) {
                    // This will discard the failed new cache.
                  //  setNewestCache(oldNewestCache.release());
                //} else {
                    // We must have been deleted by the last call to disassociateDocumentLoader().
                  //  return;
                //}

if(!oldNewestCache)
{
setNewestCache(m_cacheBeingUpdated.release());
}
else
{
oldNewestCache->setManifestResource(m_cacheBeingUpdated->manifestResource());
m_cacheBeingUpdated.release();
}
            }
        }

本次修改依然无法解决swapcache的问题,不过enough.

阅读(481) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~