void ApplicationCache::swapCache(ExceptionState& exceptionState)
{
    recordAPIUseType();
    ApplicationCacheHost* cacheHost = applicationCacheHost();
    if (!cacheHost || !cacheHost->swapCache())
        exceptionState.throwDOMException(InvalidStateError, "there is no newer application cache to swap to.");
}
void DOMApplicationCache::disconnectFrame()
{
    ApplicationCacheHost* cacheHost = applicationCacheHost();
    if (cacheHost)
        cacheHost->setDOMApplicationCache(0);
    DOMWindowProperty::disconnectFrame();
}
unsigned short ApplicationCache::status() const
{
    ApplicationCacheHost* cacheHost = applicationCacheHost();
    if (!cacheHost)
        return ApplicationCacheHost::UNCACHED;
    return cacheHost->status();
}
void ApplicationCache::update(ExceptionState& exceptionState)
{
    recordAPIUseType();
    ApplicationCacheHost* cacheHost = applicationCacheHost();
    if (!cacheHost || !cacheHost->update())
        exceptionState.throwDOMException(InvalidStateError, "there is no application cache to update.");
}
void InspectorApplicationCacheAgent::getFramesWithManifests(
    ErrorString*,
    std::unique_ptr<
        protocol::Array<protocol::ApplicationCache::FrameWithManifest>>*
        result) {
  *result =
      protocol::Array<protocol::ApplicationCache::FrameWithManifest>::create();

  for (LocalFrame* frame : *m_inspectedFrames) {
    DocumentLoader* documentLoader = frame->loader().documentLoader();
    if (!documentLoader)
      return;

    ApplicationCacheHost* host = documentLoader->applicationCacheHost();
    ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();
    String manifestURL = info.m_manifest.getString();
    if (!manifestURL.isEmpty()) {
      std::unique_ptr<protocol::ApplicationCache::FrameWithManifest> value =
          protocol::ApplicationCache::FrameWithManifest::create()
              .setFrameId(IdentifiersFactory::frameId(frame))
              .setManifestURL(manifestURL)
              .setStatus(static_cast<int>(host->getStatus()))
              .build();
      (*result)->addItem(std::move(value));
    }
  }
}
ApplicationCache::ApplicationCache(LocalFrame* frame)
    : DOMWindowProperty(frame)
{
    ApplicationCacheHost* cacheHost = applicationCacheHost();
    if (cacheHost)
        cacheHost->setApplicationCache(this);
}
ApplicationCache::ApplicationCache(LocalFrame* frame)
    : DOMWindowProperty(frame)
{
    ScriptWrappable::init(this);
    ApplicationCacheHost* cacheHost = applicationCacheHost();
    if (cacheHost)
        cacheHost->setApplicationCache(this);
}
void InspectorApplicationCacheAgent::getApplicationCaches(ErrorString*, RefPtr<InspectorObject>* applicationCaches)
{
    DocumentLoader* documentLoader = m_inspectedPage->mainFrame()->loader()->documentLoader();
    if (!documentLoader)
        return;
    ApplicationCacheHost* host = documentLoader->applicationCacheHost();
    ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();

    ApplicationCacheHost::ResourceInfoList resources;
    host->fillResourceList(&resources);
    *applicationCaches = buildObjectForApplicationCache(resources, info);
}
示例#9
0
void InspectorApplicationCacheAgent::getApplicationCaches(RefPtr<InspectorValue>* applicationCaches)
{
    DocumentLoader* documentLoader = m_inspectorController->inspectedPage()->mainFrame()->loader()->documentLoader();
    if (documentLoader) {
        ApplicationCacheHost* host = documentLoader->applicationCacheHost();
        ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();

        ApplicationCacheHost::ResourceInfoList resources;
        host->fillResourceList(&resources);
        *applicationCaches = buildObjectForApplicationCache(resources, info);
    }
}
void InspectorApplicationCacheAgent::updateApplicationCacheStatus(LocalFrame* frame)
{
    DocumentLoader* documentLoader = frame->loader().documentLoader();
    if (!documentLoader)
        return;

    ApplicationCacheHost* host = documentLoader->applicationCacheHost();
    ApplicationCacheHost::Status status = host->status();
    ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();

    String manifestURL = info.m_manifest.string();
    m_frontend->applicationCacheStatusUpdated(m_pageAgent->frameId(frame), manifestURL, static_cast<int>(status));
}
void InspectorApplicationCacheAgent::getApplicationCacheForFrame(ErrorString* errorString, const String& frameId, RefPtr<TypeBuilder::ApplicationCache::ApplicationCache>& applicationCache)
{
    DocumentLoader* documentLoader = assertFrameWithDocumentLoader(errorString, frameId);
    if (!documentLoader)
        return;

    ApplicationCacheHost* host = documentLoader->applicationCacheHost();
    ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();

    ApplicationCacheHost::ResourceInfoList resources;
    host->fillResourceList(&resources);

    applicationCache = buildObjectForApplicationCache(resources, info);
}
void InspectorApplicationCacheAgent::updateApplicationCacheStatus(LocalFrame* frame)
{
    DocumentLoader* documentLoader = frame->loader().documentLoader();
    if (!documentLoader)
        return;

    ApplicationCacheHost* host = documentLoader->applicationCacheHost();
    ApplicationCacheHost::Status status = host->getStatus();
    ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();

    String manifestURL = info.m_manifest.getString();
    String frameId = IdentifiersFactory::frameId(frame);
    frontend()->applicationCacheStatusUpdated(frameId, manifestURL, static_cast<int>(status));
}
Response InspectorApplicationCacheAgent::getApplicationCacheForFrame(
    const String& frameId,
    std::unique_ptr<protocol::ApplicationCache::ApplicationCache>*
        applicationCache) {
  DocumentLoader* documentLoader = nullptr;
  Response response = assertFrameWithDocumentLoader(frameId, documentLoader);
  if (!response.isSuccess())
    return response;

  ApplicationCacheHost* host = documentLoader->applicationCacheHost();
  ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();

  ApplicationCacheHost::ResourceInfoList resources;
  host->fillResourceList(&resources);

  *applicationCache = buildObjectForApplicationCache(resources, info);
  return Response::OK();
}
void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest> >& result)
{
    result = TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest>::create();

    for (LocalFrame* frame : *m_inspectedFrames) {
        DocumentLoader* documentLoader = frame->loader().documentLoader();
        if (!documentLoader)
            return;

        ApplicationCacheHost* host = documentLoader->applicationCacheHost();
        ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();
        String manifestURL = info.m_manifest.string();
        if (!manifestURL.isEmpty()) {
            RefPtr<TypeBuilder::ApplicationCache::FrameWithManifest> value = TypeBuilder::ApplicationCache::FrameWithManifest::create()
                .setFrameId(IdentifiersFactory::frameId(frame))
                .setManifestURL(manifestURL)
                .setStatus(static_cast<int>(host->status()));
            result->addItem(value);
        }
    }
}
void MediaPlayerPrivateAVFoundation::prepareToPlay()
{
    LOG(Media, "MediaPlayerPrivateAVFoundation::prepareToPlay(%p)", this);

    m_preload = MediaPlayer::Auto;
    if (m_havePreparedToPlay)
        return;
    m_havePreparedToPlay = true;

    m_delayingLoad = false;
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    Frame* frame = m_player->frameView() ? m_player->frameView()->frame() : 0;
    ApplicationCacheHost* cacheHost = frame ? frame->loader()->documentLoader()->applicationCacheHost() : 0;
    ApplicationCacheResource* resource = 0;
    if (cacheHost && cacheHost->shouldLoadResourceFromApplicationCache(ResourceRequest(m_assetURL), resource) && resource)
        createAVPlayerForCacheResource(resource);
    else
#endif    
    createAVPlayerForURL(m_assetURL);
    checkPlayability();
}
void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest>>& result)
{
    result = TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest>::create();

    Frame* mainFrame = m_pageAgent->mainFrame();
    for (Frame* frame = mainFrame; frame; frame = frame->tree().traverseNext(mainFrame)) {
        DocumentLoader* documentLoader = frame->loader().documentLoader();
        if (!documentLoader)
            continue;

        ApplicationCacheHost* host = documentLoader->applicationCacheHost();
        ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();
        String manifestURL = info.m_manifest.string();
        if (!manifestURL.isEmpty()) {
            RefPtr<TypeBuilder::ApplicationCache::FrameWithManifest> value = TypeBuilder::ApplicationCache::FrameWithManifest::create()
                .setFrameId(m_pageAgent->frameId(frame))
                .setManifestURL(manifestURL)
                .setStatus(static_cast<int>(host->status()));
            result->addItem(value);
        }
    }
}
void MediaPlayerPrivateQuickTimeVisualContext::loadInternal(const String& url)
{
    if (!QTMovie::initializeQuickTime()) {
        // FIXME: is this the right error to return?
        m_networkState = MediaPlayer::DecodeError; 
        m_player->networkStateChanged();
        return;
    }

    disableComponentsOnce();

    // Initialize the task timer.
    MediaPlayerPrivateTaskTimer::initialize();

    if (m_networkState != MediaPlayer::Loading) {
        m_networkState = MediaPlayer::Loading;
        m_player->networkStateChanged();
    }
    if (m_readyState != MediaPlayer::HaveNothing) {
        m_readyState = MediaPlayer::HaveNothing;
        m_player->readyStateChanged();
    }
    cancelSeek();

    setUpCookiesForQuickTime(url);

    m_movie = adoptRef(new QTMovie(m_movieClient.get()));

#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    Frame* frame = m_player->frameView() ? m_player->frameView()->frame() : 0;
    ApplicationCacheHost* cacheHost = frame ? frame->loader()->documentLoader()->applicationCacheHost() : 0;
    ApplicationCacheResource* resource = 0;
    if (cacheHost && cacheHost->shouldLoadResourceFromApplicationCache(ResourceRequest(url), resource) && resource && !resource->path().isEmpty())
        m_movie->load(resource->path().characters(), resource->path().length(), m_player->preservesPitch());
    else
#endif
        m_movie->load(url.characters(), url.length(), m_player->preservesPitch());
    m_movie->setVolume(m_player->volume());
}
void MediaPlayerPrivateAVFoundation::setPreload(MediaPlayer::Preload preload)
{
    m_preload = preload;
    if (!m_assetURL.length())
        return;

    setDelayCallbacks(true);

    if (m_preload >= MediaPlayer::MetaData && assetStatus() == MediaPlayerAVAssetStatusDoesNotExist) {
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
        Frame* frame = m_player->frameView() ? m_player->frameView()->frame() : 0;
        ApplicationCacheHost* cacheHost = frame ? frame->loader()->documentLoader()->applicationCacheHost() : 0;
        ApplicationCacheResource* resource;
        if (cacheHost && cacheHost->shouldLoadResourceFromApplicationCache(ResourceRequest(m_assetURL), resource) && resource) {
            // AVFoundation can't open arbitrary data pointers, so if this ApplicationCacheResource doesn't 
            // have a valid local path, just open the resource's original URL.
            if (resource->path().isEmpty())
                createAVAssetForURL(resource->url());
            else
                createAVAssetForCacheResource(resource);
        } else
#endif    
            createAVAssetForURL(m_assetURL);

        createAVPlayer();

        checkPlayability();
    }

    // Don't force creation of the player item unless we already know that the asset is playable. If we aren't
    // there yet, or if we already know it is not playable, creating it now won't help.
    if (m_preload == MediaPlayer::Auto && m_assetIsPlayable)
        createAVPlayerItem();

    setDelayCallbacks(false);
}
void ApplicationCache::abort()
{
    ApplicationCacheHost* cacheHost = applicationCacheHost();
    if (cacheHost)
        cacheHost->abort();
}
示例#20
0
void DOMApplicationCache::swapCache(ExceptionCode& ec)
{
    ApplicationCacheHost* cacheHost = applicationCacheHost();
    if (!cacheHost || !cacheHost->swapCache())
        ec = INVALID_STATE_ERR;
}